diff options
Diffstat (limited to 'packages/initrdscripts/files/init.sh')
-rw-r--r-- | packages/initrdscripts/files/init.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/packages/initrdscripts/files/init.sh b/packages/initrdscripts/files/init.sh new file mode 100644 index 0000000000..8c9803f21b --- /dev/null +++ b/packages/initrdscripts/files/init.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +MODULE_DIR=/initrd.d +BOOT_ROOT= +ROOT_DEVICE=/dev/null + +early_setup() { + mkdir /proc + mount -t proc proc /proc + mkdir /mnt + + echo -n "creating device nodes: " + grep '^ *[0-9]' /proc/partitions | while read major minor blocks dev + do + if [ ! -e /dev/$dev ]; then + echo -n "$dev " + [ -e /dev/$dev ] || mknod /dev/$dev b $major $minor + fi + done + echo +} + +read_args() { + CMDLINE=`cat /proc/cmdline` + for arg in $CMDLINE; do + optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` + case $arg in + root=*) + ROOT_DEVICE=$optarg ;; + rootdelay=*) + rootdelay=$optarg ;; + esac + done +} + +load_modules() { + for module in $MODULE_DIR/*; do + source $module + done +} + +boot_root() { + cd $BOOT_ROOT + exec switch_root -c /dev/console $BOOT_ROOT /sbin/init +} + +boot_failed() { + echo "No valid root device was specified. Please add root=/dev/something to" + echo "the kernel command-line and try again." + echo + exec sh +} + +echo "Starting initramfs boot..." +early_setup +read_args + +if [ -n "$rootdelay" ]; then + echo "Waiting $rootdelay seconds for devices to settle..." + sleep $rootdelay +fi + +load_modules +[ -n "$BOOT_ROOT" ] && boot_root +boot_failed |