--- trunk/create-clonezilla-sysresccd/create-clonezilla-sysresccd.sh 2010/08/13 08:30:37 93 +++ trunk/create-clonezilla-sysresccd/create-clonezilla-sysresccd.sh 2010/09/27 17:02:51 140 @@ -109,37 +109,37 @@ function createTempFolders(){ -echo -n "Creating /root/tmp folder... " -mkdir /root/tmp 2>/dev/null -if [ ! -d /root/tmp ];then +echo -n "Creating "$SAVE_DIR"/tmp folder... " +mkdir "$SAVE_DIR"/tmp 2>/dev/null +if [ ! -d "$SAVE_DIR"/tmp ];then echo - echo " Error creating folder: /root/tmp" + echo " Error creating folder: "$SAVE_DIR"/tmp" echo " This shouldn't be happening..." exit 1 fi echo 'done' echo -n "Creating temp folders... " -rm -rf /root/tmp/clonezilla-sysresccd-"$version".iso 2>/dev/null -rm -rf /root/tmp/syscd 2>/dev/null -rm -rf /root/tmp/clonecd 2>/dev/null -rm -rf /root/tmp/clonezilla-sysresccd 2>/dev/null -mkdir /root/tmp/syscd /root/tmp/clonecd /root/tmp/clonezilla-sysresccd 2>/dev/null -if [ ! -d /root/tmp/syscd ];then +rm -rf "$SAVE_DIR"/tmp/clonezilla-sysresccd-"$version".iso 2>/dev/null +rm -rf "$SAVE_DIR"/tmp/syscd 2>/dev/null +rm -rf "$SAVE_DIR"/tmp/clonecd 2>/dev/null +rm -rf "$SAVE_DIR"/tmp/clonezilla-sysresccd 2>/dev/null +mkdir "$SAVE_DIR"/tmp/syscd "$SAVE_DIR"/tmp/clonecd "$SAVE_DIR"/tmp/clonezilla-sysresccd 2>/dev/null +if [ ! -d "$SAVE_DIR"/tmp/syscd ];then echo - echo " Error creating temp folder: /root/tmp/syscd" + echo " Error creating temp folder: "$SAVE_DIR"/tmp/syscd" exit 1 fi -if [ ! -d /root/tmp/clonecd ];then +if [ ! -d "$SAVE_DIR"/tmp/clonecd ];then echo - echo " Error creating temp folder: /root/tmp/clonecd" + echo " Error creating temp folder: "$SAVE_DIR"/tmp/clonecd" exit 1 fi -if [ ! -d /root/tmp/clonezilla-sysresccd ];then +if [ ! -d "$SAVE_DIR"/tmp/clonezilla-sysresccd ];then echo - echo " Error creating temp folder: /root/tmp/clonezilla-sysresccd" + echo " Error creating temp folder: "$SAVE_DIR"/tmp/clonezilla-sysresccd" exit 1 fi echo 'done' @@ -152,8 +152,8 @@ } function errorISO(){ -echo " Error creating new ISO file: /root/tmp/output.iso" -rm /root/tmp/clonezilla-sysresccd-"$outName""$version".iso 2>/dev/null +echo " Error creating new ISO file: "$SAVE_DIR"/tmp/output.iso" +rm "$SAVE_DIR"/tmp/clonezilla-sysresccd-"$outName""$version".iso 2>/dev/null cleanUp exit 1 } @@ -161,12 +161,12 @@ function cleanUp(){ echo -n " Cleaning up... " -umount /root/tmp/clonecd 2>/dev/null -umount /root/tmp/syscd 2>/dev/null +umount "$SAVE_DIR"/tmp/clonecd 2>/dev/null +umount "$SAVE_DIR"/tmp/syscd 2>/dev/null if [ -z "$cleanUpValue" ];then - rm -rf /root/tmp/clonezilla-sysresccd 2>/dev/null + rm -rf "$SAVE_DIR"/tmp/clonezilla-sysresccd 2>/dev/null fi -rm -rf /root/tmp/clonecd /root/tmp/syscd 2>/dev/null +rm -rf "$SAVE_DIR"/tmp/clonecd "$SAVE_DIR"/tmp/syscd 2>/dev/null echo 'done' echo exit $exitStatus @@ -218,10 +218,12 @@ f copy files only. Don't create ISO file and don't burn anything on CD nf don't copy files. Use files existing in folder - \"/root/tmp/clonezilla-sysresccd\". + \""$SAVE_DIR"/tmp/clonezilla-sysresccd\". *** Caution: Dangerous!!! *** i only create ISO file. Don't burn anything on CD b burn a previously created ISO file + d [folder] Use [folder]/tmp as temporary and output folder + instead of $HOME/tmp x [script] A user defined and written BASH script to be executed just before mastering the CD v print version and exit @@ -313,6 +315,8 @@ } ####### Script starts here ####### +SAVE_DIR="$HOME" + MKISOFS=genisoimage onlyBurnISO=0 onlyCopyFiles=0 @@ -324,7 +328,7 @@ profilesError=0 -while getopts ":asp:bfihvn:x:" Option +while getopts ":asp:bfihvn:x:d:" Option do case $Option in a) @@ -405,6 +409,17 @@ fi noFileCopy=1 ;; + d) + SAVE_DIR="$OPTARG" + if [ ! -d "$SAVE_DIR" ]; then + mkdir "$SAVEDIR" 2>/dev/null + if [ -d "$SAVE_DIR" ];then + echo "Error: \"$SAVE_DIR\" cannot be created!!!" + exit 1 + fi + fi + ;; + esac done shift $(($OPTIND - 1)) @@ -433,9 +448,9 @@ exit 1 fi if [ "$outName" = "" ];then - outFile=/root/tmp/clonezilla-sysresccd-"$version".iso + outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$version".iso else - outFile=/root/tmp/clonezilla-sysresccd-"$outName"-"$version".iso + outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$outName"-"$version".iso fi if [ $onlyBurnISO -eq 0 ];then @@ -507,18 +522,18 @@ createTempFolders echo -n "Mounting ISO files... " - mount "$sysCD" /root/tmp/syscd -o loop || errorMount ' Error mounting "System Rescue CD" file' - mount "$cloneCD" /root/tmp/clonecd -o loop || errorMount ' Error mounting Clonezilla" file' + mount "$sysCD" "$SAVE_DIR"/tmp/syscd -o loop || errorMount ' Error mounting "System Rescue CD" file' + mount "$cloneCD" "$SAVE_DIR"/tmp/clonecd -o loop || errorMount ' Error mounting Clonezilla" file' echo 'done' echo -n "Copying files... " - cp -RL /root/tmp/syscd/* /root/tmp/clonezilla-sysresccd - cp -RL /root/tmp/clonecd/* /root/tmp/clonezilla-sysresccd + cp -RL "$SAVE_DIR"/tmp/syscd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd + cp -RL "$SAVE_DIR"/tmp/clonecd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd echo 'done' # echo -n "Extracting boot programs... " echo "Extracting boot programs... " - cd /root/tmp/clonezilla-sysresccd/bootprog + cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog mkdir tmp cp *zip tmp unzip -x sys*zip win32/syslinux.exe @@ -533,21 +548,21 @@ if [ ! -z "$splash" ];then echo -n "Copying new spalsh screen... " - cp -L "$splash" /root/tmp/clonezilla-sysresccd/isolinux/ocswp.png + cp -L "$splash" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png echo 'done' else - cp -L /root/.clonezilla-sysresccd/files/default-ocswp.png /root/tmp/clonezilla-sysresccd/isolinux/ocswp.png + cp -L /root/.clonezilla-sysresccd/files/default-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png fi echo -n "Copying Super Grub Disk... " - cp -L /root/.clonezilla-sysresccd/files/sgd.img /root/tmp/clonezilla-sysresccd/bootdisk/sgd.img && echo 'done' || { + cp -L /root/.clonezilla-sysresccd/files/sgd.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img && echo 'done' || { echo echo echo echo " Error: Copying Super Grub Disk failed!!!" echo echo " Please make sure that the image file exists" - echo " Image file: /root/tmp/clonezilla-sysresccd/bootdisk/sgd.img" + echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img" echo echo cleanUp @@ -555,14 +570,14 @@ } if [ -e /root/.clonezilla-sysresccd/files/sgd2.img ];then echo -n "Copying Super Grub Disk 2... " - cp -L /root/.clonezilla-sysresccd/files/sgd2.img /root/tmp/clonezilla-sysresccd/bootdisk/grubdisk.img && echo 'done' || { + cp -L /root/.clonezilla-sysresccd/files/sgd2.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/grubdisk.img && echo 'done' || { echo echo echo echo " Error: Copying Super Grub Disk 2 failed!!!" echo echo " Please make sure that the image file exists" - echo " Image file: /root/tmp/clonezilla-sysresccd/bootdisk/sgd2.img" + echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd2.img" echo echo cleanUp @@ -571,34 +586,34 @@ fi echo -n "Copying new cfg file(s)... " if [ -z $(echo "$cfgFile" | grep 'cfg$') ];then - tar -C /root/tmp/clonezilla-sysresccd -xzhf /root/.clonezilla-sysresccd/files/menu-for-iso.tar.gz + tar -C "$SAVE_DIR"/tmp/clonezilla-sysresccd -xzhf /root/.clonezilla-sysresccd/files/menu-for-iso.tar.gz else - cp -L "$cfgFile" /root/tmp/clonezilla-sysresccd/isolinux/isolinux.cfg + cp -L "$cfgFile" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/isolinux.cfg fi echo 'done' echo -n "Creating folder restorecd... " WHERE="$(pwd)" - mkdir /root/tmp/clonezilla-sysresccd/restorecd 2>/dev/null + mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd 2>/dev/null cd /root/.clonezilla-sysresccd/files cp -L pre* ocs-iso what-cd patch-clonezilla-sysresccd continue-multi-cd isolinux-restore-cd.cfg \ - isolinux-restore-cd-ram.cfg menu-for-iso.tar.gz doc.tar.gz imginfo imgconvert cust-menu /root/tmp/clonezilla-sysresccd/restorecd - cp -L default-restore-ocswp.png /root/tmp/clonezilla-sysresccd/restorecd/ocswp.png - cp sbminst /root/tmp/clonezilla-sysresccd/restorecd + isolinux-restore-cd-ram.cfg menu-for-iso.tar.gz doc.tar.gz imginfo imgconvert cust-menu "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd + cp -L default-restore-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ocswp.png + cp sbminst "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd # Copy Smart Boot Manager and rawrite-fdimage to bootdisk - mkdir /root/tmp/clonezilla-sysresccd/rawrite - cp raw* fd* *dll /root/tmp/clonezilla-sysresccd/rawrite - cp sbm.img /root/tmp/clonezilla-sysresccd/bootdisk + mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite + cp raw* fd* *dll "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite + cp sbm.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk cd "$DebianLiveFolder" 2>/dev/null || debFilesError=yes # if [ -s files.tar.gz ];then -# cp -L files.tar.gz /root/tmp/clonezilla-sysresccd/restorecd/ 2>/dev/null || debFilesError=yes +# cp -L files.tar.gz "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ 2>/dev/null || debFilesError=yes # else # [ -e "$DebianLiveFolder"/unifont.bgf ] || { # uniFontCopied=yes # cp -L /root/.clonezilla-sysresccd/files/unifont.bgf "$DebianLiveFolder" # } -# tar chzf /root/tmp/clonezilla-sysresccd/restorecd/files.tar.gz unifont.bgf debian-live-for-ocs.iso 2>/dev/null || debFilesError=yes +# tar chzf "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/files.tar.gz unifont.bgf debian-live-for-ocs.iso 2>/dev/null || debFilesError=yes # [ -z "$uniFontCopied" ] || rm "$DebianLiveFolder"/unifont.bgf # fi # [ -z "$debFilesError" ] || { @@ -621,8 +636,8 @@ echo "done" echo -n "Copying documentation files... " - cd /root/tmp/clonezilla-sysresccd - tar xzhf /root/tmp/clonezilla-sysresccd/restorecd/doc.tar.gz + cd "$SAVE_DIR"/tmp/clonezilla-sysresccd + tar xzhf "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/doc.tar.gz echo 'done' if [ ! -z "$exScript" ];then @@ -647,22 +662,22 @@ else trap cleanUp 2 cleanUpValue=1 - if [ ! -d /root/tmp/clonezilla-sysresccd ];then - echo " Error accessing folder \"/root/tmp/clonezilla-sysresccd\"" + if [ ! -d "$SAVE_DIR"/tmp/clonezilla-sysresccd ];then + echo " Error accessing folder \""$SAVE_DIR"/tmp/clonezilla-sysresccd\"" exitStatus=1 cleanUp fi fi # move extra folders into utils - mv /root/tmp/clonezilla-sysresccd/rawrite /root/tmp/clonezilla-sysresccd/bootprog /root/tmp/clonezilla-sysresccd/utils - mv /root/tmp/clonezilla-sysresccd/version /root/tmp/clonezilla-sysresccd/SystemRescueCD-Version + mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog "$SAVE_DIR"/tmp/clonezilla-sysresccd/utils + mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/version "$SAVE_DIR"/tmp/clonezilla-sysresccd/SystemRescueCD-Version # # re-build clonezilla filesystem.squashfs # echo -n "Rebuilding Clonezilla squashfs... " -cd /root/tmp/clonezilla-sysresccd/live +cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/live unsquashfs filesystem.squashfs 2>/dev/null 1>&2 cp -r ../README* ../doc ../restorecd squashfs-root mksquashfs squashfs-root aa.squashfs -always-use-fragments -no-duplicates -all-root 2>/dev/null 1>&2 @@ -675,7 +690,7 @@ cleanUpValue=1 # echo # echo - echo "Both CDs have been copyied in: /root/tmp/clonezilla-sysresccd" + echo "Both CDs have been copyied in: "$SAVE_DIR"/tmp/clonezilla-sysresccd" cleanUp fi echo @@ -685,7 +700,7 @@ ************************************************************************ Ready to master your CD. If you want to alter any files contained in the CD, now is the right time. - CD root is \"/root/tmp/clonezilla-sysresccd\" + CD root is \""$SAVE_DIR"/tmp/clonezilla-sysresccd\" When you are done *********************************************************************** @@ -695,9 +710,9 @@ else echo "Creating new ISO file." fi - find /root/tmp/clonezilla-sysresccd -name "*~" -exec rm '{}' ';' -# $MKISOFS -quiet -f -r -J -o "$outFile" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 3 -joliet-long -input-charset utf-8 -output-charset utf-8 -V "$volLabel" -publisher "$publisher" -p "$preparerID" /root/tmp/clonezilla-sysresccd || errorISO - $MKISOFS -quiet -f -r -J -o "$outFile" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V "$volLabel" -publisher "$publisher" -p "$preparerID" /root/tmp/clonezilla-sysresccd || errorISO + find "$SAVE_DIR"/tmp/clonezilla-sysresccd -name "*~" -exec rm '{}' ';' +# $MKISOFS -quiet -f -r -J -o "$outFile" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 3 -joliet-long -input-charset utf-8 -output-charset utf-8 -V "$volLabel" -publisher "$publisher" -p "$preparerID" "$SAVE_DIR"/tmp/clonezilla-sysresccd || errorISO + $MKISOFS -quiet -f -r -J -o "$outFile" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V "$volLabel" -publisher "$publisher" -p "$preparerID" "$SAVE_DIR"/tmp/clonezilla-sysresccd || errorISO echo " Done creating new ISO file The file is saved as $outFile"