#----------------------------------------------------------------------------
# /etc/boot.d/rc100.floppy
#
# Creation:     2004-06-26
# Last Update:  $Id: rc100.floppy 10606 2005-12-13 22:35:04Z hh $
#----------------------------------------------------------------------------
mount_floppy ()
{
    sects_1680_flop=`echo -e -n '\x20\x0D'`
    sects_boot_flop=`dd if="$flop_dev" bs=1 skip=19 count=2 2>/dev/null`

    if [ "$sects_boot_flop" = "$sects_1680_flop" ]
    then
        flop_dev="$flop_dev"u1680
    fi

    mount -r $flop_dev $flop_dir -t $boot_fs
}

if [ ! "$boot" ]
then
    boot_fs=vfat
    
    flop_dir=/boot
    flop_dev=/dev/fd0
    if ! mount_floppy
    then
        stop "can't mount boot-floppy, check drivers"
    fi
    boot_dev="$flop_dev"

    read_config $flop_dir/$rcfile

    if [ $BOOT_TYPE = "fdx2" ]
    then
        # two floppies
        if [ -f $flop_dir/$opt_archive ]
        then
            cp $flop_dir/$opt_archive /$opt_archive
        fi

        umount $flop_dir

        echo > /dev/console
        colecho "=======================================================" cy > /dev/console
        colecho " Remove BOOT-floppy, insert OPT-floppy and press Enter " cy > /dev/console
        colecho "=======================================================" cy > /dev/console
        for i in 1 2 3
        do
            do_beep
            sleep 1
        done
        read _a
        
        flop_dev=/dev/fd0
        if ! mount_floppy
        then
            stop "can't mount boot-floppy, check drivers"
        fi
        boot_dev="$flop_dev"
        
        if [ -f /$opt_archive ]
        then
            /bin/cat /$opt_archive  /boot/$opt_archive \
            | extract_opt "" "$unzip_method" "you seem to be out of ram"
            rm /$opt_archive
        else
            extract_opt $flop_dir/$opt_archive "$unzip_method" "you seem to be out of ram"
        fi
    else
        extract_opt $flop_dir/$opt_archive "$unzip_method" "you seem to be out of ram"
    fi

    exec_scripts /opt/etc/prep
    umount $flop_dir
fi
