#!/bin/bash # # Bacula interface to growisofs, used to write to DVD+/-R(W) # # $Id$ # # If you set in your Device resource # # Write Part Command = "path-to-this-script/dvd-writepart %n %a %v" # you will have the following input to this script: # # dvd-writepart "erase" "device" "part_filename" # $1 $2 $3 # # for example: # # dvd-writepart 0 /dev/hda File-0001 MKISOFS=@MKISOFS@ GROWISOFS=@GROWISOFS@ # GROWARGS="-use-the-force-luke=tty -quiet" GROWARGS="-quiet" # Uncomment the following line if you do not want the tray to be reloaded # when writing ends. GROWARGS="${GROWARGS} -use-the-force-luke=notray" #### You should probably not modify anything below this line # If Linux kernel version >=2.6.8, allow a session to start beyond the # 4gb boundary. kver=`uname -r | cut -d. -f1,2` ksubver=`uname -r | cut -d. -f3 | cut -d- -f1` if test "a$kver" = "a2.6" ; then if test "$ksubver" > 7 ; then echo "Kernel version >= 2.6.8, allowing to cross the 4gb boundary." GROWARGS="${GROWARGS} -use-the-force-luke=4gms" fi fi if test $# -ne 3 ; then echo "usage: dvd-writepart part_number device part_filename" echo " Wrong number of arguments arguments given (!= 3)." exit 1 fi # Setup arguments erase=$1 dev=$2 filename=$3 if test $erase = 1 ; then arg="-Z" else arg="-M" fi # Starts growisofs echo Running ${GROWISOFS} ${GROWARGS} $arg $dev -R $filename... ${GROWISOFS} ${GROWARGS} $arg $dev -R $filename & #bash -c "while [ 1 ]; do echo "G"; sleep 1; done" & growpid=$! parentpid=$$ # Starts watchdog : checks if the parent is alive. If not, kill # growisofs. bash -c "rtn=0; while [ \$rtn = 0 ]; do sleep 5; ps -p $parentpid; rtn=\$?; echo W\$rtn; done; echo \"Parent dead killing $growpid\"; kill $growpid; sleep 5; kill -9 $growpid" & watchpid=$! # Waits for growisofs to stop wait $growpid rtn=$? # Kill the watchdog kill -9 $watchpid exit $rtn