nbd's makefile/menuconfig rewrite
[openwrt/openwrt.git] / openwrt / target / default / target_skeleton / etc / preinit
1 #!/bin/sh
2 mount none /proc -t proc
3 insmod diag
4 echo 0x01 > /proc/sys/diag
5 sleep 1
6 if [ $(cat /proc/sys/reset) = 1 ] ; then
7 export FAILSAFE=true
8 while :; do { echo $(((X=(X+1)%8)%2)) > /proc/sys/diag; sleep $((X==0)); } done &
9 else
10 mount | grep jffs2 >&-
11 if [ $? = 0 ] ; then
12 mtd unlock rootfs
13 [ $(cat /proc/mtd | wc -l) = 6 ] && {
14 echo 5 > /proc/sys/diag
15 mtd unlock OpenWrt
16 mtd erase OpenWrt
17 jffs2root --move
18 }
19 mount -o remount,rw /dev/root /
20 else
21 mtd unlock mtd4
22 mount -t jffs2 /dev/mtdblock/4 /jffs
23 pivot_root /jffs /jffs/rom
24 mount none /dev -t devfs
25 mount none /proc -t proc
26 umount rom/proc rom/dev
27 fi
28 fi
29 mount none /tmp -t ramfs
30 mkdir -p /dev/pts
31 mount none /dev/pts -t devpts
32 exec /sbin/init