backupninja/handlers/makecd.in

104 lines
2.7 KiB
Plaintext
Raw Normal View History

# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
2005-07-08 18:24:57 +02:00
#
# burncd handler script for backupninja
#
getconf backupdir /var/backups/makecd
getconf exclude
getconf target
getconf burnertype cd
getconf system no
getconf isoonly yes
getconf imagefile backup.iso
getconf device
2006-10-02 02:21:24 +02:00
getconf nicelevel 0
getconf ionicelevel
## Check config
# Check that the ionicelevel is valid
if [ -n "$ionicelevel" ] && echo "$ionicelevel" | grep -vq "^[0-7]$"; then
fatal "The value of ionicelevel is expected to be either empty or an integer from 0 to 7. Got: $ionicelevel"
fi
# Only use ionice if ionicelevel is not empty
nice="nice -n $nicelevel"
if [ -n "$ionicelevel" ]; then
nice="ionice -c2 -n $ionicelevel $nice"
fi
2005-07-08 18:24:57 +02:00
# define needed executables:
MKISOFS="/usr/bin/genisoimage"
2005-07-08 18:24:57 +02:00
GROWISOFS="/usr/bin/growisofs"
CDRECORD="/usr/bin/wodim"
2005-07-08 18:24:57 +02:00
CDRDAO="/usr/bin/cdrdao"
DVDINFO="/usr/bin/dvd+rw-mediainfo"
# create backup dirs and check existence of progs.
[ -d $backupdir ] || mkdir -p $backupdir
[ -d $backupdir ] || fatal "Backup directory '$backupdir'"
[ -e "$target" ] || fatal "target does not exist "
[ -x "$MKISOFS" ] || debug 3 "echo executable $MKISOFS not present"
[ -x "$GROWISOFS" ] || debug 3 "echo executable $GROWISOFS not present"
[ -x "$CDRECORD" ] || debug 3 "echo executable $CDRECORD not present"
[ -x "$CDRDAO" ] || debug 3 "echo executable $CDRDAO not present"
2005-07-08 18:24:57 +02:00
if [ "$isoonly" == "no" ]; then
[ -e $device ] || fatal "No Burner device available"
2005-07-08 18:24:57 +02:00
fi
outputfile="$backupdir/$imagefile"
execstr="$nice $MKISOFS --quiet -R -o $outputfile "
2005-07-08 18:24:57 +02:00
str=""
# excludes
for i in $exclude; do
str=" -x ${i}$str"
2005-07-08 18:24:57 +02:00
done
debug 0 "echo $str "
execstr="${execstr} $str $target "
debug 0 "echo $execstr "
output=` $execstr 2>&1 `
code=$?
if [ "$code" == "0" ]; then
debug "$output"
info "Successfully finished creation of iso"
2005-07-08 18:24:57 +02:00
else
warning "$output"
warning "Failed to create iso"
2005-07-08 18:24:57 +02:00
fi
if [ "$isoonly" == "no" ]; then
if [ "$burnertype" == "cd" ]; then
# burning iso to CD
$CDRECORD -v gracetime=2 dev=$device speed=8 -dao -data $outputfile
code=$?
if [ "$code" == "0" ]; then
debug "$output"
info "Successfully burned CD"
else
warning "$output"
warning "Failed to create CD"
fi
fi
if [ "$burnertype" == "dvd" ]; then
# burning iso dvd
$GROWISOFS -speed=2 -Z $device=$outputfile -use-the-force-luke=notray -use-the-force-luke=tty
code=$?
if [ "$code" == "0" ]; then
debug "$output"
info "Successfully burned DVD"
else
warning "$output"
warning "Failed to create DVD"
fi
fi
2005-07-08 18:24:57 +02:00
fi
return 0