ar71xx: fix network configuration for the TL-WA901N/ND boards
[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 [ -n "$SWITCH_ROOT_TMPFS" ] && {
12 mount none /mnt -t tmpfs
13 ( cd /; find -xdev -type d ) | ( cd /mnt; xargs mkdir -p )
14 find / \! -type d -xdev | tar -cT /proc/self/fd/0 | tar -xC /mnt
15 mkdir /mnt/proc /mnt/dev /mnt/tmp /mnt/sys
16 mount -o move /proc /mnt/proc
17 mount -o move /dev /mnt/dev
18 mount -o move /tmp /mnt/tmp
19 mount -o move /sys /mnt/sys
20 rm -rf /proc /dev /tmp /sys
21 exec switch_root -c /dev/console /mnt /sbin/init
22 }
23
24 # if we have no root parameter, just go to running from ramfs
25 [ -z $rootfs ] && {
26 export NOMOUNT="No Root"
27 exec /sbin/init
28 }
29
30 #if we have a failsafe boot selected, dont bother
31 #trying to find or wait for a root mount point
32 [ -z "$FAILSAFE" ] || {
33 exec /bin/busybox init
34 }
35
36 # Load the modules we have in initramfs, this should
37 # make the media accessible, but, it may take some time
38 . /etc/functions.sh
39 load_modules /etc/modules /etc/modules.d/*
40
41 #wait 10 seconds for the disc to show up
42 #usb stick typically takes 4 to 6 seconds
43 #till it's readable
44 #it's quite possible the disc never shows up
45 #if we netbooted this kernel
46 COUNTER=0
47 while [ $COUNTER -lt 10 ]; do
48 sleep 1
49 [ -e $rootfs ] && let COUNTER=10;
50 let COUNTER=COUNTER+1
51 done
52 [ -e $rootfs ] || {
53 export FAILSAFE="NoDisc"
54 exec /bin/busybox init
55 }
56
57 # now we'll try mount it, again with a timeout
58 # This will fail if the inserted stick is formatted
59 # in a manner we dont understand
60 COUNTER=0
61 while [ $COUNTER -lt 10 ]; do
62 sleep 1
63 mount $rootfs /mnt
64 [ $? -eq "0" ] && let COUNTER=100;
65 let COUNTER=COUNTER+1
66 done
67 [ $? -ne "0" ] && {
68 export FAILSAFE="MountFail"
69 exec /bin/busybox init
70 }
71
72 #It mounted, lets look for a postinit file, again, give it time
73 #I've seen this take 6 seconds to actually complete
74 COUNTER=0
75 while [ $COUNTER -lt 10 ]; do
76 sleep 1
77 [ -e /mnt/etc/banner ] && let COUNTER=10;
78 let COUNTER=COUNTER+1
79 done
80 [ -e /mnt/etc/banner ] || {
81 export FAILSAFE="No Openwrt FS"
82 exec /bin/busybox init
83 }
84
85 unset rootfs
86
87 mount -o move /proc /mnt/proc
88 mount -o move /dev /mnt/dev
89 mount -o move /dev/pts /mnt/dev/pts
90 mount -o move /tmp /mnt/tmp
91 mount -o move /sys /mnt/sys
92 mount none /tmp -t tmpfs
93 killall -q hotplug2
94 exec switch_root -c /dev/console /mnt /sbin/init
95
96 set_state done
This page took 0.050342 seconds and 5 git commands to generate.