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