/[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 169 - (show annotations)
Tue May 24 10:10:14 2011 UTC (12 years, 10 months ago) by jyrki
File MIME type: application/x-sh
File size: 31075 byte(s)
I have reviewed the recent changes and fixed some problems.

create-clonezilla-sysresccd.sh
* the script no longer attempts to check the integrity of the disc image if md5sum isn't installed
* the image was deleted only if the user DIDN'T answer 'y' when prompted
* a temporary file was left behind if the image wasn't corrupted

boot-params.html
* a link led to a web page with the .doc extension. Some web browsers think that the page is a Word document.

clonezilla.html
* added a line break
* made a link absolute
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 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 if [ "$ans" != "n" ];then
124 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 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 if [ "$ans" = "y" ];then
157 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 if [ "$ans" = "y" ];then
176 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 if [ "$ans" != "n" ];then
216 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 function noRoot(){
226 echo " Error: You must be root to execute this script"
227 exit 1
228 }
229
230 function getScript(){
231 if [ -n "$auto" ];then return;fi
232 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 echo -n "Creating "$SAVE_DIR"/tmp folder... "
317 mkdir "$SAVE_DIR"/tmp 2>/dev/null
318 if [ ! -d "$SAVE_DIR"/tmp ];then
319 echo
320 echo " Error creating folder: "$SAVE_DIR"/tmp"
321 echo " This shouldn't be happening..."
322 exit 1
323 fi
324 echo 'done'
325
326 echo -n "Creating temp folders... "
327 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 echo
334 echo " Error creating temp folder: "$SAVE_DIR"/tmp/syscd"
335 exit 1
336 fi
337 if [ ! -d "$SAVE_DIR"/tmp/clonecd ];then
338 echo
339 echo " Error creating temp folder: "$SAVE_DIR"/tmp/clonecd"
340 exit 1
341 fi
342
343
344 if [ ! -d "$SAVE_DIR"/tmp/clonezilla-sysresccd ];then
345 echo
346 echo " Error creating temp folder: "$SAVE_DIR"/tmp/clonezilla-sysresccd"
347 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 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 cleanUp
362 exit 1
363 }
364
365 function cleanUp(){
366 echo -n "
367 Cleaning up... "
368 umount "$SAVE_DIR"/tmp/clonecd 2>/dev/null
369 umount "$SAVE_DIR"/tmp/syscd 2>/dev/null
370 if [ -z "$cleanUpValue" ];then
371 rm -rf "$SAVE_DIR"/tmp/clonezilla-sysresccd 2>/dev/null
372 fi
373 rm -rf "$SAVE_DIR"/tmp/clonecd "$SAVE_DIR"/tmp/syscd 2>/dev/null
374 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 a run in auto mode (no confirmation, assume yes to
419 all questions asked, no ISO burning to disk)
420 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 \""$SAVE_DIR"/tmp/clonezilla-sysresccd\".
426 *** Caution: Dangerous!!! ***
427 i only create ISO file. Don't burn anything on CD
428 b burn a previously created ISO file
429 d [folder] Use [folder]/tmp as temporary and output folder
430 instead of $HOME/tmp
431 x [script] A user defined and written BASH script
432 to be executed just before mastering the CD
433 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 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 SAVE_DIR="$HOME"
528
529 MKISOFS=genisoimage
530 onlyBurnISO=0
531 onlyCopyFiles=0
532 onlyCreateISO=0
533 noFileCopy=0
534 exitStatus=0
535
536 profilesExist=0
537 profilesError=0
538
539
540 while getopts ":asp:bfihvn:x:d:g:" Option
541 do
542 case $Option in
543 a)
544 auto=yes
545 ;;
546 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 usingProfile=yes
577 else
578 echo " Error in parameter: -p $OPTARG"
579 exit 1
580 fi
581 else
582 echo " Error: You have requested to use profile No $OPTARG but your profiles configuration file"
583 echo " \"/root/.clonezilla-sysresccd/profiles.conf\" does not exist or cannot be read"
584 exit 1
585 fi
586 ;;
587 b)
588 readConfig
589 onlyBurnISO=1;;
590 f)
591 readConfig
592 onlyCopyFiles=1;;
593 i)
594 readConfig
595 onlyCreateISO=1;;
596 x)
597 readConfig
598 [ -s "OPTARG" ] || {
599 echo " Error: The specified script \"$OPTARG\" cannot be found"
600 exit 1
601 }
602 [ -r "$OPTARG" ] && exScript="$OPTARG" || {
603 echo " Error: The specified script \"$OPTARG\" cannot be read"
604 exit 1
605 };;
606 h)
607 printHelp
608 exit
609 ;;
610 v)
611 printVersion
612 ;;
613 n)
614 readConfig
615 if [ "$OPTARG" != "f" ] ;then
616 echo "Error: Not a valid parameter -n$OPTARG"
617 exit 1
618 fi
619 noFileCopy=1
620 ;;
621 d)
622 SAVE_DIR="$OPTARG"
623 if [ ! -d "$SAVE_DIR" ]; then
624 mkdir "$SAVEDIR" 2>/dev/null
625 if [ -d "$SAVE_DIR" ];then
626 echo "Error: \"$SAVE_DIR\" cannot be created!!!"
627 exit 1
628 fi
629 fi
630 ;;
631 g)
632 ARCH="$OPTARG"
633 if [ "$ARCH" != "i486" ] && [ "$ARCH" != "i686" ] && [ "$ARCH" != "amd64" ] && [ "$ARCH" != "all" ];then
634 echo " Error in parameter -g. Should be -g [i668|i486|amd64|all]"
635 exit 1
636 fi
637 ;;
638 esac
639 done
640 shift $(($OPTIND - 1))
641
642 if [ -z "$ARCH" ];then
643 test "$(whoami)" = "root" || noRoot
644 else
645 evalPrograms
646 downloadIsoFiles $ARCH
647 exit
648 fi
649 # chack auto mode
650 if [ -n "$auto" ];then
651 if [ -z "$usingProfile" ];then
652 echo ' Error: Parameter -a used without -p'
653 exit 1
654 fi
655 if [ "$onlyBurnISO" -eq 1 ];then
656 echo " Error: Conflicting parameters -a and -b used"
657 exit 1
658 fi
659 fi
660
661 # Check input parameters
662 checkInParms=0
663 checkInParms=$(( onlyBurnISO + onlyCreateISO + onlyCopyFiles + noFileCopy ))
664 if [ $noFileCopy -eq 1 ] && [ $onlyCreateISO -eq 1 ];then
665 okToContinue=1
666 elif [ $checkInParms -gt 1 ];then
667 echo " Error: Conflicting input parameters detected..."
668 exit 1
669 fi
670 if [ "$outName" = "" ];then
671 outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$version".iso
672 else
673 outFile="$SAVE_DIR"/tmp/clonezilla-sysresccd-"$outName"-"$version".iso
674 fi
675
676 if [ $onlyBurnISO -eq 0 ];then
677 if [ $noFileCopy -eq 0 ];then
678 while [ "$ans" != "y" ] || [ "$ans" = "Y" ];do
679 test -z "$sysCD" && getSysCD
680 test -z "$cloneCD" && getCloneCD
681 test -z "$cfgFile" && getcfgFile
682 test -z "$exScript" && getScript
683 # test -z "$DebianLiveFolder" && getDebianLiveFolder
684 clear
685 # echo -n "Current settings:
686 # System Rescue CD: $sysCD
687 # Clonezilla Live CD: $cloneCD
688 # isolinux.cfg to use: $cfgFile
689 # Debian Live folder: $DebianLiveFolder
690 # script to execute: $exScript
691 #
692 # Is this correct? (y/[n]): "
693
694 if [ -n "$auto" ]; then
695 ans=y
696 else
697 echo -n "Current settings:
698 System Rescue CD: $sysCD
699 Clonezilla Live CD: $cloneCD
700 isolinux.cfg to use: $cfgFile
701 script to execute: $exScript
702
703 Is this correct? (y/[n]): "
704
705 read ans
706 fi
707 if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then
708 sysCD=''
709 cloneCD=''
710 cfgFile=''
711 fi
712 done
713 ans=''
714 while [ 1 ];do
715 test -z "$preparerID" && getPreparer
716 test -z "$publisher" && getPublisher
717 test -z "$volLabel" && getvolLabel
718
719 if [ -n "$auto" ]; then
720 ans=y
721 else
722 clear
723 echo -n "Current CD info:
724 Preparer: $preparerID
725 Publisher: $publisher
726 Volume label: $volLabel
727
728 Is this correct? (y/[n]): "
729 read ans
730 fi
731 if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then
732 preparerID=''
733 publisher=''
734 volLabel=''
735 fi
736 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then break;fi
737 done
738 trap cleanUp 2
739 clear
740 echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr>
741 "
742 createTempFolders
743
744 echo -n "Mounting ISO files... "
745 mount "$sysCD" "$SAVE_DIR"/tmp/syscd -o loop || errorMount ' Error mounting "System Rescue CD" file'
746 mount "$cloneCD" "$SAVE_DIR"/tmp/clonecd -o loop || errorMount ' Error mounting Clonezilla" file'
747 echo 'done'
748 echo -n "Copying files... "
749 cp -RL "$SAVE_DIR"/tmp/syscd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd
750 cp -RL "$SAVE_DIR"/tmp/clonecd/* "$SAVE_DIR"/tmp/clonezilla-sysresccd
751 echo 'done'
752
753
754 # echo -n "Extracting boot programs... "
755 echo "Extracting boot programs... "
756 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog
757 mkdir tmp
758 cp *zip tmp
759 unzip -x sys*zip win32/syslinux.exe
760 mv win32/* .
761 rmdir win32
762 unzip -x gr* gr*/grub.exe
763 mv gr*/grub.exe .
764 rm -rf grub4dos*
765 cp tmp/* .
766 rm -rf tmp
767 # echo 'done'
768
769 if [ ! -z "$splash" ];then
770 echo -n "Copying new spalsh screen... "
771 cp -L "$splash" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png
772 echo 'done'
773 else
774 cp -L /root/.clonezilla-sysresccd/files/default-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/ocswp.png
775 fi
776
777 echo -n "Copying Super Grub Disk... "
778 cp -L /root/.clonezilla-sysresccd/files/sgd.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img && echo 'done' || {
779 echo
780 echo
781 echo
782 echo " Error: Copying Super Grub Disk failed!!!"
783 echo
784 echo " Please make sure that the image file exists"
785 echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd.img"
786 echo
787 echo
788 cleanUp
789 exit 1
790 }
791 if [ -e /root/.clonezilla-sysresccd/files/sgd2.img ];then
792 echo -n "Copying Super Grub Disk 2... "
793 cp -L /root/.clonezilla-sysresccd/files/sgd2.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/grubdisk.img && echo 'done' || {
794 echo
795 echo
796 echo
797 echo " Error: Copying Super Grub Disk 2 failed!!!"
798 echo
799 echo " Please make sure that the image file exists"
800 echo " Image file: "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk/sgd2.img"
801 echo
802 echo
803 cleanUp
804 exit 1
805 }
806 fi
807 echo -n "Copying new cfg file(s)... "
808 if [ -z $(echo "$cfgFile" | grep 'cfg$') ];then
809 tar -C "$SAVE_DIR"/tmp/clonezilla-sysresccd -xzhf /root/.clonezilla-sysresccd/files/menu-for-iso.tar.gz
810 else
811 cp -L "$cfgFile" "$SAVE_DIR"/tmp/clonezilla-sysresccd/isolinux/isolinux.cfg
812 fi
813 echo 'done'
814
815 echo -n "Creating folder restorecd... "
816 WHERE="$(pwd)"
817 mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd 2>/dev/null
818 cd /root/.clonezilla-sysresccd/files
819 cp -L pre* ocs-iso what-cd patch-clonezilla-sysresccd continue-multi-cd isolinux-restore-cd.cfg \
820 isolinux-restore-cd-ram.cfg menu-for-iso.tar.gz doc.tar.gz imginfo imgconvert cust-menu "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd
821 cp -L default-restore-ocswp.png "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ocswp.png
822 cp sbminst "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd
823
824 # Copy Smart Boot Manager and rawrite-fdimage to bootdisk
825 mkdir "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite
826 cp raw* fd* *dll "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite
827 cp sbm.img "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootdisk
828 cd "$DebianLiveFolder" 2>/dev/null || debFilesError=yes
829 # if [ -s files.tar.gz ];then
830 # cp -L files.tar.gz "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/ 2>/dev/null || debFilesError=yes
831 # else
832 # [ -e "$DebianLiveFolder"/unifont.bgf ] || {
833 # uniFontCopied=yes
834 # cp -L /root/.clonezilla-sysresccd/files/unifont.bgf "$DebianLiveFolder"
835 # }
836 # tar chzf "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/files.tar.gz unifont.bgf debian-live-for-ocs.iso 2>/dev/null || debFilesError=yes
837 # [ -z "$uniFontCopied" ] || rm "$DebianLiveFolder"/unifont.bgf
838 # fi
839 # [ -z "$debFilesError" ] || {
840 # echo
841 # echo
842 # echo
843 # echo " Error: Copying files.tar.gz failed!!!"
844 # echo
845 # echo " Please make sure that the variable DebianLiveFolder points either to"
846 # echo " the folder where the files unifont.bgf and debian-live-for-ocs.iso"
847 # echo " reside, or the files files.tar.gz (which contains unifont.bgf and"
848 # echo " debian-live-for-ocs.iso) can be found"
849 # echo
850 # echo
851 # echo
852 # cleanUp
853 # exit 1
854 # }
855 cd "$WHERE"
856 echo "done"
857
858 echo -n "Copying documentation files... "
859 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd
860 tar xzhf "$SAVE_DIR"/tmp/clonezilla-sysresccd/restorecd/doc.tar.gz
861 echo 'done'
862
863 if [ ! -z "$exScript" ];then
864 # echo -n "Executing external script: \"$exScript\"... "
865 echo -n "Executing external script... "
866 . "$exScript" || {
867 echo
868 echo
869 echo
870 echo " Error: The execution of the script failed!!!"
871 echo " Please correct it and try again"
872 echo
873 echo " Script: \"$exScript\""
874 cleanUp
875 exit 1
876 }
877 echo 'done'
878 fi
879 # echo
880 # echo
881 # echo
882 else
883 trap cleanUp 2
884 cleanUpValue=1
885 if [ ! -d "$SAVE_DIR"/tmp/clonezilla-sysresccd ];then
886 echo " Error accessing folder \""$SAVE_DIR"/tmp/clonezilla-sysresccd\""
887 exitStatus=1
888 cleanUp
889 fi
890 fi
891
892 # move extra folders into utils
893 mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/rawrite "$SAVE_DIR"/tmp/clonezilla-sysresccd/bootprog "$SAVE_DIR"/tmp/clonezilla-sysresccd/utils
894 mv "$SAVE_DIR"/tmp/clonezilla-sysresccd/version "$SAVE_DIR"/tmp/clonezilla-sysresccd/SystemRescueCD-Version
895
896 #
897 # re-build clonezilla filesystem.squashfs
898 #
899 echo -n "Rebuilding Clonezilla squashfs... "
900 cd "$SAVE_DIR"/tmp/clonezilla-sysresccd/live
901 unsquashfs filesystem.squashfs 2>/dev/null 1>&2
902 cp -r ../README* ../doc ../restorecd squashfs-root
903 mksquashfs squashfs-root aa.squashfs -always-use-fragments -no-duplicates -all-root 2>/dev/null 1>&2
904 mv aa.squashfs filesystem.squashfs
905 rm -rf squashfs-root
906 cd
907 echo 'done'
908
909 if [ $onlyCopyFiles -eq 1 ];then
910 cleanUpValue=1
911 # echo
912 # echo
913 echo "Both CDs have been copyied in: "$SAVE_DIR"/tmp/clonezilla-sysresccd"
914 cleanUp
915 fi
916 echo
917 if [ -z "$auto" ]; then
918 echo -n "Ready to create new ISO file.
919
920 ************************************************************************
921 Ready to master your CD. If you want to alter any files contained
922 in the CD, now is the right time.
923 CD root is \""$SAVE_DIR"/tmp/clonezilla-sysresccd\"
924
925 When you are done
926 ***********************************************************************
927
928 Press ENTER to continue... "
929 read
930 else
931 echo "Creating new ISO file."
932 fi
933 find "$SAVE_DIR"/tmp/clonezilla-sysresccd -name "*~" -exec rm '{}' ';'
934 # $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
935 $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
936 echo "
937 Done creating new ISO file
938 The file is saved as $outFile"
939 ans=c
940 chIsoHyb=`type isohybrid 2>/dev/null`
941 if [ -n "$chIsoHyb" ];then
942 echo -n "Isohybriding $outFile... "
943 isohybrid "$outFile"
944 echo 'done'
945 fi
946
947 if [ -z "$auto" ];then
948 echo '
949
950 '
951 fi
952 else
953 while [ ! -r "$outFile" ];do
954 echo 'Insert "clonezilla-resccd" ISO file name'
955 echo -n "> "
956 read outFile
957 done
958 ans=y
959 fi
960
961 if [ $onlyCreateISO -eq 1 ];then ans=n;fi
962
963 while [ 1 ];do
964 if [ "$ans" = "" ];then ans=y;fi
965 if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
966 if [ -n "$auto" ]; then
967 ans=n
968 else
969 echo -n "Do you want to burn this ISO file? ([y]/n): "
970 read ans
971 fi
972 done
973 burnISO=0
974 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
975 echo
976 echo "File to burn: $outFile"
977 echo
978 burnISO=1
979 # decectDVDWriter
980
981 # CDRECORDER=$(sh /root/.clonezilla-sysresccd/files/what-cd -wb)
982 chmod +x /root/.clonezilla-sysresccd/files/what-cd
983 CDRECORDER=$(/root/.clonezilla-sysresccd/files/what-cd -wb)
984 chmod -x /root/.clonezilla-sysresccd/files/what-cd
985
986 echo CD redorder found: "$CDRECORDER"
987 ans=''
988 until [ "$ans" = "y" ] || [ "$ans" = "Y" ];do
989 echo -n "Is this correct? ([y]/n): "
990 read ans
991 if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "" ];then
992 ans='y'
993 cdW="$CDRECORDER"
994 else
995 echo -n "Insert your CD redorder device name ($CDRECORDER): "
996 read cdW
997 if [ "$cdW" = "" ];then cdW="$CDRECORDER";fi
998 echo CD redorder: "$cdW"
999 fi
1000 done
1001 fi
1002
1003 if [ $burnISO -eq 1 ];then
1004 ans=c
1005 while [ 1 ];do
1006 if [ "$ans" = "" ];then ans="y";fi
1007 if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
1008 echo -n "Does the CD need blanking (RW-CD)? ([y]/n): "
1009 read ans
1010 done
1011 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
1012 blankCD=1
1013 else
1014 blankCD=0
1015 fi
1016 ans=c
1017 while [ 1 ];do
1018 if [ "$ans" = "" ];then ans="y";fi
1019 if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi
1020 echo -n "Do you wan to to start a multi-session CD? ([y]/n): "
1021 read ans
1022 done
1023 if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then
1024 MULTI='-multi'
1025 else
1026 MULTI=''
1027 fi
1028
1029 clear
1030 echo "Ready to burn the ISO file to CD. Please load a (re)writable CD
1031 in $cdW and Press ENTER to continue... "
1032 read
1033 echo -n "Unmounting CD... "
1034 while [ $(mount |grep "$cdW" | wc -l) -gt 0 ] ;do
1035 umount "$cdW" 2>/dev/null
1036 done
1037 echo 'done'
1038 if [ $blankCD -eq 1 ];then
1039 echo "Blanking CD...
1040 -----------"
1041 cdrecord dev="$cdW" blank=fast -eject || errorMount '
1042
1043 Error: Blanking procedure failed...
1044
1045
1046 '
1047 fi
1048 echo
1049 echo "Burinng ISO file
1050 ----------------"
1051 cdrecord -v dev="$cdW" driveropts=burnfree "$MULTI" -eject "$outFile" || errorMount '
1052
1053 Error: Burning procedure failed...
1054
1055
1056 '
1057 fi
1058 cleanUp

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26