/[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 178 - (hide annotations)
Fri Jun 3 17:27:54 2011 UTC (12 years, 9 months ago) by sng
File MIME type: application/x-sh
File size: 31818 byte(s)
- fixing splashscreen (adding Jyrki)
- updating screenshots
- changing splashscreen color (png and cfg files)
- making restore splashscreens correspond to architecture
- making png files in syslinux/ same as isolinux/ in the CD
- fixing typo in cust-menu

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26