From 4093d60602ab2b3dad9a0488b6a3bcb40a9e169d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 3 Feb 2007 10:53:58 +0000 Subject: [PATCH] backport failsafe changes from kamikaze - the whiterussian implementation failed on devices with no /dev/console SVN-Revision: 6254 --- .../package/base-files/default/etc/preinit | 41 ++++++++++++++++--- .../base-files/default/sbin/hotplug.failsafe | 26 ++---------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/openwrt/package/base-files/default/etc/preinit b/openwrt/package/base-files/default/etc/preinit index 5b315927b3..3f94442c67 100755 --- a/openwrt/package/base-files/default/etc/preinit +++ b/openwrt/package/base-files/default/etc/preinit @@ -1,20 +1,47 @@ #!/bin/sh +# Copyright (C) 2006 OpenWrt.org + . /etc/functions.sh export PATH=/bin:/sbin:/usr/bin:/usr/sbin +failsafe() { + lock /tmp/.failsafe + + echo "0 1 2 3 4 5u*" > /proc/switch/eth0/vlan/0/ports + + set_state failsafe + [ -x "/usr/sbin/nvram" ] && { + [ "$(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 + + ash --login +} + +export PATH=/bin:/sbin:/usr/bin:/usr/sbin mount none /proc -t proc size=$(awk '/Mem:/ {l=5242880;print((s=$2/2) /proc/sys/kernel/hotplug set_state preinit +trap 'FAILSAFE=true' USR1 +echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug ifname=eth0 -# WAP54G, WL-HDD -[ "$(nvram get boardnum)" = "2" \ --o \( "$(nvram get boardnum)" = "asusX" \ - -a "$(($(nvram get et1phyaddr)))" -eq 1 \) ] && ifname="eth1" + +# hardware specific overrides +case "$(cat /proc/diag/model)" in + "Linksys WAP54G V1") ifname=eth1;; + "ASUS WL-HDD") ifname=eth1;; + "ASUS WL-300g") ifname=eth1;; + "ASUS (unknown, BCM4702)") ifname=eth1;; +esac insmod switch-core insmod switch-robo || insmod switch-adm || rmmod switch-core @@ -41,7 +68,10 @@ ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up sleep 2 +eval ${FAILSAFE:+failsafe} + lock -w /tmp/.failsafe +set_state preinit echo /sbin/hotplug > /proc/sys/kernel/hotplug ifconfig $ifname 0.0.0.0 down @@ -56,5 +86,4 @@ ifconfig $ifname 0.0.0.0 down } mount_root - exec /sbin/init diff --git a/openwrt/package/base-files/default/sbin/hotplug.failsafe b/openwrt/package/base-files/default/sbin/hotplug.failsafe index 8a3cb9b7fb..0544339de8 100755 --- a/openwrt/package/base-files/default/sbin/hotplug.failsafe +++ b/openwrt/package/base-files/default/sbin/hotplug.failsafe @@ -1,24 +1,4 @@ #!/bin/sh -[ "$1" = "button" -a "$ACTION" = "pressed" ] && { - echo /bin/true > /proc/sys/kernel/hotplug - lock /tmp/.failsafe - - case "$(nvram get boardtype)" in - 0x0467|0x042f) echo "0 1 2 3 5u*";; - *) echo "1 2 3 4 5u*";; - esac > /proc/switch/eth0/vlan/0/ports - - . /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 - - exec /dev/console 2>/dev/console - ash --login - lock -u /tmp/.failsafe -} +case "$1" in + button) kill -USR1 1;; +esac -- 2.30.2