locking rework, drop non-napi rx, multiqueue tx, misc cleanups
[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
7 if grep devfs /proc/filesystems > /dev/null; then
8 mount none /dev -t devfs
9 else
10 mount -t sysfs none /sys
11 mount -t tmpfs tmpfs /dev -o size=512K
12 mknod /dev/console c 5 1
13 mkdir /dev/pts
14 mkdir /dev/shm
15 /sbin/hotplug2 --no-persistent --coldplug --max_children 1
16 fi
17
18 mount none /dev/pts -t devpts
19
20 # the root mount point can come from the kernel command line
21 # or it can be overridden in the preinit.arch file
22 [ -f /etc/preinit.arch ] && . /etc/preinit.arch
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 exec switch_root -c /dev/console /mnt /sbin/init
This page took 0.053905 seconds and 5 git commands to generate.