#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: target/early/initrd/init.exec
|
|
# Copyright (C) 2007 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
|
|
|
|
modules=
|
|
root=
|
|
mode=
|
|
initrd=/sbin/init
|
|
|
|
NOCOLOR=
|
|
initargs="$*"
|
|
|
|
# read kernel arguments
|
|
[ -e /proc/cmdline ] || mount -n -t proc none /proc
|
|
set -- $( cat /proc/cmdline )
|
|
for x; do
|
|
v="${x#*=}"
|
|
case "$x" in
|
|
root=*) root="$v" ;;
|
|
init=*) init="$v" ;;
|
|
rw|ro) mode="$x" ;;
|
|
modules=*) modules=$( echo "$v" | tr ',' ' ' ) ;;
|
|
nocolor) export NOCOLOR=yes ;;
|
|
esac
|
|
done
|
|
|
|
. /etc/rc.d/functions.in
|
|
|
|
banner "Starting Early User Space environment"
|
|
|
|
title "Mounting /proc and /sys"
|
|
check mount -n -t usbfs none /proc/bus/usb
|
|
check mount -n -t sysfs none /sys
|
|
status
|
|
|
|
[ -x /bin/dmesg ] && /bin/dmesg -n 3
|
|
|
|
title "Starting udev daemon"
|
|
echo "" > /sys/kernel/uevent_helper
|
|
check udevd --daemon
|
|
status
|
|
|
|
if [ -x /sbin/modprobe -a -n "$modules" ]; then
|
|
title "Preloading requested kernel modules"
|
|
for x in $modules; do
|
|
echo -n " $x"
|
|
check modprobe -q $x
|
|
done
|
|
status
|
|
fi
|
|
|
|
title "Triggering coldplug"
|
|
check udevtrigger
|
|
check udevsettle
|
|
status
|
|
|
|
sleep 2
|
|
|
|
if [ -z "$root" ]; then
|
|
echo "No root device defined, mount it on /rootfs and exit to continue."
|
|
elif [ ! -e "$root" ]; then
|
|
start-raid
|
|
start-lvm
|
|
fi
|
|
|
|
if [ -n "$root" ]; then
|
|
for x in $( seq 1 10 ); do
|
|
[ ! -e "$root" ] || break
|
|
sleep 1
|
|
done
|
|
|
|
if [ -e "$root" ]; then
|
|
title "Mounting $root"
|
|
check mount ${mode:+-o $mode} "$root" /rootfs
|
|
status
|
|
else
|
|
echo "root device ($root) not found on time."
|
|
fi
|
|
fi
|
|
|
|
# wait for /sbin/init
|
|
while [ ! -x "/rootfs$initrd" ]; do
|
|
echo "Please mount root device on /rootfs and exit to continue"
|
|
setsid /bin/sh < /dev/vc/1 > /dev/vc/1 2> /dev/vc1
|
|
done
|
|
|
|
title "Cleaning up"
|
|
check killall udevd
|
|
check umount /sys
|
|
check umount /proc/bus/usb
|
|
check umount /proc
|
|
status
|
|
|
|
exec switch_root /rootfs "$initrd" "$initargs"
|