#!/bin/bash
## diskcopy: a DOS diskcopy clone based on dd

## name of temporary image
tmpImage=/tmp/tmpImage.$$
## floppy device
floppy=/dev/fd0

## check if not already mounted
if  mount | grep ${floppy} > /dev/null ; then
 echo -e "\033[1mFloppy device ${floppy} busy, exiting.\033[m"
 exit 3
fi

## ignore signals when copying
trap '' 0 1 2 3 15

echo -e "\033[1mInsert source disk and press <enter>\033[m"
read enter

echo -n "Copying source ....   "
dd if=${floppy} of=${tmpImage} &>/dev/null && echo Done.

while :
do
 echo -e "\033[1mInsert target disk and press <enter>\033[m"
 read enter
 
 echo -n "Copying target ....  "
 dd if=${tmpImage}  of=${floppy} &>/dev/null && echo Done.

 echo -e "\033[1mDo you want another copy of the source disk [y/n] ?\033[m"
 read answer
 case ${answer} in [Nn]*) break;; esac
done

## cleanup
rm -f ${tmpImage}