#! /bin/sh

if [ -z "$1" ]
then
    echo -n 'Enter floppy device [/dev/fd0]: '
    read FLOPPY
    if [ -z "$FLOPPY" ]; then FLOPPY=/dev/fd0; fi
else
    FLOPPY="$1"
fi

if [ ! -b $FLOPPY ]
then
    echo $FLOPPY is not a block device.
    exit 1
fi

FILETYPE=`dd bs=1k count=1 if=$FLOPPY | file -`
if echo $FILETYPE | grep -q "GNU tar archive"
then
    echo Replacing existing archive...
else
    if echo $FILETYPE | grep -q "data"
    then
	echo Replacing junk on floppy...
    else
	echo There is something on the floppy: `echo $FILETYPE | cut -d: -f2-`
	echo -n 'Destroy it? [N/y]: '
	read ANSWER
	if [ "$ANSWER" != "y" -a "$ANSWER" != "Y" ]
	then
	    echo Aborting.
	    exit 1
	fi
    fi
fi

tar cvpf $FLOPPY /etc
