#!/bin/sh

if [ $# -gt 1 -o "$1" == "-h" -o "$1" == "--help" ]; then
  echo "Usage: `basename $0` [device]" 
  exit 0
fi

if [ $# -eq 1 ]; then
  floppy=$1
else
  floppy=/dev/fd0u1440
fi

echo
echo "Creating FreeDOS Bootdisk. All files will be lost!"
echo
echo -n "Continue? [yes/NO] "

read answer
if [ "$answer" != "yes" ]; then
  echo
  echo "Aborted!"
  echo
  echo -n "Press any key to continue ... "
  read
  exit 0
fi

echo
echo "Formatting floppy [$floppy] ... "
echo
fdformat $floppy
if [ $? -eq 0 ]; then
  echo
  echo "Formatting sucessfull"
else
  echo
  echo "Formatting failed. Aborting."
  echo
  echo -n "Press any key to continue ... "
  read
  exit 1
fi

echo
echo -n "Creating FreeDOS bootdisk [$floppy] ... "
gunzip -c /usr/share/dosbootdisk/floppy.gz > $floppy
if [ $? -eq 0 ]; then
  echo "done"
else
  echo "failed"
  echo
  echo -n "Press any key to continue ... "
  read
  exit 1
fi

echo
echo -n "Press any key to continue ... "
read

exit 0

