From 929a2cfaff3b9eac294f18ba2ac2304e6d8b025d Mon Sep 17 00:00:00 2001 From: Mike Baker Date: Sun, 12 Feb 2006 13:26:42 +0000 Subject: [PATCH] cleanup preinit; move failsafe into preinit SVN-Revision: 3225 --- .../package/base-files/default/etc/init.d/rcS | 2 + .../package/base-files/default/etc/preinit | 40 ++++++++----------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/openwrt/package/base-files/default/etc/init.d/rcS b/openwrt/package/base-files/default/etc/init.d/rcS index 706585801c..6d5bcd7d20 100755 --- a/openwrt/package/base-files/default/etc/init.d/rcS +++ b/openwrt/package/base-files/default/etc/init.d/rcS @@ -1,4 +1,6 @@ #!/bin/sh +${FAILSAFE:+exit} + syslog_ip=$(nvram get log_ipaddr) ipcalc -s "$syslog_ip" || syslog_ip="" syslogd -C 16 ${syslog_ip:+-L -R $syslog_ip} diff --git a/openwrt/package/base-files/default/etc/preinit b/openwrt/package/base-files/default/etc/preinit index d4e99277d5..39b796b2d3 100755 --- a/openwrt/package/base-files/default/etc/preinit +++ b/openwrt/package/base-files/default/etc/preinit @@ -1,17 +1,13 @@ #!/bin/sh export PATH=/bin:/sbin:/usr/bin:/usr/sbin + mount none /proc -t proc insmod diag echo 0x01 > /proc/sys/diag -ifconfig eth0 up insmod switch-core insmod switch-robo || insmod switch-adm || rmmod switch-core -case "$(nvram get boardtype)" in - 0x0467) failsafe_vlan="0 1 2 3 5u*";; - *) failsafe_vlan="1 2 3 4 5u*";; -esac # save the boot loader's vlan config # we need it on some routers that have no vlan*ports set [ -d /proc/switch/eth0 ] && { @@ -19,10 +15,13 @@ esac v1p="$(cat /proc/switch/eth0/vlan/1/ports)" v2p="$(cat /proc/switch/eth0/vlan/2/ports)" echo 1 > /proc/switch/eth0/reset - echo "$failsafe_vlan" > /proc/switch/eth0/vlan/0/ports + + case "$(nvram get boardtype)" in + 0x0467) echo "0 1 2 3 5u*";; + *) echo "1 2 3 4 5u*";; + esac > /proc/switch/eth0/vlan/0/ports } -# this delay is apparently necessary because the link isn't up yet ifconfig eth0 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up netmsg 192.168.1.0 "(dummy message)" # b44 eats the first packet netmsg 192.168.1.255 "Press reset now, to enter Failsafe!" @@ -30,31 +29,26 @@ netmsg 192.168.1.255 "Press reset now, to enter Failsafe!" sleep 2 if [ $(cat /proc/sys/reset) = 1 -o "$(nvram get failsafe)" = 1 ]; then + while :; do { echo $(((X=(X+1)%8)%2)) > /proc/sys/diag; sleep $((X==0)); } done & export FAILSAFE=true [ "$(nvram get boot_wait)" != "on" ] && { nvram set boot_wait=on nvram commit } - while :; do { echo $(((X=(X+1)%8)%2)) > /proc/sys/diag; sleep $((X==0)); } done & netmsg 192.168.1.255 "Entering Failsafe!" + telnetd -l /bin/login else - netmsg 192.168.1.255 "Normal startup." + ifconfig eth0 0.0.0.0 + + # revert to the boot loader's vlan config + # required for at least WRT54G v1.1 + [ -d /proc/switch/eth0 ] && { + echo "$v0p" > /proc/switch/eth0/vlan/0/ports + echo "$v1p" > /proc/switch/eth0/vlan/1/ports + echo "$v2p" > /proc/switch/eth0/vlan/2/ports + } fi mount_root ${FAILSAFE:+failsafe} -# revert to the boot loader's vlan config -# required for at least WRT54G v1.1 -[ -d /proc/switch/eth0 ] && { - echo "$v0p" > /proc/switch/eth0/vlan/0/ports - echo "$v1p" > /proc/switch/eth0/vlan/1/ports - echo "$v2p" > /proc/switch/eth0/vlan/2/ports -} - -# remove the drivers for now -rmmod switch-robo -rmmod switch-adm -rmmod switch-core -ifconfig eth0 0.0.0.0 - exec /sbin/init -- 2.30.2