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 the noburn file is there then don't burn.
13 [ -f "$burnlockfile" ] && exit 0
15 # If we didn't find an non-empty file then exit gracefully
16 [ -z "$imgmd5" ] && exit 0
17 [ -s "$imgmd5" ] || exit 0
19 # Get the name of the disk image by stripping off the tailing '.md5sum'
22 # A little paranoia. Make sure the disk image file is there.
23 [ -z "$img" ] && exit 1
24 [ -s "$img" ] || exit 1
26 # Burn the image to a disk.
27 cdrecord-wrapper.sh -dao dev=$sdev $isoimage > $logfile 2>&1
29 if [ 0 != "$?" ]; then
30 echo >&2 "cdrecord failed!"
34 # Now verify the disk by running md5sum on the entire contents of the disk
36 dd if=$dev bs=1M count=4440 2>$logfile | md5sum | awk '{print$1}' > $md5sum
38 # Check that the md5sums match
39 if ! cmp $md5sum $isoimage.md5sum; then
40 echo "Failed" | mailx -s "DVD md5sum doesn't match image file!!!" $mailto
44 # Record the date in the stat file to indicate that this burn was a success
53 echo "md5sum of burned disks:"
57 } | mailx -s "DVD burned. File it as ${img%.*}" $mailto > $logfile 2>&1
59 # Two lines in the stat file indicate two successful burns. Clean-up the image.
60 if [ "$(wc -l $img.stat 2>/dev/null)" == "2" ]; then
61 # Burned the image twice. Removing it and associated files!
62 rm -f $img{,.md5sum,.stat}
63 [ -d $img.mnt ] && rmdir $img.mnt