1 |
############################################################################## |
2 |
# # |
3 |
# create-clonezilla-sysresccd, (C) 2007-2010 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 noRoot(){ |
22 |
echo " Error: You must be root to execute this script" |
23 |
exit 1 |
24 |
} |
25 |
|
26 |
function getScript(){ |
27 |
echo 'Insert script to be executed' |
28 |
echo -n '> ' |
29 |
read exScript |
30 |
} |
31 |
|
32 |
function getSysCD(){ |
33 |
echo 'Insert "System Rescue CD" ISO file name' |
34 |
until [ ! -z "$sysCD" ];do |
35 |
echo -n '> ' |
36 |
read sysCD |
37 |
done |
38 |
|
39 |
if [ ! -s "$sysCD" ];then |
40 |
echo -n " Error: File not found. Press ENTER to continue... " |
41 |
sysCD='' |
42 |
read |
43 |
getSysCD |
44 |
fi |
45 |
} |
46 |
|
47 |
function getCloneCD(){ |
48 |
echo 'Insert "Clonezilla Live" ISO file name' |
49 |
until [ ! -z "$cloneCD" ];do |
50 |
echo -n '> ' |
51 |
read cloneCD |
52 |
done |
53 |
|
54 |
if [ ! -s "$cloneCD" ];then |
55 |
echo -n " Error: File not found. Press ENTER to continue... " |
56 |
cloneCD='' |
57 |
read |
58 |
getCloneCD |
59 |
fi |
60 |
} |
61 |
|
62 |
function getcfgFile(){ |
63 |
echo 'Insert "isolinux.cfg" file to use' |
64 |
until [ ! -z "$cfgFile" ];do |
65 |
echo -n '> ' |
66 |
read cfgFile |
67 |
done |
68 |
if [ ! -s "$cfgFile" ];then |
69 |
echo -n " Error: File not found. Press ENTER to continue... " |
70 |
cfgFile='' |
71 |
read |
72 |
getcfgFile |
73 |
fi |
74 |
} |
75 |
|
76 |
function getPreparer(){ |
77 |
echo 'Insert Preparer ID' |
78 |
until [ ! -z "$preparerID" ];do |
79 |
echo -n '> ' |
80 |
read preparerID |
81 |
done |
82 |
} |
83 |
|
84 |
function getPublisher(){ |
85 |
echo 'Insert Publisher ID' |
86 |
until [ ! -z "$publisher" ];do |
87 |
echo -n '> ' |
88 |
read publisher |
89 |
done |
90 |
} |
91 |
|
92 |
function getvolLabel(){ |
93 |
echo 'Insert CD Volume label' |
94 |
until [ ! -z "$volLabel" ];do |
95 |
echo -n '> ' |
96 |
read volLabel |
97 |
done |
98 |
} |
99 |
|
100 |
function getDebianLiveFolder(){ |
101 |
echo 'Insert Debian Live folder' |
102 |
until [ ! -z "$DebianLiveFolder" ];do |
103 |
echo -n '> ' |
104 |
read DebianLiveFolder |
105 |
done |
106 |
} |
107 |
|
108 |
|
109 |
|
110 |
function createTempFolders(){ |
111 |
echo -n "Creating /root/tmp folder... " |
112 |
mkdir /root/tmp 2>/dev/null |
113 |
if [ ! -d /root/tmp ];then |
114 |
echo |
115 |
echo " Error creating folder: /root/tmp" |
116 |
echo " This shouldn't be happening..." |
117 |
exit 1 |
118 |
fi |
119 |
echo 'done' |
120 |
|
121 |
echo -n "Creating temp folders... " |
122 |
rm -rf /root/tmp/clonezilla-sysresccd-"$version".iso 2>/dev/null |
123 |
rm -rf /root/tmp/syscd 2>/dev/null |
124 |
rm -rf /root/tmp/clonecd 2>/dev/null |
125 |
rm -rf /root/tmp/clonezilla-sysresccd 2>/dev/null |
126 |
mkdir /root/tmp/syscd /root/tmp/clonecd /root/tmp/clonezilla-sysresccd 2>/dev/null |
127 |
if [ ! -d /root/tmp/syscd ];then |
128 |
echo |
129 |
echo " Error creating temp folder: /root/tmp/syscd" |
130 |
exit 1 |
131 |
fi |
132 |
if [ ! -d /root/tmp/clonecd ];then |
133 |
echo |
134 |
echo " Error creating temp folder: /root/tmp/clonecd" |
135 |
exit 1 |
136 |
fi |
137 |
|
138 |
|
139 |
if [ ! -d /root/tmp/clonezilla-sysresccd ];then |
140 |
echo |
141 |
echo " Error creating temp folder: /root/tmp/clonezilla-sysresccd" |
142 |
exit 1 |
143 |
fi |
144 |
echo 'done' |
145 |
} |
146 |
|
147 |
function errorMount(){ |
148 |
echo "$1" |
149 |
cleanUp |
150 |
exit 1 |
151 |
} |
152 |
|
153 |
function errorISO(){ |
154 |
echo " Error creating the new ISO file: /root/tmp/output.iso" |
155 |
rm /root/tmp/clonezilla-sysresccd-"$outName""$version".iso 2>/dev/null |
156 |
cleanUp |
157 |
exit 1 |
158 |
} |
159 |
|
160 |
function cleanUp(){ |
161 |
echo -n " |
162 |
Cleaning up... " |
163 |
umount /root/tmp/clonecd 2>/dev/null |
164 |
umount /root/tmp/syscd 2>/dev/null |
165 |
if [ -z "$cleanUpValue" ];then |
166 |
rm -rf /root/tmp/clonezilla-sysresccd 2>/dev/null |
167 |
fi |
168 |
rm -rf /root/tmp/clonecd /root/tmp/syscd 2>/dev/null |
169 |
echo 'done' |
170 |
echo |
171 |
exit $exitStatus |
172 |
} |
173 |
|
174 |
function isnumber(){ |
175 |
if [ "$1" = "0" ];then return 0;fi |
176 |
local n="$1" |
177 |
(( n ++ )) 2>/dev/null || return 1 |
178 |
return 0 |
179 |
} |
180 |
|
181 |
function readProfiles(){ |
182 |
local n=0 |
183 |
local tmpName=${profile[0]} |
184 |
until [ -z "$tmpName" ];do |
185 |
(( n ++ )) |
186 |
tmpName=${profile[$n]} |
187 |
done |
188 |
numOfProfiles=$(( n - 1 )) |
189 |
} |
190 |
|
191 |
function applyProfile(){ |
192 |
test -z "${sysCDP[$1]}" || sysCD="${sysCDP[$1]}" |
193 |
test -z "${cloneCDP[$1]}" || cloneCD="${cloneCDP[$1]}" |
194 |
test -z "${cfgFileP[$1]}" || cfgFile="${cfgFileP[$1]}" |
195 |
test -z "${splashP[$1]}" || splash="${splashP[$1]}" |
196 |
test -z "${outNameP[$1]}" || outName="${outNameP[$1]}" |
197 |
test -z "${preparerIDP[$1]}" || preparerID="${preparerIDP[$1]}" |
198 |
test -z "${publisherP[$1]}" || publisher="${publisherP[$1]}" |
199 |
test -z "${volLabelP[$1]}" || volLabel="${volLabelP[$1]}" |
200 |
test -z "${exScriptP[$1]}" || exScript="${exScriptP[$1]}" |
201 |
# test -z "${DebianLiveFolderP[$1]}" || DebianLiveFolder="${DebianLiveFolderP[$1]}" |
202 |
} |
203 |
|
204 |
function printHelp(){ |
205 |
echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr> |
206 |
A utility to create a multi boot CD containing |
207 |
Clonezilla Live CD and |
208 |
System Rescue CD |
209 |
(they have to be downloaded seperately) |
210 |
|
211 |
Usage: $(basename $0) [options] |
212 |
Available options are: |
213 |
s show profiles and let user select profile to use |
214 |
p [number] use profile number |
215 |
f copy files only. Don't create ISO file and don't |
216 |
burn anything on CD |
217 |
nf don't copy files. Use files existing in folder |
218 |
\"/root/tmp/clonezilla-sysresccd\". |
219 |
*** Caution: Dangerous!!! *** |
220 |
i only create ISO file. Don't burn anything on CD |
221 |
b burn a previously created ISO file |
222 |
x [script] A user defined and written BASH script |
223 |
to be executed just before mastering the CD |
224 |
v print version and exit |
225 |
h print this screen and exit |
226 |
|
227 |
More information on available customization in file |
228 |
/root/.clonezilla-sysresccd/clonezilla-sysresccd.conf" |
229 |
} |
230 |
|
231 |
function printVersion(){ |
232 |
echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr> |
233 |
A utility to create a multi boot CD containing |
234 |
Clonezilla Live CD and |
235 |
System Rescue CD |
236 |
(they have to be downloaded seperately)" |
237 |
exit |
238 |
} |
239 |
|
240 |
# function decectDVDWriter(){ |
241 |
# local z |
242 |
# # local DEV0 DEV1 |
243 |
# local CDW0 CDW1 |
244 |
# local DVDW0 DVDW1 |
245 |
# |
246 |
# z=`cat /proc/sys/dev/cdrom/info 2>/dev/null | grep name | sed 's/.*name://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' ` |
247 |
# DEV0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'` |
248 |
# DEV1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'` |
249 |
# |
250 |
# z=`cat /proc/sys/dev/cdrom/info 2>/dev/null| grep 'write' | grep 'DVD-R:'| sed 's/.*DVD-R://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' ` |
251 |
# # echo z=$z |
252 |
# DVDW0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'` |
253 |
# DVDW1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'` |
254 |
# |
255 |
# |
256 |
# z=`cat /proc/sys/dev/cdrom/info 2>/dev/null| grep 'write' | grep 'CD-R:'| sed 's/.*CD-R://' | sed 's/[ ][ ]*/ /g'| sed 's/^[ ][ ]*//' ` |
257 |
# # echo z=$z |
258 |
# CDW0=`echo "$z" | sed 's/\([^ ]*\).*/\1/'` |
259 |
# CDW1=`echo "$z" | sed 's/[^ ]* *\([^ ]*\)/\1/'` |
260 |
# |
261 |
# if ! test -z "$DEV0";then |
262 |
# if [ "$DVDW0" = "1" ];then DVDRECORDER=/dev/"$DEV0";fi |
263 |
# if [ "$CDW0" = "1" ];then CDRECORDER=/dev/"$DEV0";fi |
264 |
# fi |
265 |
# |
266 |
# if ! test -z "$DEV1";then |
267 |
# if test -z "$DVDRECORDER"; then |
268 |
# if [ "$DVDW1" = "1" ];then |
269 |
# DVDRECORDER=/dev/"$DEV1" |
270 |
# fi |
271 |
# fi |
272 |
# if test -z "$CDRECORDER"; then |
273 |
# if [ "$CDW1" = "1" ];then |
274 |
# CDRECORDER=/dev/"$DEV1" |
275 |
# fi |
276 |
# fi |
277 |
# fi |
278 |
# |
279 |
# } |
280 |
|
281 |
function sourceProfiles(){ |
282 |
if [ -r /root/.clonezilla-sysresccd/profiles.conf ];then |
283 |
. /root/.clonezilla-sysresccd/profiles.conf 2>/dev/null || profilesError=1 |
284 |
profilesExist=1 |
285 |
fi |
286 |
if [ $profilesError -eq 1 ];then |
287 |
echo " Error: Your profiles configuration file \"/root/.clonezilla-sysresccd/profiles.conf\"" |
288 |
echo " has errors and cannot be used. Please fix the problem and try again" |
289 |
exit 1 |
290 |
fi |
291 |
} |
292 |
|
293 |
|
294 |
function readConfig(){ |
295 |
if [ -n "$configAlreadyRead" ];then return; fi |
296 |
test "$(whoami)" = "root" || noRoot |
297 |
[ -r /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf ] || { |
298 |
echo " Error: Your configuration file \"/root/.clonezilla-sysresccd/clonezilla-sysresccd.conf\"" |
299 |
echo " does not exist or can not be read. Please fix the problem and try again" |
300 |
exit 1 |
301 |
} |
302 |
|
303 |
. /root/.clonezilla-sysresccd/clonezilla-sysresccd.conf 2>/dev/null |
304 |
if [ $? -ne 0 ];then |
305 |
echo " Error: Your configuration file \"/root/.clonezilla-sysresccd/clonezilla-sysresccd.conf\"" |
306 |
echo " has errors and cannot be used. Please fix the problem and try again" |
307 |
exit 1 |
308 |
fi |
309 |
configAlreadyRead='true' |
310 |
} |
311 |
|
312 |
####### Script starts here ####### |
313 |
onlyBurnISO=0 |
314 |
onlyCopyFiles=0 |
315 |
onlyCreateISO=0 |
316 |
noFileCopy=0 |
317 |
exitStatus=0 |
318 |
|
319 |
profilesExist=0 |
320 |
profilesError=0 |
321 |
|
322 |
|
323 |
while getopts ":sp:bfihvn:x:" Option |
324 |
do |
325 |
case $Option in |
326 |
s) |
327 |
readConfig |
328 |
sourceProfiles |
329 |
if [ $profilesExist -eq 1 ];then |
330 |
readProfiles |
331 |
until [ ! -z "$prN" ];do |
332 |
clear |
333 |
echo "Available profiles" |
334 |
for i in `seq 0 $numOfProfiles`;do |
335 |
echo " Profile[$i]: ${profile[$i]}" |
336 |
done |
337 |
echo -n "Insert profile number ([0]-$numOfProfiles): " |
338 |
read prN |
339 |
test -z "$prN" && prN=0 |
340 |
isnumber "$prN" || prN='' |
341 |
if [ $prN -gt $numOfProfiles ] 2>/dev/null; then prN='';fi |
342 |
done |
343 |
applyProfile $prN |
344 |
else |
345 |
echo " Error: You have requested to use profiles but your profiles configuration file" |
346 |
echo " \"/root/.clonezilla-sysresccd/profiles.conf\" does not exist or cannot be read" |
347 |
exit 1 |
348 |
fi |
349 |
;; |
350 |
p) |
351 |
readConfig |
352 |
sourceProfiles |
353 |
if [ $profilesExist -eq 1 ];then |
354 |
if $(isnumber "$OPTARG");then |
355 |
applyProfile $OPTARG |
356 |
else |
357 |
echo " Error in parameter: -p $OPTARG" |
358 |
exit 1 |
359 |
fi |
360 |
else |
361 |
echo " Error: You have requested to use profile No $OPTARG but your profiles configuration file" |
362 |
echo " \"/root/.clonezilla-sysresccd/profiles.conf\" does not exist or cannot be read" |
363 |
exit 1 |
364 |
fi |
365 |
;; |
366 |
b) |
367 |
readConfig |
368 |
onlyBurnISO=1;; |
369 |
f) |
370 |
readConfig |
371 |
onlyCopyFiles=1;; |
372 |
i) |
373 |
readConfig |
374 |
onlyCreateISO=1;; |
375 |
x) |
376 |
readConfig |
377 |
[ -s "OPTARG" ] || { |
378 |
echo " Error: The specified script \"$OPTARG\" cannot be found" |
379 |
exit 1 |
380 |
} |
381 |
[ -r "$OPTARG" ] && exScript="$OPTARG" || { |
382 |
echo " Error: The specified script \"$OPTARG\" cannot be read" |
383 |
exit 1 |
384 |
};; |
385 |
h) |
386 |
printHelp |
387 |
exit |
388 |
;; |
389 |
v) |
390 |
printVersion |
391 |
;; |
392 |
n) |
393 |
readConfig |
394 |
if [ "$OPTARG" != "f" ] ;then |
395 |
echo "Error: Not a valid parameter -n$OPTARG" |
396 |
exit 1 |
397 |
fi |
398 |
noFileCopy=1 |
399 |
;; |
400 |
esac |
401 |
done |
402 |
shift $(($OPTIND - 1)) |
403 |
|
404 |
test "$(whoami)" = "root" || noRoot |
405 |
# Check input parameters |
406 |
checkInParms=0 |
407 |
checkInParms=$(( onlyBurnISO + onlyCreateISO + onlyCopyFiles + noFileCopy )) |
408 |
if [ $noFileCopy -eq 1 ] && [ $onlyCreateISO -eq 1 ];then |
409 |
okToContinue=1 |
410 |
elif [ $checkInParms -gt 1 ];then |
411 |
echo " Error: Conflicting input parameters detected..." |
412 |
exit 1 |
413 |
fi |
414 |
if [ "$outName" = "" ];then |
415 |
outFile=/root/tmp/clonezilla-sysresccd-"$version".iso |
416 |
else |
417 |
outFile=/root/tmp/clonezilla-sysresccd-"$outName"-"$version".iso |
418 |
fi |
419 |
|
420 |
if [ $onlyBurnISO -eq 0 ];then |
421 |
if [ $noFileCopy -eq 0 ];then |
422 |
while [ "$ans" != "y" ] || [ "$ans" = "Y" ];do |
423 |
test -z "$sysCD" && getSysCD |
424 |
test -z "$cloneCD" && getCloneCD |
425 |
test -z "$cfgFile" && getcfgFile |
426 |
test -z "$exScript" && getScript |
427 |
# test -z "$DebianLiveFolder" && getDebianLiveFolder |
428 |
clear |
429 |
# echo -n "Current settings: |
430 |
# System Rescue CD: $sysCD |
431 |
# Clonezilla Live CD: $cloneCD |
432 |
# isolinux.cfg to use: $cfgFile |
433 |
# Debian Live folder: $DebianLiveFolder |
434 |
# script to execute: $exScript |
435 |
# |
436 |
# Is this correct? (y/[n]): " |
437 |
|
438 |
echo -n "Current settings: |
439 |
System Rescue CD: $sysCD |
440 |
Clonezilla Live CD: $cloneCD |
441 |
isolinux.cfg to use: $cfgFile |
442 |
script to execute: $exScript |
443 |
|
444 |
Is this correct? (y/[n]): " |
445 |
|
446 |
read ans |
447 |
if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then |
448 |
sysCD='' |
449 |
cloneCD='' |
450 |
cfgFile='' |
451 |
fi |
452 |
done |
453 |
ans='' |
454 |
while [ 1 ];do |
455 |
test -z "$preparerID" && getPreparer |
456 |
test -z "$publisher" && getPublisher |
457 |
test -z "$volLabel" && getvolLabel |
458 |
clear |
459 |
echo -n "Current CD info: |
460 |
Preparer: $preparerID |
461 |
Publisher: $publisher |
462 |
Volume label: $volLabel |
463 |
|
464 |
Is this correct? (y/[n]): " |
465 |
read ans |
466 |
if [ "$ans" = "n" ] || [ "$ans" = "N" ] || [ "$ans" = "" ];then |
467 |
preparerID='' |
468 |
publisher='' |
469 |
volLabel='' |
470 |
fi |
471 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then break;fi |
472 |
done |
473 |
trap cleanUp 2 |
474 |
clear |
475 |
echo "$(basename $0) - v $version - Spiros Georgaras <sng@hellug.gr> |
476 |
" |
477 |
createTempFolders |
478 |
|
479 |
echo -n "Mounting ISO files... " |
480 |
mount "$sysCD" /root/tmp/syscd -o loop || errorMount ' Error mounting "System Rescue CD" file' |
481 |
mount "$cloneCD" /root/tmp/clonecd -o loop || errorMount ' Error mounting Clonezilla" file' |
482 |
echo 'done' |
483 |
echo -n "Copying files... " |
484 |
cp -RL /root/tmp/syscd/* /root/tmp/clonezilla-sysresccd |
485 |
cp -RL /root/tmp/clonecd/* /root/tmp/clonezilla-sysresccd |
486 |
echo 'done' |
487 |
|
488 |
|
489 |
# echo -n "Extracting boot programs... " |
490 |
echo "Extracting boot programs... " |
491 |
cd /root/tmp/clonezilla-sysresccd/bootprog |
492 |
mkdir tmp |
493 |
cp *zip tmp |
494 |
unzip -x sys*zip win32/syslinux.exe |
495 |
mv win32/* . |
496 |
rmdir win32 |
497 |
unzip -x gr* gr*/grub.exe |
498 |
mv gr*/grub.exe . |
499 |
rm -rf grub4dos* |
500 |
cp tmp/* . |
501 |
rm -rf tmp |
502 |
# echo 'done' |
503 |
|
504 |
if [ ! -z "$splash" ];then |
505 |
echo -n "Copying new spalsh screen... " |
506 |
cp -L "$splash" /root/tmp/clonezilla-sysresccd/isolinux/ocswp.png |
507 |
echo 'done' |
508 |
else |
509 |
cp -L /root/.clonezilla-sysresccd/files/default-ocswp.png /root/tmp/clonezilla-sysresccd/isolinux/ocswp.png |
510 |
fi |
511 |
|
512 |
echo -n "Copying Super Grub Disk... " |
513 |
cp -L /root/.clonezilla-sysresccd/files/sgd.img /root/tmp/clonezilla-sysresccd/bootdisk/sgd.img && echo 'done' || { |
514 |
echo |
515 |
echo |
516 |
echo |
517 |
echo " Error: Copying Super Grub Disk failed!!!" |
518 |
echo |
519 |
echo " Please make sure that the image file exists" |
520 |
echo " Image file: /root/tmp/clonezilla-sysresccd/bootdisk/sgd.img" |
521 |
echo |
522 |
echo |
523 |
cleanUp |
524 |
exit 1 |
525 |
} |
526 |
if [ -e /root/.clonezilla-sysresccd/files/sgd2.img ];then |
527 |
echo -n "Copying Super Grub Disk 2... " |
528 |
cp -L /root/.clonezilla-sysresccd/files/sgd2.img /root/tmp/clonezilla-sysresccd/bootdisk/grubdisk.img && echo 'done' || { |
529 |
echo |
530 |
echo |
531 |
echo |
532 |
echo " Error: Copying Super Grub Disk 2 failed!!!" |
533 |
echo |
534 |
echo " Please make sure that the image file exists" |
535 |
echo " Image file: /root/tmp/clonezilla-sysresccd/bootdisk/sgd2.img" |
536 |
echo |
537 |
echo |
538 |
cleanUp |
539 |
exit 1 |
540 |
} |
541 |
fi |
542 |
echo -n "Copying new cfg file(s)... " |
543 |
if [ -z $(echo "$cfgFile" | grep 'cfg$') ];then |
544 |
tar -C /root/tmp/clonezilla-sysresccd -xzhf /root/.clonezilla-sysresccd/files/menu-iso.tar.gz |
545 |
else |
546 |
cp -L "$cfgFile" /root/tmp/clonezilla-sysresccd/isolinux/isolinux.cfg |
547 |
fi |
548 |
echo 'done' |
549 |
|
550 |
echo -n "Creating folder restorecd... " |
551 |
WHERE="$(pwd)" |
552 |
mkdir /root/tmp/clonezilla-sysresccd/restorecd 2>/dev/null |
553 |
cd /root/.clonezilla-sysresccd/files |
554 |
cp -L pre* ocs-iso what-cd continue-multi-cd isolinux-restore-cd.cfg \ |
555 |
isolinux-restore-cd-ram.cfg menu-iso.tar.gz doc.tar.gz imginfo imgconvert cust-menu /root/tmp/clonezilla-sysresccd/restorecd |
556 |
cp -L default-restore-ocswp.png /root/tmp/clonezilla-sysresccd/restorecd/ocswp.png |
557 |
cp sbminst /root/tmp/clonezilla-sysresccd/restorecd |
558 |
|
559 |
# Copy Smart Boot Manager and rawrite-fdimage to bootdisk |
560 |
mkdir /root/tmp/clonezilla-sysresccd/rawrite |
561 |
cp raw* fd* *dll /root/tmp/clonezilla-sysresccd/rawrite |
562 |
cp sbm.img /root/tmp/clonezilla-sysresccd/bootdisk |
563 |
cd "$DebianLiveFolder" 2>/dev/null || debFilesError=yes |
564 |
# if [ -s files.tar.gz ];then |
565 |
# cp -L files.tar.gz /root/tmp/clonezilla-sysresccd/restorecd/ 2>/dev/null || debFilesError=yes |
566 |
# else |
567 |
# [ -e "$DebianLiveFolder"/unifont.bgf ] || { |
568 |
# uniFontCopied=yes |
569 |
# cp -L /root/.clonezilla-sysresccd/files/unifont.bgf "$DebianLiveFolder" |
570 |
# } |
571 |
# tar chzf /root/tmp/clonezilla-sysresccd/restorecd/files.tar.gz unifont.bgf debian-live-for-ocs.iso 2>/dev/null || debFilesError=yes |
572 |
# [ -z "$uniFontCopied" ] || rm "$DebianLiveFolder"/unifont.bgf |
573 |
# fi |
574 |
# [ -z "$debFilesError" ] || { |
575 |
# echo |
576 |
# echo |
577 |
# echo |
578 |
# echo " Error: Copying files.tar.gz failed!!!" |
579 |
# echo |
580 |
# echo " Please make sure that the variable DebianLiveFolder points either to" |
581 |
# echo " the folder where the files unifont.bgf and debian-live-for-ocs.iso" |
582 |
# echo " reside, or the files files.tar.gz (which contains unifont.bgf and" |
583 |
# echo " debian-live-for-ocs.iso) can be found" |
584 |
# echo |
585 |
# echo |
586 |
# echo |
587 |
# cleanUp |
588 |
# exit 1 |
589 |
# } |
590 |
cd "$WHERE" |
591 |
echo "done" |
592 |
|
593 |
echo -n "Copying documentation files... " |
594 |
cd /root/tmp/clonezilla-sysresccd |
595 |
tar xzhf /root/tmp/clonezilla-sysresccd/restorecd/doc.tar.gz |
596 |
echo 'done' |
597 |
|
598 |
if [ ! -z "$exScript" ];then |
599 |
# echo -n "Executing external script: \"$exScript\"... " |
600 |
echo -n "Executing external script... " |
601 |
. "$exScript" || { |
602 |
echo |
603 |
echo |
604 |
echo |
605 |
echo " Error: The execution of the script failed!!!" |
606 |
echo " Please correct it and try again" |
607 |
echo |
608 |
echo " Script: \"$exScript\"" |
609 |
cleanUp |
610 |
exit 1 |
611 |
} |
612 |
fi |
613 |
echo 'done' |
614 |
# echo |
615 |
# echo |
616 |
# echo |
617 |
else |
618 |
trap cleanUp 2 |
619 |
cleanUpValue=1 |
620 |
if [ ! -d /root/tmp/clonezilla-sysresccd ];then |
621 |
echo " Error accessing folder \"/root/tmp/clonezilla-sysresccd\"" |
622 |
exitStatus=1 |
623 |
cleanUp |
624 |
fi |
625 |
fi |
626 |
|
627 |
# move extra folders into utils |
628 |
mv /root/tmp/clonezilla-sysresccd/rawrite /root/tmp/clonezilla-sysresccd/bootprog /root/tmp/clonezilla-sysresccd/utils |
629 |
mv /root/tmp/clonezilla-sysresccd/version /root/tmp/clonezilla-sysresccd/SystemRescueCD-Version |
630 |
|
631 |
if [ $onlyCopyFiles -eq 1 ];then |
632 |
cleanUpValue=1 |
633 |
# echo |
634 |
# echo |
635 |
echo "Both CDs have been copyied in: /root/tmp/clonezilla-sysresccd" |
636 |
cleanUp |
637 |
fi |
638 |
echo |
639 |
echo -n "Ready to create the new ISO file. |
640 |
|
641 |
************************************************************************ |
642 |
Ready to master your CD. If you want to alter any files contained |
643 |
in the CD, now is the right time. |
644 |
CD root is \"/root/tmp/clonezilla-sysresccd\" |
645 |
|
646 |
When you are done |
647 |
*********************************************************************** |
648 |
|
649 |
Press ENTER to continue... " |
650 |
read |
651 |
find /root/tmp/clonezilla-sysresccd -name "*~" -exec rm '{}' ';' |
652 |
# 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" /root/tmp/clonezilla-sysresccd || errorISO |
653 |
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" /root/tmp/clonezilla-sysresccd || errorISO |
654 |
echo " |
655 |
Done creating new ISO file |
656 |
The file is saved as $outFile" |
657 |
ans=c |
658 |
chIsoHyb=`type isohybrid 2>/dev/null` |
659 |
if [ -n "$chIsoHyb" ];then |
660 |
echo -n "Isohybriding $outFile... " |
661 |
isohybrid "$outFile" |
662 |
echo 'done' |
663 |
fi |
664 |
|
665 |
echo ' |
666 |
|
667 |
' |
668 |
|
669 |
else |
670 |
while [ ! -r "$outFile" ];do |
671 |
echo 'Insert "clonezilla-resccd" ISO file name' |
672 |
echo -n "> " |
673 |
read outFile |
674 |
done |
675 |
ans=y |
676 |
fi |
677 |
|
678 |
if [ $onlyCreateISO -eq 1 ];then ans=n;fi |
679 |
|
680 |
while [ 1 ];do |
681 |
if [ "$ans" = "" ];then ans=y;fi |
682 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi |
683 |
echo -n "Do you want to burn this ISO file? ([y]/n): " |
684 |
read ans |
685 |
done |
686 |
burnISO=0 |
687 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then |
688 |
echo |
689 |
echo "File to burn: $outFile" |
690 |
echo |
691 |
burnISO=1 |
692 |
# decectDVDWriter |
693 |
|
694 |
# CDRECORDER=$(sh /root/.clonezilla-sysresccd/files/what-cd -wb) |
695 |
chmod +x /root/.clonezilla-sysresccd/files/what-cd |
696 |
CDRECORDER=$(/root/.clonezilla-sysresccd/files/what-cd -wb) |
697 |
chmod -x /root/.clonezilla-sysresccd/files/what-cd |
698 |
|
699 |
echo CD redorder found: "$CDRECORDER" |
700 |
ans='' |
701 |
until [ "$ans" = "y" ] || [ "$ans" = "Y" ];do |
702 |
echo -n "Is this correct? ([y]/n): " |
703 |
read ans |
704 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "" ];then |
705 |
ans='y' |
706 |
cdW="$CDRECORDER" |
707 |
else |
708 |
echo -n "Insert your CD redorder device name ($CDRECORDER): " |
709 |
read cdW |
710 |
if [ "$cdW" = "" ];then cdW="$CDRECORDER";fi |
711 |
echo CD redorder: "$cdW" |
712 |
fi |
713 |
done |
714 |
fi |
715 |
|
716 |
if [ $burnISO -eq 1 ];then |
717 |
ans=c |
718 |
while [ 1 ];do |
719 |
if [ "$ans" = "" ];then ans="y";fi |
720 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi |
721 |
echo -n "Does the CD need blanking (RW-CD)? ([y]/n): " |
722 |
read ans |
723 |
done |
724 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then |
725 |
blankCD=1 |
726 |
else |
727 |
blankCD=0 |
728 |
fi |
729 |
ans=c |
730 |
while [ 1 ];do |
731 |
if [ "$ans" = "" ];then ans="y";fi |
732 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ] || [ "$ans" = "n" ] || [ "$ans" = "N" ];then break;fi |
733 |
echo -n "Do you wan to to start a multi-session CD? ([y]/n): " |
734 |
read ans |
735 |
done |
736 |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ];then |
737 |
MULTI='-multi' |
738 |
else |
739 |
MULTI='' |
740 |
fi |
741 |
|
742 |
clear |
743 |
echo "Ready to burn the ISO file to CD. Please load a (re)writable CD |
744 |
in $cdW and Press ENTER to continue... " |
745 |
read |
746 |
echo -n "Unmounting CD... " |
747 |
while [ $(mount |grep "$cdW" | wc -l) -gt 0 ] ;do |
748 |
umount "$cdW" 2>/dev/null |
749 |
done |
750 |
echo 'done' |
751 |
if [ $blankCD -eq 1 ];then |
752 |
echo "Blanking CD... |
753 |
-----------" |
754 |
cdrecord dev="$cdW" blank=fast -eject || errorMount ' |
755 |
|
756 |
Error: Blanking procedure failed... |
757 |
|
758 |
|
759 |
' |
760 |
fi |
761 |
echo |
762 |
echo "Burinng ISO file |
763 |
----------------" |
764 |
cdrecord -v dev="$cdW" driveropts=burnfree "$MULTI" -eject "$outFile" || errorMount ' |
765 |
|
766 |
Error: Burning procedure failed... |
767 |
|
768 |
|
769 |
' |
770 |
fi |
771 |
cleanUp |