/[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 176 - (show annotations)
Tue May 31 19:45:21 2011 UTC (12 years, 10 months ago) by sng
File MIME type: application/x-sh
File size: 31316 byte(s)
- updating prerun scripts. Making them run once
- updating ocs-iso to 1.2.8-46
- minor create-clonezilla-sysresccd update

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26