Skip to content
Snippets Groups Projects
makecd.in 2.25 KiB
Newer Older
  • Learn to ignore specific revisions
  • # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
    
    # vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
    
    micah's avatar
    micah committed
    #
    # 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
    
    micah's avatar
    micah committed
    getconf nicelevel 0
    
    micah's avatar
    micah committed
    
    # define needed executables:
    
    MKISOFS="/usr/bin/genisoimage"
    
    micah's avatar
    micah committed
    GROWISOFS="/usr/bin/growisofs"
    
    CDRECORD="/usr/bin/wodim"
    
    micah's avatar
    micah committed
    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"
    
    micah's avatar
    micah committed
    
    if [ "$isoonly" == "no" ]; then
    
       [ -e $device ] || fatal "No Burner device available"
    
    micah's avatar
    micah committed
    fi
    
    outputfile="$backupdir/$imagefile"
    
    micah's avatar
    micah committed
    execstr="nice -n $nicelevel $MKISOFS --quiet -R -o $outputfile "
    
    micah's avatar
    micah committed
    
    str=""
    # excludes
    for i in $exclude; do
    
       str=" -x ${i}$str"
    
    micah's avatar
    micah committed
    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"
    
    micah's avatar
    micah committed
    else
    
       warning $output
       warning "Failed to create iso"
    
    micah's avatar
    micah committed
    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
    
    micah's avatar
    micah committed
    fi
    return 0