]> git.wh0rd.org - dump.git/commitdiff
Added a new dump on cd/dvd script.
authorStelian Pop <stelian@popies.net>
Fri, 7 Jan 2005 09:51:06 +0000 (09:51 +0000)
committerStelian Pop <stelian@popies.net>
Fri, 7 Jan 2005 09:51:06 +0000 (09:51 +0000)
examples/dump_on_cd_3/README [new file with mode: 0644]
examples/dump_on_cd_3/dump_disk [new file with mode: 0755]

diff --git a/examples/dump_on_cd_3/README b/examples/dump_on_cd_3/README
new file mode 100644 (file)
index 0000000..c4da2fc
--- /dev/null
@@ -0,0 +1,12 @@
+I took the dump_on_cd_2/EN/* scripts and merged the pair of scripts into one
+script, which checks it's arguments to tell whether or not it is called from
+dump and acts accordingly.
+
+The script commandline takes dump arguments except -f (output file/device), -F
+(script to run after each volume is finished) and -B (volume size) which are
+overridden in the script.
+
+Andrew Basterfield
+
+bob@cemetery.homeunix.org
+
diff --git a/examples/dump_on_cd_3/dump_disk b/examples/dump_on_cd_3/dump_disk
new file mode 100755 (executable)
index 0000000..b221b7a
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+# This script dumps the specified Filesystem via dump on a CD/DVD
+# DISK_CAPACITY defines the capacity in MB per disk.
+# The script's own name $0 is passed via the -F option of dump
+# When using cdrecord/dvdrecord and at least for my DVD-Recorder (a PHILIPS
+# DVR-A03) it is necessary to define the tracksize for the next track before
+# the DVD is written. This is done via the -tsize option of cdrecord. Since
+# tsize takes its arguments in Bytes, the shell cannot compute the value
+# correctly anymore (value too high), so I use bc.
+
+# If you use growisofs which does not have the 10 second delay before burning
+# of cdrecord you may want to uncomment SLEEP="10" to ensure there is data
+# waiting on the fifo before burning starts
+
+FIFO="/tmp/dump.$$.fifo"
+#DISK_CAPACITY=10      # testing
+DISK_CAPACITY=4300
+BSIZE="$(echo "$DISK_CAPACITY*1024" | bc -l )"
+TSIZE="$(echo "$DISK_CAPACITY*1024*1024" | bc -l )"
+#RECORD_BIN="dd of=/dev/null bs=1k if="        # testing
+#RECORD_BIN="/usr/bin/dvdrecord dev=0,0,0 fs=64M speed=2 -eject -dao -pad -tsize=$TSIZE -data "
+RECORD_BIN="/usr/bin/growisofs -Z /dev/dvd="
+SLEEP="10"
+DUMP="/sbin/dump"
+
+cleanup() {
+       rm -f $FIFO
+}
+
+error_exit() {
+       retcode=$?
+       echo >&2 "Error $retcode: exiting"
+       exit $retcode
+}
+
+trap error_exit ERR
+
+write_output() {
+       # supplied info from "dump -F":
+       # $1 = filename
+       # $2 = sequence number
+       echo "Please insert disk No. $(($2+1))"
+       ANSWER=""
+       while [ "$ANSWER" != "y" ] ; do
+               echo -n "Is the disk ready? (y/n) "
+               read  </dev/tty ANSWER
+               if [ "$ANSWER" == "y" ] ; then
+                       ([ -n "$SLEEP" ] && sleep $SLEEP; ${RECORD_BIN}${1}) &
+                       return 0
+               elif [ "$ANSWER" == "n" ] ; then
+                       EXIT=""
+                       echo -n "Do you really want to exit? (y/n) "
+                       read </dev/tty EXIT
+                       if [ "$EXIT" == "y" ] ; then
+                               return 1
+                       fi
+               fi
+       done
+}
+
+if [ "$#" = "0" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+       echo >&2 "Usage: $0 <dump options>"
+       echo >&2 "See 'man dump' for dump options"
+       echo >&2 "the dump options -F -f -B are not required and are overridden"
+       exit 1
+fi
+
+set -m # We need proper job control
+
+if [ "$#" = "2" ] && [ -p "$1" ]; then
+       write_output "$@" || (kill $$ >/dev/null 2>&1; exit 1)
+       exit 0
+else
+       mkfifo $FIFO
+       trap cleanup EXIT
+       if write_output "$FIFO" "0"; then
+               if $DUMP "$@" -F "$0" -f "$FIFO" -B$BSIZE; then
+                       kill % >/dev/null 2>&1  # Kill the background writing process
+               else
+                       wait %                  # Or wait for it to complete
+               fi
+               exit 0
+       else
+               exit 1
+       fi
+fi