/[clonezilla-sysresccd]/trunk/create-clonezilla-sysresccd/continue-multi-cd
ViewVC logotype

Diff of /trunk/create-clonezilla-sysresccd/continue-multi-cd

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 64 by sng, Fri May 28 09:47:17 2010 UTC revision 68 by sng, Sun May 30 20:11:06 2010 UTC
# Line 1  Line 0 
 #!/bin/bash  
 version=3.1.0  
 ##############################################################################  
 #                                                                            #  
 # continue-multi-cd, (C) 2007-2010 S. Georgaras <sng@hellug.gr>              #  
 #                                                                            #  
 # This file is part of Clonezilla-SysRescCD.                                 #  
 #                                                                            #  
 # Clonezilla-SysRescCD is free software: you can redistribute it and/or      #  
 # modify it under the terms of the GNU General Public License as published   #  
 # by the Free Software Foundation, either version 2 of the License, or       #  
 # (at your option) any later version.                                        #  
 #                                                                            #  
 # Clonezilla-SysRescCD is distributed in the hope that it will be useful,    #  
 # but WITHOUT ANY WARRANTY; without even the implied warranty of             #  
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #  
 # GNU General Public License for more details.                               #  
 #                                                                            #  
 # You should have received a copy of the GNU General Public License along    #  
 # with Clonezilla-SysRescCD. If not, see <http://www.gnu.org/licenses/>.     #  
 #                                                                            #  
 ##############################################################################  
   
 function printVersion(){  
 echo "$(basename "$0") - v $myVers - S. Georgaras <sng@hellug.gr>"  
 }  
   
 function usage(){  
 printVersion  
 echo  
 echo "Usage: $(basename "$0") [options] <path to be added to CD>"  
 echo  
 echo "Available options are:  
     d                Specify write device (in case auto detection does not work)  
     c                Close the CD. No more burning will be possible  
                      Default is to leave it open  
     l                Don't burn the CD after image creation  
     o <image name>   Save the image file as <image name>  
     r                Remove the image file after burning  
     f                On the fly burning of the CD. No image file will be created  
     v                Print version info and exit  
     h                Print this screen and exit  
 "  
   
 }  
   
 function findCDRECORD(){  
 [ -z $(which cdrecord 2>/dev/null) ] && {  
     echo "Error: cdrecord not found!!!"  
     exit 1  
   }  
 }  
   
 function findMKISOFS(){  
 [ -z $(which mkisofs 2>/dev/null) ] && {  
     echo "Error: mkisofs not found!!!"  
     exit 1  
   }  
 }  
   
 function longHelp(){  
 echo longHelp  
 }  
   
   
 # while [ ! -z "$1" ];do  
 #  case "$1" in  
 #  --long-help) longHelp  
 #    shift  
 #        exit;;  
 #  esac  
 # done  
   
 BURN_CD=1  
 REMOVE_IMAGE=0  
 SAVE_MULTI='-multi'  
   
 while getopts fcrd:lo:hv name  
 do  
     case "$name" in  
     f)    output_mode=cdwriter;;  
     d)    dev="$OPTARG";;  
     r)    REMOVE_IMAGE=1;;  
     c)    SAVE_MULTI='';;  
     l)    BURN_CD=0;;  
     o)    img="$OPTARG"  
           ;;  
     h)    usage  
           exit;;  
     v)    printVersion  
           exit;;  
     *)    exit;;  
     esac  
 done  
 shift $(($OPTIND - 1))  
   
   
   
 [ -z "$1" ] && {  
 usage  
 echo "Error: <path to be added to CD> not specified!!!"  
 exit 1  
 }  
 [ ! -d "$1" ]&& {  
 usage  
 echo "Error: <path to be added to CD> is not a directory!!!"  
 exit 1  
 }  
   
 pathToAdd="$1"  
   
 [ -d "$img" ] && {  
 usage  
 echo "Error: <image name> is a directory!!!"  
 exit 1  
 }  
 [ -e "$img" ] && {  
 usage  
 echo "Error: <image name> already exists!!!"  
 exit 1  
 }  
   
 [ ! -w $(dirname "$img") ] && {  
 usage  
 echo "Error: No write permission for <image name>!!!"  
 exit 1  
 }  
   
 [ -z $(echo "$img" | grep "$pathToAdd") ] || {  
 usage  
 echo "Error: <image name> cannot be under <path to be added to CD>!!!"  
 exit 1  
 }  
   
 findMKISOFS  
 if [ $BURN_CD -eq 1 ];then findCDRECORD;fi  
   
   
 if [ -z "$dev" ];then  
  theCD=$(what-cd -wb 2>/dev/null)  
  # theCD=/dev/hda  
 else  
  theCD="$dev"  
 fi  
   
   
 [ -z "$theCD" ] && {  
  echo "    Error: Cannot determine your CD writer!!!"  
  exit 1  
 }  
   
   
 [ -z "$(mount |grep "$theCD")" ] || {  
  umount "$theCD" || {  
   echo  
   echo  
   echo "    Error: Your CD writer cannot be unmounted!!!"  
   exit 1  
  }  
 }  
   
 cont=$(cdrecord -msinfo dev="$theCD" 2>/dev/null)  
 [ -z "$cont" ] && {  
  echo "    Error: The media in $theCD is not a CD/RW!!!"  
  exit 1  
 }  
   
 [ -z "$img" ] && img="/tmp/multi-session-cd-$$.iso"  
   
 mkisofs -r -J -l -f -M "$theCD" -C "$cont" "$pathToAdd" | \  
 {  
  case "$output_mode" in  
  "cdwriter")  
   cdrecord -v "$SAVE_MULTI" driveropts=burnfree -data -eject dev="$theCD" -  
   exit  
   ;;  
  *)  
    # use /dev/stdout as the bridge  
    cat - > "$img" && {  
 #     set -x  
    if [ "$BURN_CD" -eq 1 ];then  
     cdrecord -v "$SAVE_MULTI" driveropts=burnfree -data -eject dev="$theCD" "$img" && {  
      if [ "$REMOVE_IMAGE" -eq 0 ];then  
       echo  
       echo  
       echo "    The image file has been saved as: $img"  
      else  
       rm -r "$img"  
      fi  
     }  
    else  
     echo  
     echo  
     echo "    The image file has been saved as: $img"  
    fi    
   } || {  
    printVersion  
    echo  
    echo "    Error: Image file creation failed!!!"  
    exit 1  
   }  
    ;;  
  esac  
 }  
   
   
   
   
   
   
   
   
   
   
   
   
   
   
 # echo "Data to continue: $cont"  
 # echo "img=$img"  

Legend:
Removed from v.64  
changed lines
  Added in v.68

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26