#!/bin/sh
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: target/bootdisk/linuxrc2.sh
# Copyright (C) 2004 - 2005 The T2 SDE 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.
# --- T2-COPYRIGHT-NOTE-END ---

export PATH="/sbin:/bin:/usr/sbin:/usr/bin"

mkdir -p /lib/modules/$( uname -r )
echo -n >> /lib/modules/$( uname -r )/modules.dep

cd /dev ; rm -f fd
ln -sf /proc/kcore      core
ln -sf /proc/self/fd    fd
ln -sf fd/0             stdin
ln -sf fd/1             stdout
ln -sf fd/2             stderr
cd /

echo "Starting udevd ..."
echo "" > /proc/sys/kernel/hotplug
udevd -d

#echo "Running ldconfig ..."
#ldconfig

echo "
T2 SDE installer (2nd stage) ...

This is a small Linux distribution, loaded into your computer's memory.
It has everything needed to install T2 Linux, restore an old installation
or perform some administrative tasks."

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

echo -n "
If you use a serial terminal, enter the names of terminal devices to use,
for example '/dev/ttyS0' for the first serial port or just '/dev/console',
just hit enter otherwise. (default=vc/1 vc/2 vc/3 vc/4 vc/5 vc/6): "
read ttydevs
[ -z "$ttydevs" ] && ttydevs="vc/1 vc/2 vc/3 vc/4 vc/5 vc/6"

echo "
Just type 'stone' now, if you want to perform a normal installation of T2 "
if type -p dialog > /dev/null ; then
	echo "(or type 'stone -text' if you prefer non-dialog based menus)."
else
	echo "(only the text interface is available)."
fi

echo -e '#!/bin/sh\ncd ; exec /bin/sh --login' > /sbin/login-shell
chmod +x /sbin/login-shell

for x in $ttydevs ; do
   ( ( while : ; do agetty -i 38400 $x -n -l /sbin/login-shell ; done ) & )
done

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

