fix typos in CONFIG_SITE files
[openwrt/svn-archive/openwrt.git] / openwrt / package / base-files / default / etc / preinit
1 #!/bin/sh
2 . /etc/functions.sh
3 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
4
5 mount none /proc -t proc
6 size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
7 mount none /tmp -t tmpfs -o size=$size
8
9 insmod diag
10 echo /sbin/hotplug.failsafe > /proc/sys/kernel/hotplug
11 set_state preinit
12
13 ifname=eth0
14 # WAP54G, WL-HDD
15 [ "$(nvram get boardnum)" = "2" \
16 -o \( "$(nvram get boardnum)" = "asusX" \
17 -a "$(($(nvram get et1phyaddr)))" -eq 1 \) ] && ifname="eth1"
18
19 insmod switch-core
20 insmod switch-robo || insmod switch-adm || rmmod switch-core
21
22 ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up
23
24 # save the boot loader's vlan config
25 # we need it on some routers that have no vlan*ports set
26 [ -d /proc/switch/eth0 ] && {
27 export v0p="$(cat /proc/switch/eth0/vlan/0/ports)"
28 export v1p="$(cat /proc/switch/eth0/vlan/1/ports)"
29 export v2p="$(cat /proc/switch/eth0/vlan/2/ports)"
30 echo 1 > /proc/switch/eth0/reset
31
32 # this would be easier if we blasted the message across all ports
33 # but we don't want packets leaking across interfaces
34
35 for port in $(seq 0 4); do {
36 echo "$port 5u*" > /proc/switch/eth0/vlan/0/ports
37 netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
38 }; done
39
40 } || netmsg 192.168.1.255 "Press reset now, to enter Failsafe!"
41
42 sleep 2
43
44 lock -w /tmp/.failsafe
45 echo /sbin/hotplug > /proc/sys/kernel/hotplug
46
47 ifconfig $ifname 0.0.0.0 down
48
49 # revert to the boot loader's vlan config
50 # required for at least WRT54G v1.1
51 [ -d /proc/switch/eth0 ] && {
52 echo "$v0p" > /proc/switch/eth0/vlan/0/ports
53 echo "$v1p" > /proc/switch/eth0/vlan/1/ports
54 echo "$v2p" > /proc/switch/eth0/vlan/2/ports
55 unset v0p v1p v2p
56 }
57
58 mount_root
59
60 exec /sbin/init