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

Annotation of /trunk/create-clonezilla-sysresccd/create-clonezilla-sysresccd.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 190 - (hide annotations)
Sun Aug 26 14:25:43 2012 UTC (9 years, 3 months ago) by sng
File MIME type: application/x-sh
File size: 32329 byte(s)
updating cfg files (removed rannish and dban from tools),
changing menu selection color, renamed pack-them to 
update-cfgs (script to create a tarball containing CFGs

1 sng 47 ##############################################################################
2     # #
3 sng 164 # create-clonezilla-sysresccd, (C) 2007-2011 S. Georgaras <sng@hellug.gr> #
4 sng 47 # #
5     # This file is part of Clonezilla-SysRescCD. #
6     # #
7     # Clonezilla-SysRescCD is free software: you can redistribute it and/or #
8     # modify it under the terms of the GNU General Public License as published #
9     # by the Free Software Foundation, either version 2 of the License, or #
10     # (at your option) any later version. #
11     # #
12     # Clonezilla-SysRescCD is distributed in the hope that it will be useful, #
13     # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15     # GNU General Public License for more details. #
16     # #
17     # You should have received a copy of the GNU General Public License along #
18     # with Clonezilla-SysRescCD. If not, see <http://www.gnu.org/licenses/>. #
19     # #
20     ##############################################################################
21 sng 162 function evalPrograms(){
22     local ans
23    
24     echo -n "Looking for curl... "
25     if [ -z "$(curl -V 2>/dev/null)" ];then
26     echo failed
27     unset curlFound
28     echo
29     echo "curl was not found on your system, so the ISO files cannot be download"
30     echo "Please install curl and try again"
31     exit 1
32     else
33     echo found
34     curlFound=1
35     fi
36    
37     echo -n "Looking for md5sum... "
38     if [ -z "$(md5sum --version 2>/dev/null)" ];then
39     echo failed
40     unset md5sumFound
41     echo
42     echo " Info: md5sum was not found on your system"
43     echo " The ISO files will not be validated."
44     echo
45     echo -n " Do you want to continue? (y/[n]) "
46     read ans
47     if [ "$ans" != "y" ];then
48     exit
49     fi
50     else
51     echo found
52     md5sumFound=1
53     fi
54     }
55    
56     function downloadIsoFiles(){
57     local clonIso
58     local sysIso="http://sourceforge.net/projects/systemrescuecd/files/sysresccd-x86/"$sysVersion"/systemrescuecd-x86-"$sysVersion".iso/download"
59    
60     # Start with Clonezilla Live
61     if [ "$1" = "all" ] || [ -z "$1" ];then
62     # Download all files
63     for clonType in i686 i486 amd64;do
64 sng 187 if [ "$clonType" = "i686" ];then
65     clonType="$clonType"-pae
66     fi
67 sng 190 clonIso="http://downloads.sourceforge.net/project/clonezilla/clonezilla_live_stable/OldFiles/"$clonVersion"/clonezilla-live-"$clonVersion"-"$clonType".iso?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fclonezilla%2Ffiles%2Fclonezilla_live_stable%2FOldFiles%2F"$clonVersion"%2F"
68 sng 162 downloadClonezillaLive
69     done
70     else
71     clonType="$1"
72 sng 187 if [ "$clonType" = "i686" ];then
73     clonType="$clonType"-pae
74     fi
75 sng 190 clonIso="http://downloads.sourceforge.net/project/clonezilla/clonezilla_live_stable/OldFiles/"$clonVersion"/clonezilla-live-"$clonVersion"-"$clonType".iso?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fclonezilla%2Ffiles%2Fclonezilla_live_stable%2FOldFiles%2F"$clonVersion"%2F"
76 sng 162 downloadClonezillaLive
77     fi
78    
79     # Download System Rescue CD
80     echo "
81     ****** Downloading System Rescue CD "$sysVersion" ******"
82     unset curlContinue
83     if [ -e systemrescuecd-x86-"$sysVersion".iso ];then
84     if [ -n "$md5sumFound" ];then
85     echo "$sysmd5 systemrescuecd-x86-"$sysVersion".iso" > test.md5sum
86 sng 187 echo -n "File found.
87     Checking integrity of "
88 sng 162 md5sum -c test.md5sum 2>/dev/null
89     if [ "$?" -eq 0 ];then
90     rm -f test.md5sum 2>/dev/null
91     return
92     else
93     echo "File systemrescuecd-x86-"$sysVersion".iso already exists"
94 sng 187 echo " You can continue downloading the file or restart it"
95     echo -n " Continue downloading? (y/[n]): "
96 sng 162 read ans
97 sng 187 curlContinue=""
98 sng 174 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
99 sng 162 curlContinue=1
100     else
101     rm -f test.md5sum 2>/dev/null
102     fi
103     fi
104     else
105     echo "File systemrescuecd-x86-"$sysVersion".iso already exists"
106 sng 187 echo " You can continue downloading the file or restart it"
107     echo " If you do continue downloading, and since md5sum was not found,"
108     echo " make sure you check the file's integrity manually, after the"
109     echo " download is complete"
110     echo -n " Continue downloading? (y/[n]): "
111     curlContinue=""
112 sng 162 read ans
113 sng 174 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
114 sng 162 curlContinue=1
115     fi
116     fi
117     fi
118     if [ -z "$curlContinue" ];then
119     curl -L "$sysIso" -o systemrescuecd-x86-"$sysVersion".iso
120     else
121     curl -L -C - "$sysIso" -o systemrescuecd-x86-"$sysVersion".iso
122     fi
123     # Check integrity
124 jyrki 169 if [ -n "$md5sumFound" ];then
125     echo "$sysmd5 systemrescuecd-x86-"$sysVersion".iso" > test.md5sum
126     echo -n "Checking integrity of "
127     md5sum -c test.md5sum 2>/dev/null
128     if [ "$?" -eq 1 ];then
129     echo "Integrity check on systemrescuecd-x86-"$sysVersion".iso failed!!!"
130     echo -n "Do you want to delete this file? ([y]/n): "
131     read ans
132 sng 174 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
133 jyrki 169 rm -f systemrescuecd-x86-"$sysVersion".iso 2>/dev/null && echo "File deleted..." || echo "****** Error deleting file!!! ******
134     Please delete systemrescuecd-x86-"$sysVersion".iso manually"
135     fi
136 sng 162 fi
137     rm -f test.md5sum 2>/dev/null
138     fi
139     }
140    
141     function downloadClonezillaLive(){
142     echo "
143     ****** Downloading Clonezilla Live "$clonVersion" "$clonType" ******"
144     unset curlContinue
145     if [ -e clonezilla-live-"$clonVersion"-"$clonType".iso ];then
146     if [ -n "$md5sumFound" ];then
147     if [ "$clonType" = "amd64" ];then
148     echo "$amd64md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
149     elif [ "$clonType" = "i486" ];then
150     echo "$i486md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
151     else
152     echo "$i686md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
153     fi
154     unset checkmd5
155 sng 187 echo -n "File found.
156     Checking integrity of "
157 sng 162 md5sum -c test.md5sum 2>/dev/null && checkmd5=1
158    
159     if [ -z "$checkmd5" ];then
160     # md5 check failed
161     unset checkmd5
162     echo "File clonezilla-live-"$clonVersion"-"$clonType".iso already exists"
163 sng 187 echo " You can continue downloading the file or restart it"
164     echo -n " Continue downloading? (y/[n]): "
165 sng 162 read ans
166 sng 174 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
167 sng 162 curlContinue=1
168     else
169     rm -f test.md5sum 2>/dev/null
170     return
171     fi
172     else
173     # file is ok
174     return
175     fi
176     else
177     # no md5sum
178     echo "File clonezilla-live-"$clonVersion"-"$clonType".iso already exists"
179 sng 187 echo " You can continue downloading the file or restart it"
180     echo " If you do continue downloading, and since md5sum was not found,"
181     echo " make sure you check the file's integrity manually, after the"
182     echo " download is complete"
183     echo -n " Continue downloading? (y/[n]): "
184 sng 162 read ans
185 sng 174 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
186 sng 162 curlContinue=1
187     fi
188     fi
189     fi
190    
191     # Check if we have to go to OldFiles
192     echo "Checking file availability..."
193 sng 190 oldFiles="$(curl -IL "$clonIso" | grep 'Location: http://')"
194     if [ -z "$oldFiles" ];then
195 sng 162 # go to stable
196 sng 190 clonIso="$(echo "$clonIso" | sed 's{OldFiles/{{' | sed 's{OldFiles%2F{{')"
197     echo ">>>>>> This is Clonezilla Live Stable!!!"
198 sng 162 else
199 sng 190 echo ">>>>>> This is an older Clonezilla Live version!!!"
200 sng 162 fi
201    
202     # Download file
203     if [ -z "$curlContinue" ];then
204     curl -L "$clonIso" -o clonezilla-live-"$clonVersion"-"$clonType".iso
205     else
206     curl -L -C - "$clonIso" -o clonezilla-live-"$clonVersion"-"$clonType".iso
207     fi
208    
209     if [ -n "$md5sumFound" ];then
210     if [ "$clonType" = "amd64" ];then
211     echo "$amd64md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
212     elif [ "$clonType" = "i486" ];then
213     echo "$i486md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
214     else
215     echo "$i686md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
216     fi
217     unset checkmd5
218     echo -n "Checking integrity of "
219     md5sum -c test.md5sum 2>/dev/null && checkmd5=1
220     rm -f test.md5sum 2>/dev/null
221     if [ -z "$checkmd5" ];then
222     echo "Integrity check on clonezilla-live-"$clonVersion"-"$clonType".iso failed!!!"
223     echo -n "Do you want to delete this file? ([y]/n): "
224     read ans
225 sng 174 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
226 sng 162 rm -f clonezilla-live-"$clonVersion"-"$clonType".iso 2>/dev/null && echo "File deleted..." || echo "****** Error deleting file!!! ******
227     Please delete clonezilla-live-"$clonVersion"-"$clonType".iso manually"
228     fi
229     fi
230     fi
231    
232    
233     }
234    
235 sng 47 function noRoot(){
236     echo " Error: You must be root to execute this script"
237     exit 1
238     }
239    
240     function getScript(){
241 sng 61 if [ -n "$auto" ];then return;fi
242 sng 47 echo 'Insert script to be executed'
243     echo -n '> '
244     read exScript
245     }
246    
247     function getSysCD(){
248     echo 'Insert "System Rescue CD" ISO file name'
249     until [ ! -z "$sysCD" ];do
250     echo -n '> '
251     read sysCD
252     done
253    
254     if [ ! -s "$sysCD" ];then
255     echo -n " Error: File not found. Press ENTER to continue... "
256     sysCD=''
257     read
258     getSysCD
259     fi
260     }
261    
262     function getCloneCD(){
263     echo 'Insert "Clonezilla Live" ISO file name'
264     until [ ! -z "$cloneCD" ];do
265     echo -n '> '
266     read cloneCD
267     done
268    
269     if [ ! -s "$cloneCD" ];then
270     echo -n " Error: File not found. Press ENTER to continue... "
271     cloneCD=''
272     read
273     getCloneCD
274     fi
275     }
276    
277     function getcfgFile(){
278     echo 'Insert "isolinux.cfg" file to use'
279     until [ ! -z "$cfgFile" ];do
280     echo -n '> '
281     read cfgFile
282     done
283     if [ ! -s "$cfgFile" ];then
284     echo -n " Error: File not found. Press ENTER to continue... "
285     cfgFile=''
286     read
287     getcfgFile
288     fi
289     }
290    
291     function getPreparer(){
292     echo 'Insert Preparer ID'
293     until [ ! -z "$preparerID" ];do
294     echo -n '> '
295     read preparerID
296     done
297     }
298    
299     function getPublisher(){
300     echo 'Insert Publisher ID'
301     until [ ! -z "$publisher" ];do
302     echo -n '> '
303     read publisher
304     done
305     }
306    
307     function getvolLabel(){
308     echo 'Insert CD Volume label'
309     until [ ! -z "$volLabel" ];do
310     echo -n '> '
311     read volLabel
312     done
313     }
314    
315     function getDebianLiveFolder(){
316     echo 'Insert Debian Live folder'
317     until [ ! -z "$DebianLiveFolder" ];do
318     echo -n '> '
319     read DebianLiveFolder
320     done
321     }
322    
323    
324    
325     function createTempFolders(){
326 sng 140 echo -n "Creating "$SAVE_DIR"/tmp folder... "
327     mkdir "$SAVE_DIR"/tmp 2>/dev/null
328     if [ ! -d "$SAVE_DIR"/tmp ];then
329 sng 47 echo
330 sng 140 echo " Error creating folder: "$SAVE_DIR"/tmp"
331 sng 47 echo " This shouldn't be happening..."
332     exit 1
333     fi
334     echo 'done'
335    
336     echo -n "Creating temp folders... "
337 sng 140 rm -rf "$SAVE_DIR"/tmp/clonezilla-sysresccd-"$version".iso 2>/dev/null
338     rm -rf "$SAVE_DIR"/tmp/syscd 2>/dev/null
339     rm -rf "$SAVE_DIR"/tmp/clonecd 2>/dev/null
340     rm -rf "$SAVE_DIR"/tmp/clonezilla-sysresccd 2>/dev/null
341     mkdir "$SAVE_DIR"/tmp/syscd "$SAVE_DIR"/tmp/clonecd "$SAVE_DIR"/tmp/clonezilla-sysresccd 2>/dev/null
342     if [ ! -d "$SAVE_DIR"/tmp/syscd ];then
343 sng 47 echo
344 sng 140 echo " Error creating temp folder: "$SAVE_DIR"/tmp/syscd"
345 sng 47 exit 1
346     fi
347 sng 140 if [ ! -d "$SAVE_DIR"/tmp/clonecd ];then
348 sng 47 echo
349 sng 140 echo " Error creating temp folder: "$SAVE_DIR"/tmp/clonecd"
350 sng 47 exit 1
351     fi
352    
353    
354 sng 140 if [ ! -d "$SAVE_DIR"/tmp/clonezilla-sysresccd ];then
355 sng 47 echo
356 sng 140 echo " Error creating temp folder: "$SAVE_DIR"/tmp/clonezilla-sysresccd"
357 sng 47 exit 1
358     fi
359     echo 'done'
360     }
361    
362     function errorMount(){
363     echo "$1"
364     cleanUp
365     exit 1
366     }
367    
368     function errorISO(){
369 sng 140 echo " Error creating new ISO file: "$SAVE_DIR"/tmp/output.iso"
370     rm "$SAVE_DIR"/tmp/clonezilla-sysresccd-"$outName""$version".iso 2>/dev/null
371 sng 47 cleanUp
372     exit 1
373     }
374    
375     function cleanUp(){
376     echo -n "
377     Cleaning up... "
378 sng 140 umount "$SAVE_DIR"/tmp/clonecd 2>/dev/null
379     umount "$SAVE_DIR"/tmp/syscd 2>/dev/null
380 sng 47 if [ -z "$cleanUpValue" ];then
381 sng 140 rm -rf "$SAVE_DIR"/tmp/clonezilla-sysresccd 2>/dev/null
382 sng 47 fi
383 sng 140 rm -rf "$SAVE_DIR"/tmp/clonecd "$SAVE_DIR"/tmp/syscd 2>/dev/null
384 sng 47 echo 'done'
385     echo
386     exit $exitStatus
387     }
388    
389     function isnumber(){
390     if [ "$1" = "0" ];then return 0;fi
391     local n="$1"
392     (( n ++ )) 2>/dev/null || return 1
393     return 0
394     }
395    
396     function readProfiles(){
397     local n=0
398     local tmpName=${profile[0]}
399     until [ -z "$tmpName" ];do
400     (( n ++ ))
401     tmpName=${profile[$n]}
402     done
403     numOfProfiles=$(( n - 1 ))
404     }
405    
406     function applyProfile(){
407     test -z "${sysCDP[$1]}" || sysCD="${sysCDP[$1]}"
408     test -z "${cloneCDP[$1]}" || cloneCD="${cloneCDP[$1]}"
409     test -z "${cfgFileP[$1]}" || cfgFile="${cfgFileP[$1]}"
410     test -z "${splashP[$1]}" || splash="${splashP[$1]}"
411     test -z "${outNameP[$1]}" || outName="${outNameP[$1]}"
412     test -z "${preparerIDP[$1]}" || preparerID="${preparerIDP[$1]}"
413     test -z "${publisherP[$1]}" || publisher="${publisherP[$1]}"
414     test -z "${volLabelP[$1]}" || volLabel="${volLabelP[$1]}"
415     test -z "${exScriptP[$1]}" || exScript="${exScriptP[$1]}"
416     # test -z "${DebianLiveFolderP[$1]}" || DebianLiveFolder="${DebianLiveFolderP[$1]}"
417     }
418    
419     function printHelp(){
420     echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr>
421     A utility to create a multi boot CD containing
422     Clonezilla Live CD and
423     System Rescue CD
424     (they have to be downloaded seperately)
425    
426     Usage: $(basename $0) [options]
427     Available options are:
428 sng 61 a run in auto mode (no confirmation, assume yes to
429     all questions asked, no ISO burning to disk)
430 sng 47 s show profiles and let user select profile to use
431     p [number] use profile number
432     f copy files only. Don't create ISO file and don't
433     burn anything on CD
434     nf don't copy files. Use files existing in folder
435 sng 140 \""$SAVE_DIR"/tmp/clonezilla-sysresccd\".
436 sng 47 *** Caution: Dangerous!!! ***
437     i only create ISO file. Don't burn anything on CD
438     b burn a previously created ISO file
439 sng 140 d [folder] Use [folder]/tmp as temporary and output folder
440     instead of $HOME/tmp
441 sng 47 x [script] A user defined and written BASH script
442     to be executed just before mastering the CD
443 sng 162 g [arch] Download ISO files and exit. $(basename $0)
444     will download the appropriate ISO files in
445     order to succesfully build Clonezilla-SysRescCD.
446     [arch] refers to Clonezilla Live architecture
447     (i686,i486 or amd64 - use all to get them all)
448 sng 47 v print version and exit
449     h print this screen and exit
450    
451     More information on available customization in file
452     /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf"
453     }
454    
455     function printVersion(){
456     echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr>
457     A utility to create a multi boot CD containing
458     Clonezilla Live CD and
459     System Rescue CD
460     (they have to be downloaded seperately)"
461     exit
462     }
463    
464     # function decectDVDWriter(){
465     # local z
466     # # local DEV0 DEV1
467     # local CDW0 CDW1
468     # local DVDW0 DVDW1
469     #
470     # z=`cat /proc/sys/dev/cdrom/info 2>/dev/null | grep name | sed 's/.*name://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' `
471     # DEV0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'`
472     # DEV1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'`
473     #
474     # z=`cat /proc/sys/dev/cdrom/info 2>/dev/null| grep 'write' | grep 'DVD-R:'| sed 's/.*DVD-R://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' `
475     # # echo z=$z
476     # DVDW0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'`
477     # DVDW1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'`
478     #
479     #
480     # z=`cat /proc/sys/dev/cdrom/info 2>/dev/null| grep 'write' | grep 'CD-R:'| sed 's/.*CD-R://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' `
481     # # echo z=$z
482     # CDW0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'`
483     # CDW1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'`
484     #
485     # if ! test -z "$DEV0";then
486     # if [ "$DVDW0" = "1" ];then DVDRECORDER=/dev/"$DEV0";fi
487     # if [ "$CDW0" = "1" ];then CDRECORDER=/dev/"$DEV0";fi
488     # fi
489     #
490     # if ! test -z "$DEV1";then
491     # if test -z "$DVDRECORDER"; then
492     # if [ "$DVDW1" = "1" ];then
493     # DVDRECORDER=/dev/"$DEV1"
494     # fi
495     # fi
496     # if test -z "$CDRECORDER"; then
497     # if [ "$CDW1" = "1" ];then
498     # CDRECORDER=/dev/"$DEV1"
499     # fi
500     # fi
501     # fi
502     #
503     # }
504    
505     function sourceProfiles(){
506     if [ -r /root/.clonezilla-sysresccd/profiles.conf ];then
507     . /root/.clonezilla-sysresccd/profiles.conf 2>/dev/null || profilesError=1
508     profilesExist=1
509     fi
510     if [ $profilesError -eq 1 ];then
511     echo " Error: Your profiles configuration file \"/root/.clonezilla-sysresccd/profiles.conf\""
512     echo " has errors and cannot be used. Please fix the problem and try again"
513     exit 1
514     fi
515     }
516    
517    
518     function readConfig(){
519     if [ -n "$configAlreadyRead" ];then return; fi
520     test "$(whoami)" = "root" || noRoot
521     [ -r /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf ] || {
522     echo " Error: Your configuration file \"/root/.clonezilla-sysresccd/clonezilla-sysresccd.conf\""
523     echo " does not exist or can not be read. Please fix the problem and try again"
524     exit 1
525     }
526    
527     . /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf 2>/dev/null
528     if [ $? -ne 0 ];then
529     echo " Error: Your configuration file \"/root/.clonezilla-sysresccd/clonezilla-sysresccd.conf\""
530     echo " has errors and cannot be used. Please fix the problem and try again"
531     exit 1
532     fi
533     configAlreadyRead='true'
534     }
535    
536     ####### Script starts here #######
537 sng 140 SAVE_DIR="$HOME"
538    
539 sng 93 MKISOFS=genisoimage
540 sng 47 onlyBurnISO=0
541     onlyCopyFiles=0
542     onlyCreateISO=0
543     noFileCopy=0
544     exitStatus=0
545    
546     profilesExist=0
547     profilesError=0
548    
549    
550 sng 162 while getopts ":asp:bfihvn:x:d:g:" Option
551 sng 47 do
552     case $Option in
553 sng 61 a)
554     auto=yes
555 sng 162 ;;
556 sng 47 s)
557     readConfig
558     sourceProfiles
559     if [ $profilesExist -eq 1 ];then
560     readProfiles
561     until [ ! -z "$prN" ];do
562     clear
563     echo "Available profiles"
564     for i in `seq 0 $numOfProfiles`;do
565     echo " Profile[$i]: ${profile[$i]}"
566     done
567     echo -n "Insert profile number ([0]-$numOfProfiles): "
568     read prN
569     test -z "$prN" && prN=0
570     isnumber "$prN" || prN=''
571     if [ $prN -gt $numOfProfiles ] 2>/dev/null; then prN='';fi
572     done
573     applyProfile $prN
574     else
575     echo " Error: You have requested to use profiles but your profiles configuration file"
576     echo " \"/root/.clonezilla-sysresccd/profiles.conf\" does not exist or cannot be read"
577     exit 1
578     fi
579     ;;
580     p)
581     readConfig
582     sourceProfiles
583     if [ $profilesExist -eq 1 ];then
584     if $(isnumber "$OPTARG");then
585     applyProfile $OPTARG
586 sng 162 usingProfile=yes
587 sng 176 currentProfile=$OPTARG
588 sng 47 else
589     echo " Error in parameter: -p $OPTARG"
590     exit 1
591     fi
592     else
593     echo " Error: You have requested to use profile No $OPTARG but your profiles configuration file"
594     echo " \"/root/.clonezilla-sysresccd/profiles.conf\" does not exist or cannot be read"
595     exit 1
596     fi
597     ;;
598     b)
599     readConfig
600     onlyBurnISO=1;;
601     f)
602     readConfig
603     onlyCopyFiles=1;;
604     i)
605     readConfig
606     onlyCreateISO=1;;
607     x)
608     readConfig
609     [ -s "OPTARG" ] || {
610     echo " Error: The specified script \"$OPTARG\" cannot be found"
611     exit 1
612     }
613     [ -r "$OPTARG" ] && exScript="$OPTARG" || {
614     echo " Error: The specified script \"$OPTARG\" cannot be read"
615     exit 1
616     };;
617     h)
618     printHelp
619     exit
620     ;;
621     v)
622     printVersion
623     ;;
624     n)
625     readConfig
626     if [ "$OPTARG" != "f" ] ;then
627     echo "Error: Not a valid parameter -n$OPTARG"
628     exit 1
629     fi
630     noFileCopy=1
631     ;;
632 sng 140 d)
633     SAVE_DIR="$OPTARG"
634     if [ ! -d "$SAVE_DIR" ]; then
635     mkdir "$SAVEDIR" 2>/dev/null
636     if [ -d "$SAVE_DIR" ];then
637     echo "Error: \"$SAVE_DIR\" cannot be created!!!"
638     exit 1
639     fi
640     fi
641     ;;
642 sng 162 g)
643     ARCH="$OPTARG"
644     if [ "$ARCH" != "i486" ] && [ "$ARCH" != "i686" ] && [ "$ARCH" != "amd64" ] && [ "$ARCH" != "all" ];then
645     echo " Error in parameter -g. Should be -g [i668|i486|amd64|all]"
646     exit 1
647     fi
648     ;;
649 sng 47 esac
650     done
651     shift $(($OPTIND - 1))
652    
653 sng 162 if [ -z "$ARCH" ];then
654     test "$(whoami)" = "root" || noRoot
655     else
656     evalPrograms
657     downloadIsoFiles $ARCH
658     exit
659     fi
660 sng 190 # check auto mode
661 sng 61 if [ -n "$auto" ];then
662     if [ -z "$usingProfile" ];then
663     echo ' Error: Parameter -a used without -p'
664 sng 162 exit 1
665     fi
666 sng 64 if [ "$onlyBurnISO" -eq 1 ];then
667 sng 63 echo " Error: Conflicting parameters -a and -b used"
668 sng 162 exit 1
669     fi
670 sng 61 fi
671    
672 sng 47 # Check input parameters
673     checkInParms=0
674     checkInParms=$(( onlyBurnISO + onlyCreateISO + onlyCopyFiles + noFileCopy ))
675     if [ $noFileCopy -eq 1 ] && [ $onlyCreateISO -eq 1 ];then
676     okToContinue=1
677     elif [ $checkInParms -gt 1 ];then
678     echo " Error: Conflicting input parameters detected..."
679     exit 1
680     fi
681     if [ "$outName" = "" ];then
682 sng 140 outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$version".iso
683 sng 47 else
684 sng 140 outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$outName"-"$version".iso
685 sng 47 fi
686    
687     if [ $onlyBurnISO -eq 0 ];then
688     if [ $noFileCopy -eq 0 ];then
689     while [ "$ans" != "y" ] || [ "$ans" = "Y" ];do
690     test -z "$sysCD" && getSysCD
691     test -z "$cloneCD" && getCloneCD
692     test -z "$cfgFile" && getcfgFile
693     test -z "$exScript" && getScript
694     # test -z "$DebianLiveFolder" && getDebianLiveFolder
695     clear
696     # echo -n "Current settings:
697     # System Rescue CD: $sysCD
698     # Clonezilla Live CD: $cloneCD
699     # isolinux.cfg to use: $cfgFile
700     # Debian Live folder: $DebianLiveFolder
701     # script to execute: $exScript
702     #
703     # Is this correct? (y/[n]): "
704    
705 sng 190 if [ -n "$auto" ]; then
706     ans=y
707     else
708     echo -n "Current settings:
709     System Rescue CD: $sysCD
710     Clonezilla Live CD: $cloneCD
711     isolinux.cfg to use: $cfgFile
712     script to execute: $exScript
713    
714     Is this correct? (y/[n]): "
715    
716     read ans
717     fi
718 sng 47 if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then
719     sysCD=''
720     cloneCD=''
721     cfgFile=''
722     fi
723     done
724     ans=''
725     while [ 1 ];do
726     test -z "$preparerID" && getPreparer
727     test -z "$publisher" && getPublisher
728     test -z "$volLabel" && getvolLabel
729 sng 61
730     if [ -n "$auto" ]; then
731     ans=y
732     else
733 sng 162 clear
734 sng 47 echo -n "Current CD info:
735     Preparer: $preparerID
736     Publisher: $publisher
737     Volume label: $volLabel
738    
739     Is this correct? (y/[n]): "
740 sng 61 read ans
741     fi
742 sng 47 if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then
743     preparerID=''
744     publisher=''
745     volLabel=''
746     fi
747     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then break;fi
748     done
749     trap cleanUp 2
750     clear
751     echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr>
752     "
753 sng 176
754     if [ -n "$currentProfile" ];then
755     echo "Running profile: $currentProfile ($outName)"
756     fi
757    
758 sng 47 createTempFolders
759    
760     echo -n "Mounting ISO files... "
761 sng 190 mount "$sysCD" "$SAVE_DIR"/tmp/syscd -o ro,loop || errorMount ' Error mounting "System Rescue CD" file'
762     mount "$cloneCD" "$SAVE_DIR"/tmp/clonecd -o ro,loop || errorMount ' Error mounting Clonezilla" file'
763 sng 47 echo 'done'
764     echo -n "Copying files... "
765 sng 140 cp -RL "$SAVE_DIR"/tmp/syscd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd
766     cp -RL "$SAVE_DIR"/tmp/clonecd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd
767 sng 47 echo 'done'
768    
769    
770     # echo -n "Extracting boot programs... "
771     echo "Extracting boot programs... "
772 sng 140 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog
773 sng 47 mkdir tmp
774     cp *zip tmp
775     unzip -x sys*zip win32/syslinux.exe
776     mv win32/* .
777     rmdir win32
778     unzip -x gr* gr*/grub.exe
779     mv gr*/grub.exe .
780     rm -rf grub4dos*
781     cp tmp/* .
782     rm -rf tmp
783     # echo 'done'
784    
785     if [ ! -z "$splash" ];then
786 sng 178 echo -n "Copying new spalsh screen... "
787     cp -L "$splash" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png
788     echo 'done'
789 sng 47 else
790 sng 178 cp -L /root/.clonezilla-sysresccd/files/default-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png
791 sng 47 fi
792    
793     echo -n "Copying Super Grub Disk... "
794 sng 140 cp -L /root/.clonezilla-sysresccd/files/sgd.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img && echo 'done' || {
795 sng 47 echo
796     echo
797     echo
798     echo " Error: Copying Super Grub Disk failed!!!"
799     echo
800     echo " Please make sure that the image file exists"
801 sng 140 echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img"
802 sng 47 echo
803     echo
804     cleanUp
805     exit 1
806     }
807     if [ -e /root/.clonezilla-sysresccd/files/sgd2.img ];then
808     echo -n "Copying Super Grub Disk 2... "
809 sng 140 cp -L /root/.clonezilla-sysresccd/files/sgd2.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/grubdisk.img && echo 'done' || {
810 sng 47 echo
811     echo
812     echo
813     echo " Error: Copying Super Grub Disk 2 failed!!!"
814     echo
815     echo " Please make sure that the image file exists"
816 sng 140 echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd2.img"
817 sng 47 echo
818     echo
819     cleanUp
820     exit 1
821     }
822     fi
823     echo -n "Copying new cfg file(s)... "
824     if [ -z $(echo "$cfgFile" | grep 'cfg$') ];then
825 sng 140 tar -C "$SAVE_DIR"/tmp/clonezilla-sysresccd -xzhf /root/.clonezilla-sysresccd/files/menu-for-iso.tar.gz
826 sng 47 else
827 sng 140 cp -L "$cfgFile" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/isolinux.cfg
828 sng 47 fi
829     echo 'done'
830    
831     echo -n "Creating folder restorecd... "
832     WHERE="$(pwd)"
833 sng 140 mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd 2>/dev/null
834 sng 47 cd /root/.clonezilla-sysresccd/files
835 sng 64 cp -L pre* ocs-iso what-cd patch-clonezilla-sysresccd continue-multi-cd isolinux-restore-cd.cfg \
836 sng 140 isolinux-restore-cd-ram.cfg menu-for-iso.tar.gz doc.tar.gz imginfo imgconvert cust-menu "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd
837 sng 178 fsplash=`basename "$splash"`
838     if [ "$fsplash" = "default-ocswp-i686.png" ] || [ "$fsplash" = "default-ocswp-i486.png" ] || [ "$fsplash" = "default-ocswp-amd64.png" ];then
839     cp $(echo "$splash" | sed 's/default/default-restore/') "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ocswp.png
840     else
841     cp -L default-restore-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ocswp.png
842     fi
843 sng 140 cp sbminst "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd
844 sng 47
845     # Copy Smart Boot Manager and rawrite-fdimage to bootdisk
846 sng 140 mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite
847     cp raw* fd* *dll "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite
848     cp sbm.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk
849 sng 47 cd "$DebianLiveFolder" 2>/dev/null || debFilesError=yes
850     # if [ -s files.tar.gz ];then
851 sng 140 # cp -L files.tar.gz "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ 2>/dev/null || debFilesError=yes
852 sng 47 # else
853     # [ -e "$DebianLiveFolder"/unifont.bgf ] || {
854     # uniFontCopied=yes
855     # cp -L /root/.clonezilla-sysresccd/files/unifont.bgf "$DebianLiveFolder"
856     # }
857 sng 140 # tar chzf "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/files.tar.gz unifont.bgf debian-live-for-ocs.iso 2>/dev/null || debFilesError=yes
858 sng 47 # [ -z "$uniFontCopied" ] || rm "$DebianLiveFolder"/unifont.bgf
859     # fi
860     # [ -z "$debFilesError" ] || {
861     # echo
862     # echo
863     # echo
864     # echo " Error: Copying files.tar.gz failed!!!"
865     # echo
866     # echo " Please make sure that the variable DebianLiveFolder points either to"
867     # echo " the folder where the files unifont.bgf and debian-live-for-ocs.iso"
868     # echo " reside, or the files files.tar.gz (which contains unifont.bgf and"
869     # echo " debian-live-for-ocs.iso) can be found"
870     # echo
871     # echo
872     # echo
873     # cleanUp
874     # exit 1
875     # }
876     cd "$WHERE"
877     echo "done"
878    
879     echo -n "Copying documentation files... "
880 sng 140 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd
881     tar xzhf "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/doc.tar.gz
882 sng 47 echo 'done'
883    
884     if [ ! -z "$exScript" ];then
885     # echo -n "Executing external script: \"$exScript\"... "
886 sng 178 echo -n "Executing external script... "
887     . "$exScript" || {
888     echo
889     echo
890     echo
891     echo " Error: The execution of the script failed!!!"
892     echo " Please correct it and try again"
893     echo
894     echo " Script: \"$exScript\""
895     cleanUp
896     exit 1
897     }
898     echo 'done'
899 sng 47 fi
900     # echo
901     # echo
902     # echo
903 sng 178 else
904     trap cleanUp 2
905     cleanUpValue=1
906     if [ ! -d "$SAVE_DIR"/tmp/clonezilla-sysresccd ];then
907     echo " Error accessing folder \""$SAVE_DIR"/tmp/clonezilla-sysresccd\""
908     exitStatus=1
909     cleanUp
910     fi
911 sng 47 fi
912    
913     # move extra folders into utils
914 sng 140 mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog "$SAVE_DIR"/tmp/clonezilla-sysresccd/utils
915     mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/version "$SAVE_DIR"/tmp/clonezilla-sysresccd/SystemRescueCD-Version
916 sng 47
917 sng 178 # copy png files from isolinux/ to syslinux/
918     cp "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/*.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/syslinux
919 sng 68 #
920     # re-build clonezilla filesystem.squashfs
921     #
922     echo -n "Rebuilding Clonezilla squashfs... "
923 sng 140 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/live
924 sng 68 unsquashfs filesystem.squashfs 2>/dev/null 1>&2
925     cp -r ../README* ../doc ../restorecd squashfs-root
926 sng 164 mksquashfs squashfs-root aa.squashfs -always-use-fragments -no-duplicates -all-root 2>/dev/null 1>&2
927 sng 68 mv aa.squashfs filesystem.squashfs
928     rm -rf squashfs-root
929     cd
930     echo 'done'
931    
932 sng 47 if [ $onlyCopyFiles -eq 1 ];then
933     cleanUpValue=1
934     # echo
935     # echo
936 sng 140 echo "Both CDs have been copyied in: "$SAVE_DIR"/tmp/clonezilla-sysresccd"
937 sng 47 cleanUp
938     fi
939     echo
940 sng 61 if [ -z "$auto" ]; then
941     echo -n "Ready to create new ISO file.
942 sng 47
943     ************************************************************************
944     Ready to master your CD. If you want to alter any files contained
945     in the CD, now is the right time.
946 sng 140 CD root is \""$SAVE_DIR"/tmp/clonezilla-sysresccd\"
947 sng 47
948     When you are done
949     ***********************************************************************
950    
951     Press ENTER to continue... "
952     read
953 sng 61 else
954     echo "Creating new ISO file."
955     fi
956 sng 140 find "$SAVE_DIR"/tmp/clonezilla-sysresccd -name "*~" -exec rm '{}' ';'
957     # $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
958     $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
959 sng 47 echo "
960     Done creating new ISO file
961     The file is saved as $outFile"
962     ans=c
963     chIsoHyb=`type isohybrid 2>/dev/null`
964     if [ -n "$chIsoHyb" ];then
965     echo -n "Isohybriding $outFile... "
966     isohybrid "$outFile"
967     echo 'done'
968     fi
969    
970 sng 61 if [ -z "$auto" ];then
971 sng 47 echo '
972    
973     '
974 sng 61 fi
975 sng 47 else
976     while [ ! -r "$outFile" ];do
977     echo 'Insert "clonezilla-resccd" ISO file name'
978     echo -n "> "
979     read outFile
980     done
981     ans=y
982     fi
983    
984     if [ $onlyCreateISO -eq 1 ];then ans=n;fi
985    
986     while [ 1 ];do
987     if [ "$ans" = "" ];then ans=y;fi
988     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
989 sng 61 if [ -n "$auto" ]; then
990     ans=n
991     else
992     echo -n "Do you want to burn this ISO file? ([y]/n): "
993 sng 174 read ans
994 sng 61 fi
995 sng 47 done
996     burnISO=0
997     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
998     echo
999     echo "File to burn: $outFile"
1000     echo
1001     burnISO=1
1002     # decectDVDWriter
1003    
1004 sng 58 # CDRECORDER=$(sh /root/.clonezilla-sysresccd/files/what-cd -wb)
1005     chmod +x /root/.clonezilla-sysresccd/files/what-cd
1006     CDRECORDER=$(/root/.clonezilla-sysresccd/files/what-cd -wb)
1007     chmod -x /root/.clonezilla-sysresccd/files/what-cd
1008 sng 47
1009     echo CD redorder found: "$CDRECORDER"
1010     ans=''
1011     until [ "$ans" = "y" ] || [ "$ans" = "Y" ];do
1012     echo -n "Is this correct? ([y]/n): "
1013     read ans
1014     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "" ];then
1015     ans='y'
1016     cdW="$CDRECORDER"
1017     else
1018     echo -n "Insert your CD redorder device name ($CDRECORDER): "
1019     read cdW
1020     if [ "$cdW" = "" ];then cdW="$CDRECORDER";fi
1021     echo CD redorder: "$cdW"
1022     fi
1023     done
1024     fi
1025    
1026     if [ $burnISO -eq 1 ];then
1027     ans=c
1028     while [ 1 ];do
1029     if [ "$ans" = "" ];then ans="y";fi
1030     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
1031     echo -n "Does the CD need blanking (RW-CD)? ([y]/n): "
1032     read ans
1033     done
1034     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
1035     blankCD=1
1036     else
1037     blankCD=0
1038     fi
1039     ans=c
1040     while [ 1 ];do
1041     if [ "$ans" = "" ];then ans="y";fi
1042     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
1043     echo -n "Do you wan to to start a multi-session CD? ([y]/n): "
1044     read ans
1045     done
1046     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
1047     MULTI='-multi'
1048     else
1049     MULTI=''
1050     fi
1051    
1052     clear
1053     echo "Ready to burn the ISO file to CD. Please load a (re)writable CD
1054     in $cdW and Press ENTER to continue... "
1055     read
1056     echo -n "Unmounting CD... "
1057     while [ $(mount |grep "$cdW" | wc -l) -gt 0 ] ;do
1058     umount "$cdW" 2>/dev/null
1059     done
1060     echo 'done'
1061     if [ $blankCD -eq 1 ];then
1062     echo "Blanking CD...
1063     -----------"
1064     cdrecord dev="$cdW" blank=fast -eject || errorMount '
1065    
1066     Error: Blanking procedure failed...
1067    
1068    
1069     '
1070     fi
1071     echo
1072     echo "Burinng ISO file
1073     ----------------"
1074     cdrecord -v dev="$cdW" driveropts=burnfree "$MULTI" -eject "$outFile" || errorMount '
1075    
1076     Error: Burning procedure failed...
1077    
1078    
1079     '
1080     fi
1081     cleanUp

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26