3 PATH=$(dirname $0):/bin:/usr/bin
7 # Discover disk images by looking for .img.md5sum files in $imagedir
8 imgmd5=$(ls $imagedir/*.img.md5sum | head -n 1)
12 # If we didn't find an non-empty file then exit gracefully
13 [ -z "$imgmd5" ] && exit 0
14 [ -s "$imgmd5" ] || exit 0
16 # Get the name of the disk image by stripping off the tailing '.md5sum'
19 # A little paranoia. Make sure the disk image file is there.
20 [ -z "$img" ] && exit 1
21 [ -s "$img" ] || exit 1
23 # Burn the image to a disk.
24 cdrecord-wrapper.sh -dao dev=$sdev $isoimage > $logfile 2>&1
26 if [ 0 != "$?" ]; then
27 echo >&2 "cdrecord failed!"
31 # Now verify the disk by running md5sum on the entire contents of the disk
33 dd if=$dev bs=1M count=4440 2>$logfile | md5sum | awk '{print$1}' > $md5sum
35 # Check that the md5sums match
36 if ! cmp $md5sum $isoimage.md5sum; then
37 echo "Failed" | mailx -s "DVD md5sum doesn't match image file!!!" $mailto
41 # Record the date in the stat file to indicate that this burn was a success
48 echo "md5sum of burned disks:"
52 } | mailx -s "DVD burned. File it as ${img%.*}" $mailto > $logfile 2>&1
54 # Two lines in the stat file indicate two successful burns. Clean-up the image.
55 if [ "$(wc -l $img.stat 2>/dev/null)" == "2" ]; then
56 # Burned the image twice. Removing it and associated files!
57 rm -f $img{,.md5sum,.stat}
58 [ -d $img.mnt ] && rmdir $img.mnt