linux内核init->initable->rc脚本

#!/bin/sh

#
# create essential directory
#
mkdir /var/empty
mkdir /dev/pts

mount -t devpts devpts /dev/pts > /dev/null
mount -t proc proc /proc > /dev/null
mount -o loop /sqfs.img /sqfs > /dev/null
mount -o loop /modsqfs.img /modsqfs > /dev/null

# Mount CFG JFFS2 File System
mount -t jffs2 -o rw,sync /dev/mtdblock3 /mnt > /dev/null

# Mount LOG JFFS2 File System
#mount -t jffs2 -o rw,sync /dev/mtdblock4 /mntlog > /dev/null

#
# mount process
#
#mountfs

echo 5 > /proc/sys/kernel/printk
#
# TCP keepalive settings
#
echo 300 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 10 > /proc/sys/net/ipv4/tcp_keepalive_intvl
echo 6 > /proc/sys/net/ipv4/tcp_keepalive_probes

#
# insert kernel module if exist
# default path is /lib/modules/2.6.19/kernel
#
if test -d "/lib/modules/2.6.32.58/kernel"; then
	cd /lib/modules/2.6.32.58/kernel
fi
if test -d "/lib/modules/2.6.19/kernel"; then
	cd /lib/modules/2.6.19/kernel
fi

if test -f "drivers/net/switch/rtcore/rtcore.ko"; then
	insmod drivers/net/switch/rtcore/rtcore.ko
fi

if test -f "drivers/net/switch/rtk/rtk.ko"; then
	insmod drivers/net/switch/rtk/rtk.ko
fi

if test -f "drivers/net/switch/rtnic/rtnic.ko"; then
       insmod drivers/net/switch/rtnic/rtnic.ko
fi

if test -f "net/switch/rtdrv/rtdrv.ko"; then
	insmod net/switch/rtdrv/rtdrv.ko
fi


cd /

# Remove ko from file system
if test -f "/modsqfs.img"; then
	umount /modsqfs
	rm -f /modsqfs.img
else
	rm -rf /lib/modules
fi

# install netlink_api_proxy.ko for port link monitor
if test -f "/sqfs/usr/lib/modules/bcm_api_proxy.ko"; then
	insmod /sqfs/usr/lib/modules/bcm_api_proxy.ko
fi
# install for gpio and kernel register
#if test -f "/sqfs/usr/lib/modules/bcm_api_proxy.ko"; then
#	insmod /sqfs/usr/lib/modules/kernel_register.ko
#fi

#
# network interface configuration
#
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.255.255.0 lo
ifconfig eth0 up

#
# start application
#

if test -f "/bin/klogd"; then
        klogd &
fi

if [ ! -f /mnt/config ]; then
	mkdir -p /mnt/config
fi

if [ -d /var/config ]; then
    	rm -rf /var/config
fi
ln -s /mnt/config /var/config

if [ ! -f /var/config/switch.conf ]; then
	cp -f /etc/default/switch.conf /var/config
fi

if [ -f /var/config/switch_upload.conf ]; then
	rm /mnt/config/switch.conf
	mv /mnt/config/switch_upload.conf /mnt/config/switch.conf
fi


if [ ! -f /var/config/licence.info ]; then
	cp -f /etc/default/licence.info /var/config
fi

#weimeng customer not need this function
#if [ ! -f /var/config/factory_flag ]; then
#	cp -f /etc/default/factory_flag /var/config
#fi

if [ ! -d /var/tmp ]; then
    mkdir /var/tmp
fi

if [ ! -d /var/tmp/tftp ]; then
    mkdir /var/tmp/tftp
fi

if [ ! -d /var/tmp/config ]; then
    mkdir /var/tmp/config
fi

if [ ! -d /var/run ]; then
    mkdir /var/run
fi

if [ ! -d /var/log ]; then
    mkdir /var/log
fi

if [ ! -d /var/net-snmp ]; then
    mkdir /var/net-snmp
fi

if [ ! -d /var/syslog ]; then
    mkdir /var/syslog
fi

if [ ! -d /var/vmanage ]; then
    mkdir /var/vmanage
fi


# if [ -f /mnt/mac_config ]; then
#	MAC=`cat /mnt/mac_config`
#	ifconfig eth0 down
#	ifconfig eth0 hw ether $MAC
#	ifconfig eth0 up
# fi

#rtusr &
#backpre &
#swctrl &
#if test -f "/bin/cli"; then
#	if test -f "/bin/login"; then
#		ln -s /bin/cli /bin/login
#	fi
#fi

mknod /dev/LocalArpGuardDev c 130 0

#cp -f /etc/default/hardware_model /var/config
if [ ! -f /var/config/hardware_model ]; then
	ln -s /etc/default/hardware_model /var/config/hardware_model
fi
echo  1 >  /var/snmpd.conf
echo  "agentaddress udp6:161" >>  /var/snmpd.conf

Switch_server_monitor.sh &
cpu_usage &
sys_led_run &
switch_server &

if [ -f /sqfs/usr/sbin/swctrl ]; then
	swctrl &
fi

if [ -f /sqfs/usr/sbin/vsftpd ]; then
    mkdir -m 0755 -p /var/run/vsftpd
    chown admin /etc/vsftpd.conf
    vsftpd &
fi

if [ -f /sqfs/usr/sbin/ac_guard ];then
    if [ ! -d /var/config/data ]; then
	mkdir -m 0755 -p /var/config/data
    	cp -f /sqfs/home/apm/data/* /var/config/data/
    fi
    ac_guard &
fi

if [ ! -d "/etc/crontabs/" ] ;then
    mkdir -p /etc/crontabs
fi

if [ ! -d "/var/spool/cron" ] ;then
    mkdir -p /var/spool/cron
    ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
fi
/sbin/busybox crond -f -c /etc/crontabs -l 10 &

#sleep 2
#cp -f /usr/local/share/snmp/snmpd.conf /var/snmpd.conf

#
#Open IP forwarding setting
#use hardware ip forwarding, not software
#echo 1 > /proc/sys/net/ipv4/ip_forward

switch_cli
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

the future c

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值