blob: 786845ac6d9f6e8e227e288476c40ffaa5117259 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/bin/bash
#Usage: burndir <dir> <device>
# http://www.linuxquestions.org/questions/linux-software-2/burning-dvd-and-verifying-no-iso-689438/#post3458795
#Make sure we are running as root (otherwise we can't burn later)
if [ `whoami` != "root" ]
then
echo "This script must be run as root."
exit 1
fi
DIRPATH="$1"
DEVICE="$2"
TMPDIR=`mktemp -d` || exit 1
ISOPIPE="$TMPDIR/pipe.iso"
MKISOERR="$TMPDIR/mkisoerr"
mkfifo "$ISOPIPE"
echo "Burning directory..."
growisofs -dvd-compat -Z "$DEVICE"="$ISOPIPE" &
BURNER=$!
MD5=`mkisofs -r -J -l "$DIRPATH" 2>"$MKISOERR" | tee "$ISOPIPE" | md5sum | egrep -o -i -e "^[0-9a-f]{32}"`
EXTENTS=`egrep -e "^[0-9]+ extents written " "$MKISOERR" | egrep -o -e "^[0-9]+"`
wait "$BURNER"
echo "Wrote $EXTENTS extents with a MD5 hash of $MD5."
echo "Cycling drive tray..."
eject "$DEVICE"
eject -t "$DEVICE"
# Arch Linux seems to have problems without a wait
# here; gives dd: opening `/dev/sr1': No medium found otherwise
sleep 15
echo "Verifying..."
DISCMD5=`dd if="$DEVICE" bs=2048 count="$EXTENTS" | md5sum | egrep -o -i -e "^[0-9a-f]{32}"`
echo "Disc has an MD5 hash of $DISCMD5."
if [ "$MD5" == "$DISCMD5" ]
then
echo "Disc appears to have burned successfully!"
else
echo "Disc appears to have burned with errors."
fi
rm -r "$TMPDIR"
|