diff options
author | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2010-06-26 20:42:58 +0000 |
---|---|---|
committer | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2010-06-26 20:42:58 +0000 |
commit | c5552ad03973839d83d32d7108f20c00f192633b (patch) | |
tree | de32e4def600e56134cd085a7447cb6620542078 /target/linux/generic/base-files/init | |
parent | 7ec88f88f4c65a22b3b7e32ef87cb42dcb32a6fb (diff) |
rename target/linux/generic-2.6 to generic
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21952 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/base-files/init')
-rwxr-xr-x | target/linux/generic/base-files/init | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/target/linux/generic/base-files/init b/target/linux/generic/base-files/init new file mode 100755 index 0000000000..9e8ba7c5eb --- /dev/null +++ b/target/linux/generic/base-files/init @@ -0,0 +1,83 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +INITRAMFS=1 + +. /etc/preinit + +set_state init +echo "- init -" + +# if we have no root parameter, just go to running from ramfs +[ -z $rootfs ] && { + export NOMOUNT="No Root" + exec /sbin/init +} + +#if we have a failsafe boot selected, dont bother +#trying to find or wait for a root mount point +[ -z "$FAILSAFE" ] || { + exec /bin/busybox init +} + +# Load the modules we have in initramfs, this should +# make the media accessible, but, it may take some time +. /etc/functions.sh +load_modules /etc/modules /etc/modules.d/* + +#wait 10 seconds for the disc to show up +#usb stick typically takes 4 to 6 seconds +#till it's readable +#it's quite possible the disc never shows up +#if we netbooted this kernel +COUNTER=0 +while [ $COUNTER -lt 10 ]; do + sleep 1 + [ -e $rootfs ] && let COUNTER=10; + let COUNTER=COUNTER+1 +done +[ -e $rootfs ] || { + export FAILSAFE="NoDisc" + exec /bin/busybox init +} + +# now we'll try mount it, again with a timeout +# This will fail if the inserted stick is formatted +# in a manner we dont understand +COUNTER=0 +while [ $COUNTER -lt 10 ]; do + sleep 1 + mount $rootfs /mnt + [ $? -eq "0" ] && let COUNTER=100; + let COUNTER=COUNTER+1 +done +[ $? -ne "0" ] && { + export FAILSAFE="MountFail" + exec /bin/busybox init +} + +#It mounted, lets look for a postinit file, again, give it time +#I've seen this take 6 seconds to actually complete +COUNTER=0 +while [ $COUNTER -lt 10 ]; do + sleep 1 + [ -e /mnt/etc/banner ] && let COUNTER=10; + let COUNTER=COUNTER+1 +done +[ -e /mnt/etc/banner ] || { + export FAILSAFE="No Openwrt FS" + exec /bin/busybox init +} + +unset rootfs + +mount -o move /proc /mnt/proc +mount -o move /dev /mnt/dev +mount -o move /dev/pts /mnt/dev/pts +mount -o move /tmp /mnt/tmp +mount -o move /sys /mnt/sys +mount none /tmp -t tmpfs +killall -q hotplug2 +exec switch_root -c /dev/console /mnt /sbin/init + +set_state done |