#! /bin/sh
# img2cd  
# writes image to CD
#
# Schreibgerät Kontrollieren, ob untenstehende Angabe richtig! 
# schreibt auch auf HD !!!
#
# 990808; 000416; 000417; 001026

#     which image ?
IMAGE_DIR="/tmp/img/"
#CD_IMAGE="dose.raw"
CD_IMAGE="track01.raw"
#CD_IMAGE="/dosg/cd-imgs/linsik_0.raw"
if test $# -ne 0; then CD_IMAGE=$1; fi
if ! test -f $IMAGE_DIR$CD_IMAGE; then 
  echo image-file $IMAGE_DIR$CD_IMAGE not found
  exit 1
fi

IMG2CD_LOG="./iso2cd.log"

#     Options   (  == Schalter setzen :-)  )
G_OPTS="-v speed=4 fs=4m dev=0,3,0"   # general
OPTS=""                               # specials
#OPTS=" -debug"$OPTS
OPTS=" -dummy"$OPTS
OPTS=" -multi"$OPTS
#echo "OPTS: $G_OPTS $OPTS"
echo -e " Writes Iso-Image  \"$IMAGE_DIR$CD_IMAGE\"  to CD,\n Log to \
        \"$IMG2CD_LOG\"\n\n is it the right device to write to ?  Multi on?  "\
	"Dummy on ?\nOPTS: $G_OPTS $OPTS\n\n then press Enter, ^C to abort"
read rubbish

echo "\n----- Begin -----"  | tee -a  $IMG2CD_LOG
date | tee -a  $IMG2CD_LOG
echo | tee -a  $IMG2CD_LOG

#     CD schreiben:
cdrecord $OPTS $G_OPTS $IMAGE_DIR$CD_IMAGE 2>&1 | tee -a $IMG2CD_LOG

echo | tee -a  $IMG2CD_LOG
date | tee -a  $IMG2CD_LOG
echo "----- End -----"  | tee -a  $IMG2CD_LOG
echo | tee -a  $IMG2CD_LOG



#	Testen, ob alle files korrekt vom image auf CD übertragen wurden:
#mount -t iso9660 -o loop,ro /mnt/dosg/lin16/lin16.raw /mnt/iso
#mount /mnt/cd
#diff -qrd /mnt/cd /mnt/iso &> ~/diff.log
#tail -f ~/diff.log

echo -e "\a"