/[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 193 - (hide annotations)
Tue Aug 28 09:39:20 2012 UTC (9 years, 3 months ago) by sng
File MIME type: application/x-sh
File size: 32710 byte(s)
- updating ChangeLog
- using xz compression for mksquashfs in create-clonezilla-sysresccd

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 193 SystemRescueCD will be downloaded in any case
449 sng 47 v print version and exit
450     h print this screen and exit
451    
452     More information on available customization in file
453     /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf"
454     }
455    
456     function printVersion(){
457     echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr>
458     A utility to create a multi boot CD containing
459     Clonezilla Live CD and
460     System Rescue CD
461     (they have to be downloaded seperately)"
462     exit
463     }
464    
465     # function decectDVDWriter(){
466     # local z
467     # # local DEV0 DEV1
468     # local CDW0 CDW1
469     # local DVDW0 DVDW1
470     #
471     # z=`cat /proc/sys/dev/cdrom/info 2>/dev/null | grep name | sed 's/.*name://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' `
472     # DEV0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'`
473     # DEV1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'`
474     #
475     # z=`cat /proc/sys/dev/cdrom/info 2>/dev/null| grep 'write' | grep 'DVD-R:'| sed 's/.*DVD-R://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' `
476     # # echo z=$z
477     # DVDW0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'`
478     # DVDW1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'`
479     #
480     #
481     # z=`cat /proc/sys/dev/cdrom/info 2>/dev/null| grep 'write' | grep 'CD-R:'| sed 's/.*CD-R://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' `
482     # # echo z=$z
483     # CDW0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'`
484     # CDW1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'`
485     #
486     # if ! test -z "$DEV0";then
487     # if [ "$DVDW0" = "1" ];then DVDRECORDER=/dev/"$DEV0";fi
488     # if [ "$CDW0" = "1" ];then CDRECORDER=/dev/"$DEV0";fi
489     # fi
490     #
491     # if ! test -z "$DEV1";then
492     # if test -z "$DVDRECORDER"; then
493     # if [ "$DVDW1" = "1" ];then
494     # DVDRECORDER=/dev/"$DEV1"
495     # fi
496     # fi
497     # if test -z "$CDRECORDER"; then
498     # if [ "$CDW1" = "1" ];then
499     # CDRECORDER=/dev/"$DEV1"
500     # fi
501     # fi
502     # fi
503     #
504     # }
505    
506     function sourceProfiles(){
507     if [ -r /root/.clonezilla-sysresccd/profiles.conf ];then
508     . /root/.clonezilla-sysresccd/profiles.conf 2>/dev/null || profilesError=1
509     profilesExist=1
510     fi
511     if [ $profilesError -eq 1 ];then
512     echo " Error: Your profiles configuration file \"/root/.clonezilla-sysresccd/profiles.conf\""
513     echo " has errors and cannot be used. Please fix the problem and try again"
514     exit 1
515     fi
516     }
517    
518    
519     function readConfig(){
520     if [ -n "$configAlreadyRead" ];then return; fi
521     test "$(whoami)" = "root" || noRoot
522     [ -r /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf ] || {
523     echo " Error: Your configuration file \"/root/.clonezilla-sysresccd/clonezilla-sysresccd.conf\""
524     echo " does not exist or can not be read. Please fix the problem and try again"
525     exit 1
526     }
527    
528     . /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf 2>/dev/null
529     if [ $? -ne 0 ];then
530     echo " Error: Your configuration file \"/root/.clonezilla-sysresccd/clonezilla-sysresccd.conf\""
531     echo " has errors and cannot be used. Please fix the problem and try again"
532     exit 1
533     fi
534     configAlreadyRead='true'
535     }
536    
537     ####### Script starts here #######
538 sng 140 SAVE_DIR="$HOME"
539    
540 sng 93 MKISOFS=genisoimage
541 sng 47 onlyBurnISO=0
542     onlyCopyFiles=0
543     onlyCreateISO=0
544     noFileCopy=0
545     exitStatus=0
546    
547     profilesExist=0
548     profilesError=0
549    
550    
551 sng 162 while getopts ":asp:bfihvn:x:d:g:" Option
552 sng 47 do
553     case $Option in
554 sng 61 a)
555     auto=yes
556 sng 162 ;;
557 sng 47 s)
558     readConfig
559     sourceProfiles
560     if [ $profilesExist -eq 1 ];then
561     readProfiles
562     until [ ! -z "$prN" ];do
563     clear
564     echo "Available profiles"
565     for i in `seq 0 $numOfProfiles`;do
566     echo " Profile[$i]: ${profile[$i]}"
567     done
568     echo -n "Insert profile number ([0]-$numOfProfiles): "
569     read prN
570     test -z "$prN" && prN=0
571     isnumber "$prN" || prN=''
572     if [ $prN -gt $numOfProfiles ] 2>/dev/null; then prN='';fi
573     done
574     applyProfile $prN
575     else
576     echo " Error: You have requested to use profiles but your profiles configuration file"
577     echo " \"/root/.clonezilla-sysresccd/profiles.conf\" does not exist or cannot be read"
578     exit 1
579     fi
580     ;;
581     p)
582     readConfig
583     sourceProfiles
584     if [ $profilesExist -eq 1 ];then
585     if $(isnumber "$OPTARG");then
586     applyProfile $OPTARG
587 sng 162 usingProfile=yes
588 sng 176 currentProfile=$OPTARG
589 sng 47 else
590     echo " Error in parameter: -p $OPTARG"
591     exit 1
592     fi
593     else
594     echo " Error: You have requested to use profile No $OPTARG but your profiles configuration file"
595     echo " \"/root/.clonezilla-sysresccd/profiles.conf\" does not exist or cannot be read"
596     exit 1
597     fi
598     ;;
599     b)
600     readConfig
601     onlyBurnISO=1;;
602     f)
603     readConfig
604     onlyCopyFiles=1;;
605     i)
606     readConfig
607     onlyCreateISO=1;;
608     x)
609     readConfig
610     [ -s "OPTARG" ] || {
611     echo " Error: The specified script \"$OPTARG\" cannot be found"
612     exit 1
613     }
614     [ -r "$OPTARG" ] && exScript="$OPTARG" || {
615     echo " Error: The specified script \"$OPTARG\" cannot be read"
616     exit 1
617     };;
618     h)
619     printHelp
620     exit
621     ;;
622     v)
623     printVersion
624     ;;
625     n)
626     readConfig
627     if [ "$OPTARG" != "f" ] ;then
628     echo "Error: Not a valid parameter -n$OPTARG"
629     exit 1
630     fi
631     noFileCopy=1
632     ;;
633 sng 140 d)
634     SAVE_DIR="$OPTARG"
635     if [ ! -d "$SAVE_DIR" ]; then
636     mkdir "$SAVEDIR" 2>/dev/null
637     if [ -d "$SAVE_DIR" ];then
638     echo "Error: \"$SAVE_DIR\" cannot be created!!!"
639     exit 1
640     fi
641     fi
642     ;;
643 sng 162 g)
644     ARCH="$OPTARG"
645     if [ "$ARCH" != "i486" ] && [ "$ARCH" != "i686" ] && [ "$ARCH" != "amd64" ] && [ "$ARCH" != "all" ];then
646     echo " Error in parameter -g. Should be -g [i668|i486|amd64|all]"
647     exit 1
648     fi
649     ;;
650 sng 47 esac
651     done
652     shift $(($OPTIND - 1))
653    
654 sng 162 if [ -z "$ARCH" ];then
655     test "$(whoami)" = "root" || noRoot
656     else
657     evalPrograms
658     downloadIsoFiles $ARCH
659     exit
660     fi
661 sng 190 # check auto mode
662 sng 61 if [ -n "$auto" ];then
663     if [ -z "$usingProfile" ];then
664     echo ' Error: Parameter -a used without -p'
665 sng 162 exit 1
666     fi
667 sng 64 if [ "$onlyBurnISO" -eq 1 ];then
668 sng 63 echo " Error: Conflicting parameters -a and -b used"
669 sng 162 exit 1
670     fi
671 sng 61 fi
672    
673 sng 47 # Check input parameters
674     checkInParms=0
675     checkInParms=$(( onlyBurnISO + onlyCreateISO + onlyCopyFiles + noFileCopy ))
676     if [ $noFileCopy -eq 1 ] && [ $onlyCreateISO -eq 1 ];then
677     okToContinue=1
678     elif [ $checkInParms -gt 1 ];then
679     echo " Error: Conflicting input parameters detected..."
680     exit 1
681     fi
682     if [ "$outName" = "" ];then
683 sng 140 outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$version".iso
684 sng 47 else
685 sng 140 outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$outName"-"$version".iso
686 sng 47 fi
687    
688     if [ $onlyBurnISO -eq 0 ];then
689     if [ $noFileCopy -eq 0 ];then
690     while [ "$ans" != "y" ] || [ "$ans" = "Y" ];do
691     test -z "$sysCD" && getSysCD
692     test -z "$cloneCD" && getCloneCD
693     test -z "$cfgFile" && getcfgFile
694     test -z "$exScript" && getScript
695     # test -z "$DebianLiveFolder" && getDebianLiveFolder
696     clear
697     # echo -n "Current settings:
698     # System Rescue CD: $sysCD
699     # Clonezilla Live CD: $cloneCD
700     # isolinux.cfg to use: $cfgFile
701     # Debian Live folder: $DebianLiveFolder
702     # script to execute: $exScript
703     #
704     # Is this correct? (y/[n]): "
705    
706 sng 190 if [ -n "$auto" ]; then
707     ans=y
708     else
709     echo -n "Current settings:
710     System Rescue CD: $sysCD
711     Clonezilla Live CD: $cloneCD
712     isolinux.cfg to use: $cfgFile
713     script to execute: $exScript
714    
715     Is this correct? (y/[n]): "
716    
717     read ans
718     fi
719 sng 47 if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then
720     sysCD=''
721     cloneCD=''
722     cfgFile=''
723     fi
724     done
725     ans=''
726     while [ 1 ];do
727     test -z "$preparerID" && getPreparer
728     test -z "$publisher" && getPublisher
729     test -z "$volLabel" && getvolLabel
730 sng 61
731     if [ -n "$auto" ]; then
732     ans=y
733     else
734 sng 162 clear
735 sng 47 echo -n "Current CD info:
736     Preparer: $preparerID
737     Publisher: $publisher
738     Volume label: $volLabel
739    
740     Is this correct? (y/[n]): "
741 sng 61 read ans
742     fi
743 sng 47 if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then
744     preparerID=''
745     publisher=''
746     volLabel=''
747     fi
748     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then break;fi
749     done
750     trap cleanUp 2
751     clear
752     echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr>
753     "
754 sng 176
755     if [ -n "$currentProfile" ];then
756     echo "Running profile: $currentProfile ($outName)"
757     fi
758    
759 sng 47 createTempFolders
760    
761     echo -n "Mounting ISO files... "
762 sng 190 mount "$sysCD" "$SAVE_DIR"/tmp/syscd -o ro,loop || errorMount ' Error mounting "System Rescue CD" file'
763     mount "$cloneCD" "$SAVE_DIR"/tmp/clonecd -o ro,loop || errorMount ' Error mounting Clonezilla" file'
764 sng 47 echo 'done'
765     echo -n "Copying files... "
766 sng 140 cp -RL "$SAVE_DIR"/tmp/syscd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd
767     cp -RL "$SAVE_DIR"/tmp/clonecd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd
768 sng 47 echo 'done'
769    
770    
771     # echo -n "Extracting boot programs... "
772     echo "Extracting boot programs... "
773 sng 140 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog
774 sng 47 mkdir tmp
775     cp *zip tmp
776     unzip -x sys*zip win32/syslinux.exe
777     mv win32/* .
778     rmdir win32
779     unzip -x gr* gr*/grub.exe
780     mv gr*/grub.exe .
781     rm -rf grub4dos*
782     cp tmp/* .
783     rm -rf tmp
784     # echo 'done'
785    
786     if [ ! -z "$splash" ];then
787 sng 178 echo -n "Copying new spalsh screen... "
788     cp -L "$splash" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png
789     echo 'done'
790 sng 47 else
791 sng 178 cp -L /root/.clonezilla-sysresccd/files/default-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png
792 sng 47 fi
793    
794     echo -n "Copying Super Grub Disk... "
795 sng 140 cp -L /root/.clonezilla-sysresccd/files/sgd.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img && echo 'done' || {
796 sng 47 echo
797     echo
798     echo
799     echo " Error: Copying Super Grub Disk failed!!!"
800     echo
801     echo " Please make sure that the image file exists"
802 sng 140 echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img"
803 sng 47 echo
804     echo
805     cleanUp
806     exit 1
807     }
808     if [ -e /root/.clonezilla-sysresccd/files/sgd2.img ];then
809     echo -n "Copying Super Grub Disk 2... "
810 sng 140 cp -L /root/.clonezilla-sysresccd/files/sgd2.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/grubdisk.img && echo 'done' || {
811 sng 47 echo
812     echo
813     echo
814     echo " Error: Copying Super Grub Disk 2 failed!!!"
815     echo
816     echo " Please make sure that the image file exists"
817 sng 140 echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd2.img"
818 sng 47 echo
819     echo
820     cleanUp
821     exit 1
822     }
823     fi
824     echo -n "Copying new cfg file(s)... "
825     if [ -z $(echo "$cfgFile" | grep 'cfg$') ];then
826 sng 140 tar -C "$SAVE_DIR"/tmp/clonezilla-sysresccd -xzhf /root/.clonezilla-sysresccd/files/menu-for-iso.tar.gz
827 sng 47 else
828 sng 140 cp -L "$cfgFile" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/isolinux.cfg
829 sng 47 fi
830     echo 'done'
831    
832     echo -n "Creating folder restorecd... "
833     WHERE="$(pwd)"
834 sng 140 mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd 2>/dev/null
835 sng 47 cd /root/.clonezilla-sysresccd/files
836 sng 64 cp -L pre* ocs-iso what-cd patch-clonezilla-sysresccd continue-multi-cd isolinux-restore-cd.cfg \
837 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
838 sng 178 fsplash=`basename "$splash"`
839     if [ "$fsplash" = "default-ocswp-i686.png" ] || [ "$fsplash" = "default-ocswp-i486.png" ] || [ "$fsplash" = "default-ocswp-amd64.png" ];then
840     cp $(echo "$splash" | sed 's/default/default-restore/') "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ocswp.png
841     else
842     cp -L default-restore-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ocswp.png
843     fi
844 sng 140 cp sbminst "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd
845 sng 47
846     # Copy Smart Boot Manager and rawrite-fdimage to bootdisk
847 sng 140 mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite
848     cp raw* fd* *dll "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite
849     cp sbm.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk
850 sng 47 cd "$DebianLiveFolder" 2>/dev/null || debFilesError=yes
851     # if [ -s files.tar.gz ];then
852 sng 140 # cp -L files.tar.gz "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ 2>/dev/null || debFilesError=yes
853 sng 47 # else
854     # [ -e "$DebianLiveFolder"/unifont.bgf ] || {
855     # uniFontCopied=yes
856     # cp -L /root/.clonezilla-sysresccd/files/unifont.bgf "$DebianLiveFolder"
857     # }
858 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
859 sng 47 # [ -z "$uniFontCopied" ] || rm "$DebianLiveFolder"/unifont.bgf
860     # fi
861     # [ -z "$debFilesError" ] || {
862     # echo
863     # echo
864     # echo
865     # echo " Error: Copying files.tar.gz failed!!!"
866     # echo
867     # echo " Please make sure that the variable DebianLiveFolder points either to"
868     # echo " the folder where the files unifont.bgf and debian-live-for-ocs.iso"
869     # echo " reside, or the files files.tar.gz (which contains unifont.bgf and"
870     # echo " debian-live-for-ocs.iso) can be found"
871     # echo
872     # echo
873     # echo
874     # cleanUp
875     # exit 1
876     # }
877     cd "$WHERE"
878     echo "done"
879    
880     echo -n "Copying documentation files... "
881 sng 140 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd
882     tar xzhf "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/doc.tar.gz
883 sng 47 echo 'done'
884    
885     if [ ! -z "$exScript" ];then
886     # echo -n "Executing external script: \"$exScript\"... "
887 sng 178 echo -n "Executing external script... "
888     . "$exScript" || {
889     echo
890     echo
891     echo
892     echo " Error: The execution of the script failed!!!"
893     echo " Please correct it and try again"
894     echo
895     echo " Script: \"$exScript\""
896     cleanUp
897     exit 1
898     }
899     echo 'done'
900 sng 47 fi
901     # echo
902     # echo
903     # echo
904 sng 178 else
905     trap cleanUp 2
906     cleanUpValue=1
907     if [ ! -d "$SAVE_DIR"/tmp/clonezilla-sysresccd ];then
908     echo " Error accessing folder \""$SAVE_DIR"/tmp/clonezilla-sysresccd\""
909     exitStatus=1
910     cleanUp
911     fi
912 sng 47 fi
913    
914     # move extra folders into utils
915 sng 140 mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog "$SAVE_DIR"/tmp/clonezilla-sysresccd/utils
916     mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/version "$SAVE_DIR"/tmp/clonezilla-sysresccd/SystemRescueCD-Version
917 sng 47
918 sng 178 # copy png files from isolinux/ to syslinux/
919     cp "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/*.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/syslinux
920 sng 68 #
921     # re-build clonezilla filesystem.squashfs
922     #
923     echo -n "Rebuilding Clonezilla squashfs... "
924 sng 140 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/live
925 sng 68 unsquashfs filesystem.squashfs 2>/dev/null 1>&2
926     cp -r ../README* ../doc ../restorecd squashfs-root
927 sng 193 # mksquashfs squashfs-root aa.squashfs -always-use-fragments -no-duplicates -all-root 2>/dev/null 1>&2
928     if [ "$clonType" = "amd64" ];then
929     mksquashfs squashfs-root aa.squashfs -comp xz -Xbcj ia64 -Xdict-size 75% -always-use-fragments -no-duplicates -all-root 2>/dev/null 1>&2
930     else
931     mksquashfs squashfs-root aa.squashfs -comp xz -Xbcj x86 -Xdict-size 75% -always-use-fragments -no-duplicates -all-root 2>/dev/null 1>&2
932     fi
933 sng 68 mv aa.squashfs filesystem.squashfs
934     rm -rf squashfs-root
935     cd
936     echo 'done'
937    
938 sng 47 if [ $onlyCopyFiles -eq 1 ];then
939     cleanUpValue=1
940     # echo
941     # echo
942 sng 140 echo "Both CDs have been copyied in: "$SAVE_DIR"/tmp/clonezilla-sysresccd"
943 sng 47 cleanUp
944     fi
945     echo
946 sng 61 if [ -z "$auto" ]; then
947     echo -n "Ready to create new ISO file.
948 sng 47
949     ************************************************************************
950     Ready to master your CD. If you want to alter any files contained
951     in the CD, now is the right time.
952 sng 140 CD root is \""$SAVE_DIR"/tmp/clonezilla-sysresccd\"
953 sng 47
954     When you are done
955     ***********************************************************************
956    
957     Press ENTER to continue... "
958     read
959 sng 61 else
960     echo "Creating new ISO file."
961     fi
962 sng 140 find "$SAVE_DIR"/tmp/clonezilla-sysresccd -name "*~" -exec rm '{}' ';'
963     # $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
964     $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
965 sng 47 echo "
966     Done creating new ISO file
967     The file is saved as $outFile"
968     ans=c
969     chIsoHyb=`type isohybrid 2>/dev/null`
970     if [ -n "$chIsoHyb" ];then
971     echo -n "Isohybriding $outFile... "
972     isohybrid "$outFile"
973     echo 'done'
974     fi
975    
976 sng 61 if [ -z "$auto" ];then
977 sng 47 echo '
978    
979     '
980 sng 61 fi
981 sng 47 else
982     while [ ! -r "$outFile" ];do
983     echo 'Insert "clonezilla-resccd" ISO file name'
984     echo -n "> "
985     read outFile
986     done
987     ans=y
988     fi
989    
990     if [ $onlyCreateISO -eq 1 ];then ans=n;fi
991    
992     while [ 1 ];do
993     if [ "$ans" = "" ];then ans=y;fi
994     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
995 sng 61 if [ -n "$auto" ]; then
996     ans=n
997     else
998     echo -n "Do you want to burn this ISO file? ([y]/n): "
999 sng 174 read ans
1000 sng 61 fi
1001 sng 47 done
1002     burnISO=0
1003     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
1004     echo
1005     echo "File to burn: $outFile"
1006     echo
1007     burnISO=1
1008     # decectDVDWriter
1009    
1010 sng 58 # CDRECORDER=$(sh /root/.clonezilla-sysresccd/files/what-cd -wb)
1011     chmod +x /root/.clonezilla-sysresccd/files/what-cd
1012     CDRECORDER=$(/root/.clonezilla-sysresccd/files/what-cd -wb)
1013     chmod -x /root/.clonezilla-sysresccd/files/what-cd
1014 sng 47
1015     echo CD redorder found: "$CDRECORDER"
1016     ans=''
1017     until [ "$ans" = "y" ] || [ "$ans" = "Y" ];do
1018     echo -n "Is this correct? ([y]/n): "
1019     read ans
1020     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "" ];then
1021     ans='y'
1022     cdW="$CDRECORDER"
1023     else
1024     echo -n "Insert your CD redorder device name ($CDRECORDER): "
1025     read cdW
1026     if [ "$cdW" = "" ];then cdW="$CDRECORDER";fi
1027     echo CD redorder: "$cdW"
1028     fi
1029     done
1030     fi
1031    
1032     if [ $burnISO -eq 1 ];then
1033     ans=c
1034     while [ 1 ];do
1035     if [ "$ans" = "" ];then ans="y";fi
1036     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
1037     echo -n "Does the CD need blanking (RW-CD)? ([y]/n): "
1038     read ans
1039     done
1040     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
1041     blankCD=1
1042     else
1043     blankCD=0
1044     fi
1045     ans=c
1046     while [ 1 ];do
1047     if [ "$ans" = "" ];then ans="y";fi
1048     if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
1049     echo -n "Do you wan to to start a multi-session CD? ([y]/n): "
1050     read ans
1051     done
1052     if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
1053     MULTI='-multi'
1054     else
1055     MULTI=''
1056     fi
1057    
1058     clear
1059     echo "Ready to burn the ISO file to CD. Please load a (re)writable CD
1060     in $cdW and Press ENTER to continue... "
1061     read
1062     echo -n "Unmounting CD... "
1063     while [ $(mount |grep "$cdW" | wc -l) -gt 0 ] ;do
1064     umount "$cdW" 2>/dev/null
1065     done
1066     echo 'done'
1067     if [ $blankCD -eq 1 ];then
1068     echo "Blanking CD...
1069     -----------"
1070     cdrecord dev="$cdW" blank=fast -eject || errorMount '
1071    
1072     Error: Blanking procedure failed...
1073    
1074    
1075     '
1076     fi
1077     echo
1078     echo "Burinng ISO file
1079     ----------------"
1080     cdrecord -v dev="$cdW" driveropts=burnfree "$MULTI" -eject "$outFile" || errorMount '
1081    
1082     Error: Burning procedure failed...
1083    
1084    
1085     '
1086     fi
1087     cleanUp

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26