mount sysfs at boot on linux 2.6
[openwrt/svn-archive/archive.git] / openwrt / package / base-files / default / etc / preinit
1 #!/bin/sh
2 . /etc/nvram.sh
3 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
4 mount none /proc -t proc
5 insmod diag
6 [ -f /proc/sys/diag ] && echo 0x01 > /proc/sys/diag
7 sleep 1
8 if [ -f /proc/sys/reset ] && [ $(cat /proc/sys/reset) = 1 -o "$(nvram get failsafe)" = 1 ]; then
9 export FAILSAFE=true
10 [ -x /usr/sbin/nvram -a "$(nvram get boot_wait)" != "on" ] && {
11 nvram set boot_wait=on
12 nvram commit
13 }
14 while :; do { echo $(((X=(X+1)%8)%2)) > /proc/sys/diag; sleep $((X==0)); } done &
15 fi
16
17 mount_root ${FAILSAFE:+failsafe}
18
19 # automagically run firstboot
20 [ -z "$FAILSAFE" -a -z "$(nvram get no_root_swap)" ] && {
21 { mount|grep "on / type jffs2" 1>&-; } || firstboot
22 }
23
24 grep sysfs /proc/filesystems >&- 2>&- && {
25 mkdir -p /sys
26 mount -t sysfs none /sys
27 }
28
29 exec /sbin/init