#! /bin/sh

# Set the path
PATH=/sbin
export PATH

mount -n -o rw,remount /

rm /etc/mtab
echo "/dev/ramdisk / ext2 rw 0 0" > /etc/mtab

# try and mount the live filesystem

echo "Looking for Red Hat Live CD."

for n in mcd scd0 scd1 sonycd cdu535 hda hdb hdc hdd sbpcd0 sbpcd1 sbpcd2 sbpcd3 aztcd; do
    echo -n "    trying /dev/$n"
    mount -o ro -t iso9660 /dev/$n /cdrom 2> /dev/null
    if [ "$?" = "0" ]; then
	if [ ! -d /cdrom/live ]; then 
	    echo " directory live not found."
	    umount /cdrom
	else
	    echo " found!"
	    break
	fi
    else
	echo " none."
    fi
done

if [ ! -d /cdrom/live ]; then 
    echo "The CD image wasn't found. Reboot and try again."
    while [ "0" = "0" ] ; do
    done
fi

cd /
/bin/ln -sf /image/bin .
/bin/ln -sf /image/sbin .
/bin/ln -sf /image/lib .
/bin/ln -sf /var/run /tmp
/bin/ln -sf /var/tmp /tmp

/bin/hostname redhat.live
/sbin/ifconfig lo 127.0.0.1

cd /etc
/bin/ln -sf /image/etc/rc.d .
/bin/rm -f inittab
/bin/ln -sf /image/etc/inittab .

/bin/rm -f /ilib/*

echo "Insert a disk for /home. If you don't want to use one, type n now."
echo "Otherwise, just press return after inserting the disk."

read answer

if [ "$answer" = "n" ]; then
    exit
fi

/bin/mount -t ext2 /dev/fd0 /home
if [ "$?" != "0" ]; then
    echo "Insert a disk to format, and then use as /home. Press enter when ready."
    read answer
    /sbin/mke2fs /dev/fd0
    /bin/mount -t ext2 /dev/fd0 /home
fi


