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