2022-01-06 12:31:30 -07:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
2022-01-09 16:26:12 -07:00
|
|
|
. $(dirname $0)/common.sh
|
|
|
|
|
2022-01-06 12:31:30 -07:00
|
|
|
log "Scanning for DVD title"
|
|
|
|
title=$(dvdbackup -I | awk -F \" '/DVD with title/ {print $2}')
|
2022-01-09 16:26:12 -07:00
|
|
|
setenv title "$title"
|
2022-01-06 12:31:30 -07:00
|
|
|
|
2022-01-09 16:26:12 -07:00
|
|
|
# How big is this DVD?
|
|
|
|
totalSize=$(dvdbackup -I | awk '/[MK]iB$/ { b += $2 } END { print b }')
|
2022-01-06 12:31:30 -07:00
|
|
|
|
2022-01-09 16:26:12 -07:00
|
|
|
dvdbackup -p -F -n DVD \
|
|
|
|
| tr '\r' '\n' \
|
2022-01-09 16:54:08 -07:00
|
|
|
| awk -v total=$totalSize -F '[ /:()]+' '
|
|
|
|
function update(bytes) {
|
|
|
|
pct = 100 * bytes / total
|
|
|
|
if (pct >= nextpct) {
|
|
|
|
print pct
|
|
|
|
fflush()
|
|
|
|
nextpct = pct + 0.5
|
|
|
|
}
|
2022-01-09 16:26:12 -07:00
|
|
|
}
|
2022-01-06 12:31:30 -07:00
|
|
|
|
2022-01-09 16:54:08 -07:00
|
|
|
/[MK]iB.$/ {
|
|
|
|
read = $(NF-3) * 1024
|
|
|
|
if ($(NF-1) == "MiB") {
|
|
|
|
read *= 1024
|
2022-01-09 16:26:12 -07:00
|
|
|
}
|
2022-01-09 16:54:08 -07:00
|
|
|
if (read < last) {
|
|
|
|
totalRead += last
|
|
|
|
}
|
|
|
|
update(totalRead + read)
|
|
|
|
last = read
|
2022-01-09 16:26:12 -07:00
|
|
|
}
|
|
|
|
' \
|
2022-01-09 16:54:08 -07:00
|
|
|
| while read val; do
|
|
|
|
setenv complete "$val"
|
2022-01-09 16:26:12 -07:00
|
|
|
done
|
2022-01-06 12:31:30 -07:00
|
|
|
|