#!/bin/sh
#
# ROCK Linux: /sbin/init  (rescue disk version)
#

if ! [ -e /dev/.devfsd ] ; then
	mount -v -n -t devfs none /dev
	echo "Mounted /dev (devfs) from /sbin/init." > /dev/console
fi

exec < /dev/console > /dev/console 2>&1

cd / ; echo 'Init started - setting up necessary stuff ...'
mount -n -t proc none /proc ; mount -o remount,rw / ; hostname localhost
[ -f /bin/ifconfig ] && ifconfig lo 127.0.0.1 netmask 255.0.0.0 up
. /etc/profile

for x in /etc/setup-*.sh /setup/setup.sh ; do
   if [ -f "$x" ] ; then
      echo "Running $x ..." ; sh $x
      echo "Setup script $x finished."
   fi
done

echo ; helpmsg

echo "Try to load all kernel-modules available? (YES/no) "
read in
case "$in" in
    [nN]*) echo;;
    *) echo
       find /lib/modules -name "*.o" | xargs insmod > /dev/null 2>&1;;
esac

echo "Enter the names of all terminal devices (e.g. 'vc/1' or 'tts/0')."
echo -n "An empty text stands for vc/1 - vc/6: "  ;  read ttydevs
[ -z "$ttydevs" ] && ttydevs="vc/1 vc/2 vc/3 vc/4 vc/5 vc/6"
for x in $ttydevs ; do
   ( ( while : ; do agetty -i 38400 $x -n -l /sbin/login-shell ; done ) & )
done


exec > /dev/null 2>&1
while : ; do sleep 1 ; done
