#!/bin/sh
-${FAILSAFE:+exit}
-
syslog_ip=$(nvram get log_ipaddr)
eval $(ipcalc "$syslog_ip")
[ "$syslog_ip" = "$IP" ] || syslog_ip=""
syslogd -C 16 ${syslog_ip:+-L -R $syslog_ip}
klogd
-#${FAILSAFE:+telnetd -l /bin/login; ifup lan; exit}
for i in /etc/init.d/S*; do
$i start 2>&1
done | logger -s -p 6 -t '' &
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mount none /proc -t proc
+size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
+mount none /tmp -t tmpfs -o size=$size
+
insmod diag
+echo /sbin/hotplug.failsafe > /proc/sys/kernel/hotplug
set_state preinit
ifname=eth0
}
ifconfig $ifname 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!"
-echo /sbin/hotplug.failsafe > /proc/sys/kernel/hotplug
-if sleep 2; then
- ifconfig $ifname 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
- }
-else
- # sleep was interrupted by a hotplug event - enter failsafe mode
- set_state failsafe
- export FAILSAFE=true
- [ "$(nvram get boot_wait)" != "on" ] && {
- nvram set boot_wait=on
- nvram commit
- }
- netmsg 192.168.1.255 "Entering Failsafe!"
- telnetd -l /bin/login <> /dev/null 2>&1
-fi
+sleep 2
+lock -w /tmp/.failsafe
echo /sbin/hotplug > /proc/sys/kernel/hotplug
-mount_root ${FAILSAFE:+failsafe}
+ifconfig $ifname 0.0.0.0 down
+
+# 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
+}
+
+mount_root
exec /sbin/init
#!/bin/sh
-# trigger for failsafe mode
-[ "$1" = "button" ] && killall sleep
+[ "$1" = "button" -a "$ACTION" = "pressed" ] && {
+ lock /tmp/.failsafe
+
+ . /etc/functions.sh
+ set_state failsafe
+ [ "$(nvram get boot_wait)" != "on" ] && {
+ nvram set boot_wait=on
+ nvram commit
+ }
+
+ netmsg 192.168.1.255 "Entering Failsafe!"
+ telnetd -l /bin/login <> /dev/null 2>&1
+}