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