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