#! /bin/bash

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/root/bin:/usr/X11R6/bin:/usr/local/bin:/lbin

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

#echo verbose >/proc/splash

echo 'root: reboot' > /etc/yast.inf

set > /tmp/SETTING

## Evaluate the boot parameter
for i in `cat /proc/cmdline `
do
    echo $i | grep -q '=' && eval "export $i";
done

if [ -z "$NOSSH" ]
then
	/usr/bin/ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N ''
	/usr/bin/ssh-keygen -t dsa  -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
	/usr/bin/ssh-keygen -t rsa  -b 1024 -f /etc/ssh/ssh_host_rsa_key -N ''
	/usr/sbin/sshd -q
	chmod 700 /root/.ssh/
	chmod 600 /root/.ssh/authorized_keys
fi

## Check for some boot parameter
if [ -z "${SERVER}" ]
then
        export SERVER="admin"
fi

curl ftp://${SERVER}/itool/scripts/login > /root/login
curl ftp://${SERVER}/itool/scripts/clone.sh > /root/clone.sh

/bin/bash ${CDEBUG} -l /root/login

