diff options
author | Sean Whitton <spw+git@sdf.org> | 2014-05-05 08:12:56 +0000 |
---|---|---|
committer | Sean Whitton <spw+git@sdf.org> | 2014-05-05 08:12:56 +0000 |
commit | 192d9be63efef2f68adcd29f57023c8710c07bd6 (patch) | |
tree | 5b7265334044e8d9e522d7bcc99d853eb1a0cd3a /bin/copydvd | |
parent | c8d583f71ef4f1d87c97a14ba399816a76ec90d1 (diff) | |
download | dotfiles-192d9be63efef2f68adcd29f57023c8710c07bd6.tar.gz |
Transfer (cleaned-up) ~/bin to dotfiles repository
Diffstat (limited to 'bin/copydvd')
-rwxr-xr-x | bin/copydvd | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bin/copydvd b/bin/copydvd new file mode 100755 index 00000000..6b939c68 --- /dev/null +++ b/bin/copydvd @@ -0,0 +1,55 @@ +#!/bin/bash + +#Usage: copydvd <read> <write> + +#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 + +DEVICE1="$1" +DEVICE2="$2" + +TMPDIR=`mktemp -d` || exit 1 +ISOPIPE="$TMPDIR/pipe.iso" +READERR="$TMPDIR/mkisoerr" + +mkfifo "$ISOPIPE" + +echo "Burning directory..." + +growisofs -dvd-compat -Z "$DEVICE2"="$ISOPIPE" & +BURNER=$! +MD5=`dd if="$DEVICE1" 2>"$READERR" | tee "$ISOPIPE" | md5sum | egrep -o -i -e "^[0-9a-f]{32}"` + +EXTENTS=`egrep -e "^[0-9]+ extents written " "$READERR" | egrep -o -e "^[0-9]+"` + +wait "$BURNER" + +echo "Wrote $EXTENTS extents with a MD5 hash of $MD5." +echo "Cycling drive tray..." + +eject "$DEVICE2" +eject -t "$DEVICE2" + +# 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="$DEVICE2" 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" + |