#!/bin/sh

MOUNT=/mnt/dvdrom

function doError {
	echo -n "ERROR: "
	echo "$1"
	rm -f /tmp/"$MD5FILE"
	rm -f "$MD5FILE"
	exit 1
}

echo    "Type in a short name for this CD below and hit enter."
echo 
echo    "(Do not use the '/' character.  Max 32 characters.)"
echo -n "> "

read NAME
MD5FILE=${NAME}.md5

echo -e "\nCreating MD5 checksums...\n"
find . -type f -exec md5sum "{}" >> /tmp/"$MD5FILE" \; \
	|| doError "Something happened during md5 creation."
mv -v /tmp/"$MD5FILE" . \
	|| doError "Could not move md5 file."

echo -e "\nMaking ISO...\n"
mkisofs -J -l -r -V "$NAME" -o "../$NAME.iso" . \
	|| doError "Something happened during ISO creation."

echo "Deleting files..."
mkdir -p ~amrit/files/lists/
mv -v "$MD5FILE" ~amrit/files/lists/
echo "SKIPPING rm -rf -- ./*"
