ramips: update HW550-3G mtd partitions
[openwrt.git] / target / linux / generic / base-files / init
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 INITRAMFS=1
5
6 . /etc/preinit
7
8 set_state init
9 echo "- init -"
10
11 # if we have no root parameter, just go to running from ramfs
12 [ -z $rootfs ] && {
13 export NOMOUNT="No Root"
14 exec /sbin/init
15 }
16
17 #if we have a failsafe boot selected, dont bother
18 #trying to find or wait for a root mount point
19 [ -z "$FAILSAFE" ] || {
20 exec /bin/busybox init
21 }
22
23 # Load the modules we have in initramfs, this should
24 # make the media accessible, but, it may take some time
25 . /etc/functions.sh
26 load_modules /etc/modules /etc/modules.d/*
27
28 #wait 10 seconds for the disc to show up
29 #usb stick typically takes 4 to 6 seconds
30 #till it's readable
31 #it's quite possible the disc never shows up
32 #if we netbooted this kernel
33 COUNTER=0
34 while [ $COUNTER -lt 10 ]; do
35 sleep 1
36 [ -e $rootfs ] && let COUNTER=10;
37 let COUNTER=COUNTER+1
38 done
39 [ -e $rootfs ] || {
40 export FAILSAFE="NoDisc"
41 exec /bin/busybox init
42 }
43
44 # now we'll try mount it, again with a timeout
45 # This will fail if the inserted stick is formatted
46 # in a manner we dont understand
47 COUNTER=0
48 while [ $COUNTER -lt 10 ]; do
49 sleep 1
50 mount $rootfs /mnt
51 [ $? -eq "0" ] && let COUNTER=100;
52 let COUNTER=COUNTER+1
53 done
54 [ $? -ne "0" ] && {
55 export FAILSAFE="MountFail"
56 exec /bin/busybox init
57 }
58
59 #It mounted, lets look for a postinit file, again, give it time
60 #I've seen this take 6 seconds to actually complete
61 COUNTER=0
62 while [ $COUNTER -lt 10 ]; do
63 sleep 1
64 [ -e /mnt/etc/banner ] && let COUNTER=10;
65 let COUNTER=COUNTER+1
66 done
67 [ -e /mnt/etc/banner ] || {
68 export FAILSAFE="No Openwrt FS"
69 exec /bin/busybox init
70 }
71
72 unset rootfs
73
74 mount -o move /proc /mnt/proc
75 mount -o move /dev /mnt/dev
76 mount -o move /dev/pts /mnt/dev/pts
77 mount -o move /tmp /mnt/tmp
78 mount -o move /sys /mnt/sys
79 mount none /tmp -t tmpfs
80 killall -q hotplug2
81 exec switch_root -c /dev/console /mnt /sbin/init
82
83 set_state done
This page took 0.052723 seconds and 5 git commands to generate.