/[clonezilla-sysresccd]/trunk/create-clonezilla-sysresccd/patch-clonezilla-sysresccd.sh
ViewVC logotype

Diff of /trunk/create-clonezilla-sysresccd/patch-clonezilla-sysresccd.sh

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

revision 62 by sng, Wed May 26 13:14:04 2010 UTC revision 63 by sng, Wed May 26 20:30:21 2010 UTC
# Line 52  Available options are: Line 52  Available options are:
52    
53  function printVersion(){  function printVersion(){
54  echo "$(basename $0) - v $version  echo "$(basename $0) - v $version
55  (C) 2008-2009, Spiros Georgaras <sng@hellug.gr>  (C) 2008-2010, Spiros Georgaras <sng@hellug.gr>
56    
57  A utility to personalize Clonezilla-SysRescCD  A utility to personalize Clonezilla-SysRescCD
58  "  "
# Line 107  echo -n "Cleanning up...   " Line 107  echo -n "Cleanning up...   "
107  echo "done"  echo "done"
108  }  }
109    
110    function doMountPartition(){
111    ##############################################################################
112    #                                                                            #
113    #                             Find mount command                             #
114    #                                                                            #
115    ##############################################################################
116    partitionType="$(fdisk -l | grep "$savePartition" | grep ^/dev| sed 's|*||' | sed 's|.*[0-9]  *||')"
117    mountCommand=mount
118    if [ "$partitionType" = "" ];then
119      echo
120      echo "    Error: Partition $savePartition does not exist"
121      cleanUp
122            exit 1
123    elif [ "$partitionType" = "Extended" ];then
124      echo
125      echo "    Error: $savePartition is an Extended partition"
126      cleanUp
127            exit 1
128    elif [ "$partitionType" = "Linux swap / Solaris" ];then
129      echo
130      echo "    Error: $savePartition is a swap partition"
131      cleanUp
132            exit 1
133    elif [ "$partitionType" = "HPFS/NTFS" ];then
134      mountCommand=ntfs-3g
135    fi
136    
137    
138    
139    
140    ##############################################################################
141    #                                                                            #
142    #                            Create mount point                              #
143    #                                                                            #
144    ##############################################################################
145    if [ -z "$workingFromCD" ];then
146      savePartitionMountPoint=/root/tmp/savePartition.$$
147    else
148      savePartitionMountPoint=/savePartition.$$
149    fi
150    mkdir -p "$savePartitionMountPoint" 2>/dev/null && savePartitionMountPointCreated='y' || {
151        echo
152        echo "    Error: Temp folder \"$savePartitionMountPoint\" cannot be created!!!"
153        cleanUp
154        exit 1
155      }
156    
157    ##############################################################################
158    
159    
160    ##############################################################################
161    #                                                                            #
162    #                              Mount partition                               #
163    #                                                                            #
164    ##############################################################################
165    unset savePartitionMounted
166    # mount partition
167    $mountCommand "$savePartition" "$savePartitionMountPoint" 2>/dev/null && savePartitionMounted='y'
168    # is it mounted?
169    if [ -z "$savePartitionMounted" ];then
170      echo
171      echo "    Error: \"$savePartition\" cannot be mounted!!!"
172      cleanUp
173      exit 1
174    fi
175    # is it writeable?
176      rm -rf "$savePartitionMountPoint"/new-iso 2>/dev/null
177            mkdir "$savePartitionMountPoint"/new-iso 2>/dev/null || {
178        echo
179              echo "    Error: Partition $savePartition is mounted read-only"
180                    exit 1
181            }
182    echo "done"
183    ##############################################################################
184    }
185    
186    
187    
188  ####### Script starts here #######  ####### Script starts here #######
189    
190  # set -x  # set -x
# Line 138  do Line 216  do
216        echo "    Error: The specified file \"$OPTARG\" cannot be created!!!"        echo "    Error: The specified file \"$OPTARG\" cannot be created!!!"
217        exit 1        exit 1
218      }      }
219      outputFile="$OPTARG"      outputFile="$(basename "$OPTARG")"
220      ;;      ;;
221   s) # boot splash screen   s) # boot splash screen
222      test "$(whoami)" = "root" || noRoot      test "$(whoami)" = "root" || noRoot
# Line 162  do Line 240  do
240      ;;      ;;
241   p) # storage partition   p) # storage partition
242      if [ -z $(echo "$OPTARG" | grep '/dev/') ];then      if [ -z $(echo "$OPTARG" | grep '/dev/') ];then
243        echo "    Error: Parameter -c (storage partition) is not a valid partition"        echo "    Error: Parameter -p (storage partition) is not a valid partition"
244        exit 1        exit 1
245      fi      fi
246      if [ -z "$(fdisk -l "$OPTARG" 2>/dev/null)" ];then      if [ -z "$(fdisk -l "$OPTARG" 2>/dev/null)" ];then
# Line 245  test "$(whoami)" = "root" || noRoot Line 323  test "$(whoami)" = "root" || noRoot
323      exit 1      exit 1
324    }    }
325  }  && {  }  && {
326    if [-n "$boot" ];then    if [ -n "$boot" ];then
327      echo "    Error: Parameter -r (restore splash screen) not specified!!!"      echo "    Error: Parameter -r (restore splash screen) not specified!!!"
328      exit 1      exit 1
329    fi    fi
# Line 262  test "$(whoami)" = "root" || noRoot Line 340  test "$(whoami)" = "root" || noRoot
340  }  }
341    
342  [ -z "$savePartition" ] && {  [ -z "$savePartition" ] && {
343    echo "    Error: Parameter -c (storage partition) not specified!!!"    echo "    Error: Parameter -p (storage partition) not specified!!!"
344    exit 1    exit 1
345  }  }
346    
347  [ -z "$burnISO" ] || {  [ -n "$burnISO" ] || {
348    [ -z "$cdWritter" ] && {    [ -z "$cdWritter" ] && {
349      WHAT_CD=$(which what-cd)      WHAT_CD=$(which what-cd)
350      [ -z "$WHAT_CD" ] && {      [ -z "$WHAT_CD" ] && {
351        [ -e /root/.clonezilla-sysresccd/files/what-cd ] && {        [ -e /root/.clonezilla-sysresccd/files/what-cd ] && {
352          WHAT_CD=/root/.clonezilla-sysresccd/files/what-cd          WHAT_CD=/root/.clonezilla-sysresccd/files/what-cd
353          cdWritter=$(sh "$WHAT_CD" -bw)                                  chmod +x "$WHAT_CD"
354          [ -z "$cdWritter" ] && {          cdWritter=$("$WHAT_CD" -bw)
355            [ -w "$cdWritter" ] || {
356            echo "    Error: Cannot determine your writter device name!!!"            echo "    Error: Cannot determine your writter device name!!!"
357            exit 1            exit 1
358          }          }
# Line 290  printVersion Line 369  printVersion
369  echo -n "Mounting files...   "  echo -n "Mounting files...   "
370  isClonezillaSysRescCDRunning  isClonezillaSysRescCDRunning
371    
372  # umount "$inputFile" 2>/dev/null  ##############################################################################
373    #                                                                            #
374    #                Mount inputFile (ISO file or actual CD)                     #
375    #                                                                            #
376    ##############################################################################
377  if [ -z $(mount | grep "$inputFile" | sed "s|\(^[^ ]*\).*|\1|" | uniq) ];then  if [ -z $(mount | grep "$inputFile" | sed "s|\(^[^ ]*\).*|\1|" | uniq) ];then
378    # mount the inputFile    # mount the inputFile
379    if [ -z "$ClonezillaSysRescCDRunning" ];then    if [ -z "$ClonezillaSysRescCDRunning" ];then
# Line 323  else Line 406  else
406    # our inputFile is mounted!!!    # our inputFile is mounted!!!
407    mountPoint=$(mount | grep "$inputFile" | grep 's|.* on \(.*\) type .*)|\1|')    mountPoint=$(mount | grep "$inputFile" | grep 's|.* on \(.*\) type .*)|\1|')
408  fi  fi
409    ##############################################################################
410    
411    
412    
413    
414  # set -x  ##############################################################################
415  if [ -z $(mount | grep "$savePartition" | sed "s|\(^[^ ]*\).*|\1|" | uniq) ];then  #                                                                            #
416    if [ -z "$workingFromCD" ];then  #                Check if savePartition is already mounted                   #
417      savePartitionMountPoint=/root/tmp/savePartition.$$  #                                                                            #
418    else  ##############################################################################
419      savePartitionMountPoint=/savePartition.$$  if [ -n "$(mount | grep "$savePartition")" ];then
420    fi    # it is mounted!!!
421            # can i write to it?
422    mkdir -p "$savePartitionMountPoint" 2>/dev/null && savePartitionMountPointCreated='y' || {    savePartitionMountPoint=$(mount | grep "$savePartition" | sed "s|"$savePartition" on \(.*\) type .*)|\1|")
423      echo "failed"          rm -rf "$savePartitionMountPoint"/new-iso 2>/dev/null
424            mkdir "$savePartitionMountPoint"/new-iso 2>/dev/null || {
425      echo      echo
426      echo "    Error: Temp folder \"$savePartitionMountPoint\" cannot be created!!!"            echo "    Error: Partition $savePartition is already mounted read-only"
427      cleanUp                  exit 1
428      exit 1          }
429    }    echo 'done'
430    else
431    ntfs-3g "$savePartition" "$savePartitionMountPoint" 2>/dev/null && savePartitionMounted='y'    doMountPartition
   if [ -z "$savePartitionMounted" ];then  
     savePartitionMounted=''  
     mount "$savePartition" "$savePartitionMountPoint" 2>/dev/null && savePartitionMounted='y'  
     if [ -z "$savePartitionMounted" ];then  
       echo "failed"  
       echo  
       echo "    Error: \"$savePartition\" cannot be mounted!!!"  
       cleanUp  
       exit 1  
     fi  
   fi  
 else  
   savePartitionMountPoint=$(mount | grep "$savePartition" | uniq | sed 's|.*on \(.*\) type.*|\1|')  
432  fi  fi
433    ##############################################################################
434    # echo "mountPoint=$mountPoint"
435    # echo "workingFromCD=$workingFromCD"
436    # echo "ClonezillaSysRescCDRunning=$ClonezillaSysRescCDRunning"
437    # echo "savePartition=$savePartition"
438    # echo "savePartitionMountPoint=$savePartitionMountPoint"
439    # umount /dev/loop0
440    # exit
441    
   
 mkdir "$savePartitionMountPoint"/new-iso 2>/dev/null && newIsoCreated='y' || {  
   [ -z "$savePartitionMounted" ] || umount "$savePartition" 2>/dev/null  
   savePartitionMounted=''  
   echo "failed"  
   echo  
   echo "    Error: Partition \"$savePartition\ is mounted read-only!!!"  
   cleanUp  
   exit 1  
 }  
 echo "done"  
   
 # set +x  
442  echo -n "Copying files...   "  echo -n "Copying files...   "
443    
444  cp -r "$mountPoint"/* "$savePartitionMountPoint"/new-iso 2>/dev/null && {  cp -r "$mountPoint"/* "$savePartitionMountPoint"/new-iso 2>/dev/null && {
# Line 384  cp -r "$mountPoint"/* "$savePartitionMou Line 451  cp -r "$mountPoint"/* "$savePartitionMou
451  }  }
452    
453    
 # echo  
 # echo -n "Press ENTER to continue...   "  
 # read  
 # cleanUp  
 # exit  
   
   
   
454  echo -n "Installing new files...   "  echo -n "Installing new files...   "
455  if [ ! -z "$mainTitle" ];then  if [ ! -z "$mainTitle" ];then
456    for n in $(find "$savePartitionMountPoint"/new-iso -iname "*.cfg");do    for n in $(find "$savePartitionMountPoint"/new-iso -iname "*.cfg");do
457      sed "s|^MENU TITLE.*|MENU TITLE $mainTitle|" "$n"  > "$n".$$      sed "0,/^MENU TITLE.*/s//MENU TITLE $mainTitle/" "$n"  > "$n".$$
458      mv "$n".$$ "$n"      mv "$n".$$ "$n"
459    done    done
460  fi  fi
461  if [ -e "$mainSplash" ];then  if [ -e "$mainSplash" ];then
462    cp "$mainSplash" "$savePartitionMountPoint"/new-iso/isolinux/ocswp.png    cp "$mainSplash" "$savePartitionMountPoint"/new-iso/isolinux/ocswp.png
463  fi    if [ -e "$restoreSplash" ];then
464  if [ -e "$restoreSplash" ];then      cp "$restoreSplash" "$savePartitionMountPoint"/new-iso/restorecd/default-restore-ocswp.png
465  cp "$restoreSplash" "$savePartitionMountPoint"/new-iso/restorecd/default-restore-ocswp.png      cp "$restoreSplash" "$savePartitionMountPoint"/new-iso/restorecd/ocswp.png
466  cp "$restoreSplash" "$savePartitionMountPoint"/new-iso/restorecd/ocswp.png    fi
467  fi  fi
468    
469  cd "$savePartitionMountPoint"/new-iso  cd "$savePartitionMountPoint"/new-iso
# Line 509  mkisofs -r -J -l -b isolinux/isolinux.bi Line 568  mkisofs -r -J -l -b isolinux/isolinux.bi
568    echo -n "Deleting ISO file...   "    echo -n "Deleting ISO file...   "
569    rm -rf "$outputFile" 2>/dev/null &&  echo "done" || echo "failed"    rm -rf "$outputFile" 2>/dev/null &&  echo "done" || echo "failed"
570  }  }
571  echo  # echo
572  echo -n "Press ENTER to continue...   "  # echo -n "Press ENTER to continue...   "
573  read  # read
574  cleanUp  cleanUp

Legend:
Removed from v.62  
changed lines
  Added in v.63

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26