#!/bin/sh
##########################################################################
##                                                                      ##
## makes a boot disk which can be used to boot into the rescue system   ##
## in case the bios does not support bootable cdroms.                   ##
## copylefted by Timo Benk <t_benk@users.sourceforge.net>               ##
##                                                                      ##
##########################################################################

. ../config_build
. ../"$SCRIPTS"/misc/lib/lib_fail

if ! [ "$1" ]; then
    cat <<EOF
Usage: $0 BOOTLOADER
BOOTLOADER = lilo or syslinux
This script creates a bootable floppy disk which you can
use to boot into the rescue system on systems where the
bios does not support el torito cdroms.

Important: This script should only be called out of the utils
directory.
EOF
     exit 1
fi

BOOTLOADER=$1
cd ..

case $BOOTLOADER in
    syslinux)
	"$SCRIPTS"/make/syslinux/make_check            || exit 1
	"$SCRIPTS"/make/syslinux/make_initrd           || exit 1
	"$SCRIPTS"/make/syslinux/make_toritoimage 144  || exit 1
	;;
    lilo)
	"$SCRIPTS"/make/lilo/make_check            || exit 1
	"$SCRIPTS"/make/lilo/make_initrd           || exit 1
	"$SCRIPTS"/make/lilo/make_toritoimage 144  || exit 1
	;;
    *)
	exit 1
	;;
esac

# catch the freshly created boot disk image
mv $ROOTFS/boot/boot.img $TMPDIR/boot.img

echo "Transferring floppy disk image to /dev/fd0. That will take some time."
dd if=$TMPDIR/boot.img of=/dev/fd0u1722

# and remove it finally
rm $TMPDIR/boot.img
