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