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)
14 echo MD5 file: $imgmd5
18 echo Logfile: $logfile
20 # If we didn't find an non-empty file then exit gracefully
21 [ -z "$imgmd5" ] && exit 0
22 [ -s "$imgmd5" ] || exit 0
24 # Get the name of the disk image by stripping off the tailing '.md5sum'
29 # A little paranoia. Make sure the disk image file is there.
30 [ -z "$img" ] && exit 1
31 [ -s "$img" ] || exit 1
33 # Burn the image to a disk.
34 cdrecord-wrapper.sh -dao dev=$sdev $img > $logfile 2>&1
36 if [ "0" != "$?" ]; then
37 echo >&2 "cdrecord failed!"
41 # Now verify the disk by running md5sum on the entire contents of the disk
44 dd if=$dev bs=1M count=4440 2>$logfile | md5sum | awk '{print$1}' > $md5sum
46 # Check that the md5sums match
47 if ! cmp $md5sum $img.md5sum; then
48 echo "Failed" | mailx -s "DVD md5sum doesn't match image file!!!" $mailto
52 # Record the date in the stat file to indicate that this burn was a success
59 echo "md5sum of burned disks:"
65 } | mailx -s "DVD burned. File as ${img%.*}" $mailto > $logfile 2>&1
67 # Two lines in the stat file indicate two successful burns. Clean-up the image.
68 if [ "$(wc -l $img.stat 2>/dev/null | awk '{print$1}')" == "2" ]; then
69 # Burned the image twice. Removing it and associated files!
70 rm -f $img{,.md5sum,.stat}
71 [ -d $img.mnt ] && rmdir $img.mnt