3dc10539414c10ee76af78635e3286b447a7e137
4 dev
=${DVDRIP_DEVICE-/dev/dvd}
5 tmp
=${DVDRIP_TMPDIR-${HOME?}/tmp
/dvdrip
}
6 archive
=${DVDRIP_ARCHIVE-jem.distorted.org.uk:/mnt/dvd/archive}
7 : ${DVD_SECTOR_COPY=dvd-sector-copy}
8 : ${DVDRIP_UPLOAD=dvdrip-upload}
9 backup
=nil eject
=nil force
=nil retry
=nil verbose
=nil bogus
=nil
12 usage: $prog [-efrv] [-D DEV] [-a ARCH] [-t TMP] TITLE
15 while getopts "hD:a:efrt:v" opt
; do
28 shift $
(( $OPTIND - 1 ))
29 case $# in 1) title
=$1 ;; *) bogus
=t
;; esac
30 case $bogus in t
) usage
>&2; exit 2 ;; esac
31 case $verbose in t
) set -x
;; esac
33 *:*) archhost
=${archive%%:*} archpath
=${archive#*:} ;;
34 *) unset archhost
; archpath
=$archive ;;
39 echo "$(tput bold; tput setaf $colour)$message$(tput sgr0; tput op)"
41 fail
() { notify
1 "!!! $*"; exit 2; }
42 warn
() { notify
5 "??? $*"; }
43 info
() { notify
6 "--- $*"; }
46 set +e
; nice
"$@"; rc
=$?
; set -e
48 run
() { run_setrc
"$@"; case $rc in 0) ;; *) fail
"$1: exit $rc" ;; esac; }
56 qq
="${qq:+$qq }'${a//\'/"'\\''"}'" #" # emacs is confused
58 "$op" ssh "$archhost" "$qq"
65 archrun
() { archdo run
"$@"; }
69 archdo run_setrc
test -f
"$archpath/$title.iso"
71 0,nil
) fail
"output file already exists" ;;
72 0,t
) warn
"output file already exists; will overwrite" ;;
75 accumulate_badblocks
() {
76 if [ -f
"$tmp/$tag/badblocks.new" ]; then
77 if [ ! -f
"$tmp/$tag/badblocks" ]; then
78 { echo "## bad-blocks region map"; echo; } >"$tmp/$tag/badblocks"
80 sed -n
"/^[^#]/p" "$tmp/$tag/badblocks.new" >>"$tmp/$tag/badblocks"
81 rm "$tmp/$tag/badblocks.new"
88 for i
in "$tmp/$tag/dest.new" "$tmp/$tag/dest" "$tmp/$tag/dest.seen"; do
89 if [ -f
"$tmp/$tag/dest.new" ]; then any
=t
; fi
92 nil
) printf "%s\n" "$title.iso" >"$tmp/$tag/dest.new" ;;
98 if [ -f
"$tmp/$tag/badblocks.retry" ]; then
100 elif [ -f
"$tmp/$tag/badblocks" ]; then
101 run
mv "$tmp/$tag/badblocks" "$tmp/$tag/badblocks.retry"
103 fail
"no blocks to retry"
105 set -- "$@" -R
"$tmp/$tag/badblocks.retry"
106 if [ -f
"$tmp/$tag/iso" ]; then
107 mv "$tmp/$tag/iso" "$tmp/$tag/iso.new"
111 if [ ! -f
"$tmp/$tag/iso" ]; then
112 run
"$DVD_SECTOR_COPY" -cs
-b
"$tmp/$tag/badblocks.new" "$@" \
113 "$dev" "$tmp/$tag/iso.new"
114 run
mv "$tmp/$tag/iso.new" "$tmp/$tag/iso"
116 case $retry in t
) rm -f
"$tmp/$tag/badblocks.retry" ;; esac
117 if [ -f
"$tmp/$tag/badblocks" ]; then
118 fail
"bad sectors found: check \`$tmp/$tag/iso', run again if ok"
122 run
mv "$tmp/$tag/dest.new" "$tmp/$tag/dest"
124 case $eject in t
) run eject
"$dev" ;; esac