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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 164 - (show annotations)
Sat Apr 9 21:34:35 2011 UTC (12 years, 11 months ago) by sng
File MIME type: application/x-sh
File size: 31018 byte(s)
- updating profiles.conf for current original CDs
- updating cfg files for Clonezilla Live
- updating trunk site

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26