add a few more 'formItem include' lines to the rdiff and dup handlers
[matthijs/upstream/backupninja.git] / handlers / makecd.in
1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2 # vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
3 #
4 # burncd handler script for backupninja
5 #
6 getconf backupdir /var/backups/makecd
7 getconf exclude
8 getconf target
9 getconf burnertype cd
10 getconf system no
11 getconf isoonly yes
12 getconf imagefile backup.iso
13 getconf device
14 getconf nicelevel 0
15
16 # define needed executables:
17 MKISOFS="/usr/bin/genisoimage"
18 GROWISOFS="/usr/bin/growisofs"
19 CDRECORD="/usr/bin/wodim"
20 CDRDAO="/usr/bin/cdrdao"
21 DVDINFO="/usr/bin/dvd+rw-mediainfo"
22
23 # create backup dirs and check existence of progs.
24
25 [ -d $backupdir ] || mkdir -p $backupdir
26 [ -d $backupdir ] || fatal "Backup directory '$backupdir'"
27 [ -e "$target" ]  || fatal "target does not exist "
28
29 [ -x "$MKISOFS" ]   || debug 3 "echo executable $MKISOFS not present"
30 [ -x "$GROWISOFS" ] || debug 3 "echo executable $GROWISOFS not present"
31 [ -x "$CDRECORD" ]  || debug 3 "echo executable $CDRECORD not present"
32 [ -x "$CDRDAO" ]    || debug 3 "echo executable $CDRDAO not present"
33
34 if [ "$isoonly" == "no" ]; then
35    [ -e $device ] || fatal "No Burner device available"
36 fi
37
38 outputfile="$backupdir/$imagefile"
39 execstr="nice -n $nicelevel $MKISOFS --quiet -R -o $outputfile "
40
41 str=""
42 # excludes
43 for i in $exclude; do
44    str=" -x ${i}$str"
45 done
46
47 debug 0 "echo $str "
48 execstr="${execstr} $str $target "
49 debug 0 "echo $execstr "
50
51 output=` $execstr 2>&1 `
52 code=$?
53 if [ "$code" == "0" ]; then
54    debug $output
55    info "Successfully finished creation of iso"
56 else
57    warning $output
58    warning "Failed to create iso"
59 fi
60
61 if [ "$isoonly" == "no" ]; then
62
63    if [ "$burnertype" == "cd" ]; then
64       # burning iso to CD
65       $CDRECORD -v gracetime=2 dev=$device speed=8 -dao -data $outputfile
66       code=$?
67       if [ "$code" == "0" ]; then
68          debug $output
69          info "Successfully burned CD"
70       else
71          warning $output
72          warning "Failed to create CD"
73       fi
74    fi
75    if [ "$burnertype" == "dvd" ]; then
76       # burning iso dvd
77       $GROWISOFS -speed=2 -Z $device=$outputfile -use-the-force-luke=notray -use-the-force-luke=tty
78       code=$?
79       if [ "$code" == "0" ]; then
80          debug $output
81          info "Successfully burned DVD"
82       else
83          warning $output
84          warning "Failed to create DVD"
85       fi
86    fi
87 fi
88 return 0
89