ec171c356ef4efeece72c12065c421475f04a4ed
[openwrt/staging/yousong.git] / target / linux / brcm-2.4 / base-files / default / etc / preinit.arch
1 . /etc/functions.sh
2
3 failsafe_ip() {
4 ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up
5 }
6
7 failsafe() {
8 lock /tmp/.failsafe
9 failsafe_ip
10
11 echo "0 1 2 3 4 5u*" > /proc/switch/eth0/vlan/0/ports
12
13 set_state failsafe
14 [ -x "/usr/sbin/nvram" ] && {
15 [ "$(nvram get boot_wait)" != "on" ] && {
16 nvram set boot_wait=on
17 nvram commit
18 }
19 }
20
21 netmsg 192.168.1.255 "Entering Failsafe!"
22 telnetd -l /bin/login <> /dev/null 2>&1
23
24 ash --login
25 }
26
27 mount none /proc -t proc
28
29 insmod diag
30 set_state preinit
31 trap 'FAILSAFE=true' USR1
32 echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug
33
34 ifname=eth0
35
36 # hardware specific overrides
37 case "$(cat /proc/diag/model)" in
38 "Linksys WAP54G V1") ifname=eth1;;
39 "ASUS WL-HDD") ifname=eth1;;
40 "ASUS WL-300g") ifname=eth1;;
41 "ASUS (unknown, BCM4702)") ifname=eth1;;
42 esac
43
44 failsafe_ip
45
46 insmod switch-core
47 insmod switch-robo || insmod switch-adm || rmmod switch-core
48
49 [ -d /proc/switch/eth0 ] && {
50 echo 1 > /proc/switch/eth0/reset
51
52 # this would be easier if we blasted the message across all ports
53 # but we don't want packets leaking across interfaces
54 for port in $(seq 0 4); do {
55 echo "$port 5u*" > /proc/switch/eth0/vlan/0/ports
56 netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
57 }; done
58 } || netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
59
60 ifconfig $ifname 0.0.0.0 down
61
62 sleep 2
63