#!/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
linux内核init->initable->rc脚本
于 2022-01-22 11:50:38 首次发布