/[clonezilla-sysresccd]/trunk/create-clonezilla-sysresccd/files/ocs-iso
ViewVC logotype

Contents of /trunk/create-clonezilla-sysresccd/files/ocs-iso

Parent Directory Parent Directory | Revision Log Revision Log


Revision 190 - (show annotations)
Sun Aug 26 14:25:43 2012 UTC (9 years, 3 months ago) by sng
File size: 41984 byte(s)
updating cfg files (removed rannish and dban from tools),
changing menu selection color, renamed pack-them to 
update-cfgs (script to create a tarball containing CFGs

1 #!/bin/bash
2 # Author: Steven Shiau <steven _at_ nchc org tw>
3 # License: GPL
4 # Description: This program will put Debian Live minimal + DRBL/Clonezilla program into a bootable iso file.
5
6 #
7 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/opt/drbl/}"
8
9 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
10 . $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf
11 . $DRBL_SCRIPT_PATH/sbin/ocs-functions
12
13 # other default settings
14 # If insert_mode=prog_only, only copy DRBL/Clonezilla programs only, no ocs images.
15 insert_mode="prog_and_img"
16 img_size_sum=0
17 # Default to output the result to iso file, another vaule is cdwriter.
18 output_mode="file"
19 # If there is any file larger then 2GB, we need to turn on -allow-limited-size option for genisoimage. Actually it can be 4GB. Anyway, here we use 2GB. (man genisoimage for more details)
20 iso9660_file_size_limit="2000M" # For command "find" to find the file size (unit: Bytes)
21
22 # Excluding list for mkisofs
23 # We will create it like this:
24 # -x $DEBIAN_ISO_TMP/isolinux -x $DEBIAN_ISO_TMP/md5sum.txt -x $DEBIAN_ISO_TMP/casper/memtest
25 # "home" should also be excluded since if it exists, it will conflict with the real home later we will merge. Ref: https://sourceforge.net/forum/message.php?msg_id=7599463 Thanks to Andrew Bloxom for this idea.
26 mkiso_exclude_list_1="isolinux syslinux md5sum.txt doc live etc pkg ocs-live.d utils"
27 mkiso_exclude_list_2="home" # This should not be a duplicated count.
28 mkiso_exclude_list="$mkiso_exclude_list_1 $mkiso_exclude_list_2"
29 # Flag to put EFI booting image in iso
30 enabled_EFI=""
31
32 #
33 prog="$(basename $0)"
34 prog_option="$*"
35
36 # functions
37 USAGE() {
38 echo "Usage:"
39 echo "To put clonezilla image into live CD:"
40 echo "$prog [OPTION] CLONEZILLA_IMAGE_NAME"
41 echo "OPTION:"
42 language_help_prompt_by_idx_no
43 echo "-a, --file-name-prefix NAME Assign the output file name as NAME.iso. $0 will auto append '.iso' in the end of filename."
44 echo "-b, --bg-mode [text|graphic] Assign the background of boot menu. Default is graphic"
45 echo "-m, --custom-ocs PATH/custom-ocs Use the customized ocs program 'custom-ocs' instead of the default one. Note! PATH should be assigned so that it can be found. This is advanced mode."
46 echo "-e, --extra-param PARAM Assign extra parameter PARAM for clonezilla live to run, PARAM will be appended when run in ocs-live-restore or ocs."
47 echo "-g, --ocs-live-language LANGUAGE Assign the language when using clonezilla live, available languages are en_US.UTF-8, zh_TW.UTF-8 "
48 echo "-k, --ocs-live-keymap KEYMAP Assign the keyboard when using clonezilla live. Use full path for KEYMAP, for example: /usr/share/keymaps/i386/azerty/fr.kmap.gz. If 'NONE' is used, the default one (US keyboard) will be use."
49 echo "-t, --ocs-live-batch Set clonezilla live to run in batch mode, usually it's for restoring. If this mode is set, some dialog question will be ignored."
50 echo "-i, --assign-version-no NO Assign the version no as NO instead of date. This only works when using with option -s."
51 echo "-j, --debian-iso ISO_FILE Assign Debian live template iso file name as ISO_FILE to be used to create Clonezilla live."
52 echo "-n, --debian-iso-etc-url-path ISO_ETC_FILE_URL Assign the url (Ex. http://localhost/clonezilla-live/template-iso) for Debian live template iso file as ISO_FILE_URL to be used to create Clonezilla live."
53 echo "-p, --image-path Assign the clonezilla image path where CLONEZILLA_IMAGE_NAME exists. Default = $ocsroot"
54 echo "-s, --skip-image Do not include any clonezilla image. The is used to created a live CD with DRBL/Clonezilla programs only."
55 echo "-f, --on-the-fly DEV Write the output to CD/DVD writer DEV (such as /dev/hdc) instead of creating an ISO file."
56 echo "-o, --normal-menu When a clonezilla image is inserted, by default only restore menu will be shown in the created ISO file. If you want to show normal menu, i.e. with save and restore menu, use this one."
57 echo "-x, --extra-boot-param EXTRA_PARAM Assign extra boot parameter EXTRA_PARAM for clonezilla live kernel to read. These parameters are the same with that from live-initramfs. Ex. \"noprompt\" can be use to not prompt to eject the CD on reboot."
58 echo "-u, --include-dir DIR Include a dir in the target iso file."
59 echo "--ocs-live-boot-menu-option EXTRA_OPTION Assign an extra option for ocs-live-boot-menu. //NOTE// Do not put '-' in this EXTRA_OPTION, $0 will add that automatically. e.g. if you want to add -s1 for ocs-live-boot-menu to run, use 's1' only."
60 echo "$prog will download a template Debian live CD for clonezilla iso file if ncecessary. You can also download it by yourself, and put it in the working directory when you run $prog. If you want to create that template iso file in Debian Etch, run create-debian-live."
61 echo "NOTE! Due to the limitation in mkisofs, this program does not work in clonezilla image file larger than $FILE_LIMIT MB."
62 echo "Ex:"
63 echo "To put clonezilla image sarge-ocs (located in /home/partimag in clonezilla server) to Live CD, you can run:"
64 echo " $prog sarge-ocs"
65 echo "To put more images, just append them, such as:"
66 echo " $prog sarge-ocs etch-ocs"
67 echo "To create a Live CD with DRBL/Clonezilla programs:"
68 echo " $prog -s"
69 echo "To specify the Debian live template iso, run like this:"
70 echo " $prog -j debian-live-for-ocs-1.0.1-3.iso -n http://localhost/clonezilla-live/template-iso/testing -s"
71 echo "To put clonezilla image sarge-ocs, etch-ocs to to Live CD, and write it to cd writer /dev/hdc, you can run:"
72 echo " $prog -f /dev/hdc sarge-ocs etch-ocs"
73 echo "To create an iso file for restoring with clonezilla image sarge-r5 builtin, and make it boot then restore the image sarge-r5 to hda in unattended mode (Only confirmation in the beginning), you can run:"
74 echo " $prog -g en_US.UTF-8 -t -k NONE -e \"-b -c restoredisk sarge-r5 hda\" sarge-r5"
75 echo "To create an iso file to run your own custom-ocs program:"
76 echo " $prog -g en_US.UTF-8 -k NONE -s -m ./custom-ocs"
77 }
78 #
79 check_file_size_in_ocs_image() {
80 local img_path="$1"
81 local size_t
82 local size_t_tot=0
83 for ifile in $img_path/*; do
84 size_t="$(du -Lms $ifile | awk -F" " '{print $1}')"
85 size_t_tot=$((size_t_tot+size_t))
86 done
87 if [ "$size_t_tot" -gt "$FILE_LIMIT" ]; then
88 ################################################################################
89 # Section edited by S. Georgaras <sng@hellug.gr>
90
91 # [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
92 # echo "$ifile size ($size_t MB) is too large! $msg_mkisofs_unable_process_that"
93 # [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
94 # echo "$msg_are_u_sure_u_want_to_continue"
95 # echo -n "[y/N] "
96 # read cont_ans
97 # case "$cont_ans" in
98 # y|Y|[yY][eE][sS])
99 # echo $msg_ok_let_do_it
100 # ;;
101 # *)
102 # echo "Abort!"
103 # exit 2
104 # esac
105 whiptail --backtitle Clonezilla-SysRescCD --title ' Excessive Image Size ' --yesno "The image file \"$(basename ${1})\" is too large ($size_t_tot MB) and
106 $msg_mkisofs_unable_process_that
107
108 $msg_are_u_sure_u_want_to_continue" 0 60
109 if [ $? -eq 1 ];then
110 exit 1
111 fi
112 # going2RAM="prog_only"
113 break
114 fi
115 # done
116 ################################################################################
117 }
118
119 #
120 clean_tmp_dir() {
121 if [ -d "$DEBIAN_ISO_TMP" -a -n "$DEBIAN_ISO_TMP" ]; then
122 # Force to unmount, althouth it might have beed unmounted, or maybe not (ctrl-c interrupt).
123 umount $DEBIAN_ISO_TMP &>/dev/null
124 rmdir $DEBIAN_ISO_TMP &>/dev/null
125 fi
126 if [ -d "$ISOSYSLNX_TMP" -a -n "$(echo $ISOSYSLNX_TMP | grep "ocs_isosyslnx")" ]; then
127 rm -rf $ISOSYSLNX_TMP
128 fi
129 if [ -d "$WD_TMP" -a -n "$(echo $WD_TMP | grep "ocs_iso_wd")" ]; then
130 rm -rf $WD_TMP
131 fi
132 } # End of clean_tmp_dir
133
134 #
135 check_if_root
136
137 # default settings:
138 ocs_live_batch="no"
139 custom_ocs=""
140 normal_menu_with_insert_image="no"
141 template_mode=""
142
143 # Parse command-line options
144 while [ $# -gt 0 ]; do
145 case "$1" in
146 -a|--file-name-prefix)
147 shift
148 if [ -z "$(echo $1 |grep ^-.)" ]; then
149 # skip the -xx option, in case
150 target_iso_prefix="$1"
151 shift
152 fi
153 [ -z "$target_iso_prefix" ] && USAGE && exit 1
154 ;;
155 -l|--language)
156 shift
157 if [ -z "$(echo $1 |grep ^-.)" ]; then
158 # skip the -xx option, in case
159 specified_lang="$1"
160 shift
161 fi
162 [ -z "$specified_lang" ] && USAGE && exit 1
163 ;;
164 -b|--bg-mode)
165 shift
166 if [ -z "$(echo $1 |grep ^-.)" ]; then
167 # skip the -xx option, in case
168 bg_mode="$1"
169 shift
170 fi
171 [ -z "$bg_mode" ] && USAGE && exit 1
172 ;;
173 -m|--custom-ocs)
174 shift
175 if [ -z "$(echo $1 |grep ^-.)" ]; then
176 # skip the -xx option, in case
177 custom_ocs="$1"
178 shift
179 fi
180 [ -z "$custom_ocs" ] && USAGE && exit 1
181 ;;
182 -e|--extra-param)
183 shift
184 # extra param might begin with -, i.e. Ex. -b -p true. Therefore we should not skip this.
185 ocs_live_extra_param="$1"
186 shift
187 [ -z "$ocs_live_extra_param" ] && USAGE && exit 1
188 ;;
189 -i|--assign-version-no)
190 shift
191 if [ -z "$(echo $1 |grep ^-.)" ]; then
192 # skip the -xx option, in case
193 version_no="$1"
194 shift
195 fi
196 [ -z "$version_no" ] && USAGE && exit 1
197 ;;
198 -g|--ocs-live-language)
199 shift
200 if [ -z "$(echo $1 |grep ^-.)" ]; then
201 # skip the -xx option, in case
202 ocs_lang="$1"
203 shift
204 fi
205 [ -z "$ocs_lang" ] && USAGE && exit 1
206 ;;
207 -k|--ocs-live-keymap)
208 shift
209 if [ -z "$(echo $1 |grep ^-.)" ]; then
210 # skip the -xx option, in case
211 ocs_live_keymap="$1"
212 shift
213 fi
214 [ -z "$ocs_live_keymap" ] && USAGE && exit 1
215 ;;
216 -p|--image-path)
217 shift
218 if [ -z "$(echo $1 |grep ^-.)" ]; then
219 # skip the -xx option, in case
220 image_path="$1"
221 shift
222 fi
223 [ -z "$image_path" ] && USAGE && exit 1
224 ;;
225 -s|--skip-image)
226 insert_mode="prog_only"
227 #
228 # Section inserted by S. Georgaras <sng@hellug.gr>
229 # Variable to know that -s was actually used
230 #
231 ORIGINAL_INSERT_MODE='-o'
232 #
233 ##################################################
234 shift ;;
235 -t|--ocs-live-batch)
236 ocs_live_batch="yes"
237 shift ;;
238 -o|--normal-menu)
239 normal_menu_with_insert_image="yes"
240 shift ;;
241 -f|--on-the-fly)
242 shift
243 output_mode="cdwriter"
244 if [ -z "$(echo $1 |grep ^-.)" ]; then
245 # skip the -xx option, in case
246 output_dev="$1"
247 shift
248 fi
249 [ -z "$output_dev" ] && USAGE && exit 1
250 ;;
251 -j|--debian-iso)
252 shift
253 if [ -z "$(echo $1 |grep ^-.)" ]; then
254 # skip the -xx option, in case
255 DEBIAN_ISO="$1"
256 template_mode="from-download-live-media"
257 shift
258 fi
259 [ -z "$DEBIAN_ISO" ] && USAGE && exit 1
260 ;;
261 -n|--debian-iso-etc-url-path)
262 shift
263 if [ -z "$(echo $1 |grep ^-.)" ]; then
264 # skip the -xx option, in case
265 DEBIAN_ISO_ETC_PATH="$1"
266 shift
267 fi
268 [ -z "$DEBIAN_ISO_ETC_PATH" ] && USAGE && exit 1
269 ;;
270 -x|--extra-boot-param)
271 shift
272 if [ -z "$(echo $1 |grep ^-.)" ]; then
273 # skip the -xx option, in case
274 live_extra_boot_param="$1"
275 shift
276 fi
277 [ -z "$live_extra_boot_param" ] && USAGE && exit 1
278 ;;
279 --ocs-live-boot-menu-option)
280 shift
281 if [ -z "$(echo $1 |grep ^-.)" ]; then
282 # skip the -xx option, in case
283 ocs_live_boot_menu_option="$1"
284 shift
285 fi
286 [ -z "$ocs_live_boot_menu_option" ] && USAGE && exit 1
287 ;;
288 -u|--include-dir)
289 shift
290 if [ -z "$(echo $1 |grep ^-.)" ]; then
291 # skip the -xx option, in case
292 include_dir="$1"
293 include_dir_graft_point="$include_dir=$include_dir"
294 shift
295 fi
296 [ -z "$include_dir" ] && USAGE && exit 1
297 ;;
298 -*) echo "${0}: ${1}: invalid option" >&2
299 USAGE >& 2
300 exit 2 ;;
301 *) break ;;
302 esac
303 done
304 ocs_image="$*"
305 # strip the / to avoid problem
306 ocs_image="$(echo $ocs_image | sed -e "s|/||g")"
307
308 [ -z "$ocs_image" -a "$insert_mode" = "prog_and_img" ] && USAGE && exit 1
309 [ -z "$image_path" ] && image_path=$ocsroot
310 [ -z "$bg_mode" ] && bg_mode="$BG_MODE_DEF"
311 [ -z "$DEBIAN_ISO_ETC_PATH" ] && DEBIAN_ISO_ETC_PATH="$DEBIAN_ISO_ETC_PATH_DEF"
312 [ -z "$DEBIAN_ISO" ] && DEBIAN_ISO="$DEBIAN_ISO_DEF"
313 [ -n "$ocs_live_boot_menu_option" ] && ocs_live_boot_menu_option="-$ocs_live_boot_menu_option"
314 DEBIAN_ISO_URL="$DEBIAN_ISO_ETC_PATH/$DEBIAN_ISO"
315 md5_file_url="$DEBIAN_ISO_ETC_PATH/$md5_file"
316
317 #
318 ask_and_load_lang_set $specified_lang
319
320 #
321 if ! type genisoimage &>/dev/null; then
322 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
323 echo "Program genisoimage not found!"
324 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
325 echo "$msg_program_stop"
326 exit 1
327 fi
328
329 # Check if genisoimage support -efi-boot option
330 if [ -n "$(LC_ALL=C genisoimage --help 2>&1 | grep -E -- "-efi-boot")" ]; then
331 enabled_EFI="true"
332 else
333 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
334 echo "Warning! Setting EFI boot image name is not supported in genisoimage!"
335 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
336 enabled_EFI="false"
337 fi
338
339 if [ "$output_mode" = "cdwriter" -a type wodim &>/dev/null ]; then
340 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
341 echo "Program wodim is not aviailable! You have to install it."
342 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
343 echo "$msg_program_stop"
344 exit 1
345 fi
346
347 if [ -n "$custom_ocs" -a ! -e "$custom_ocs" ]; then
348 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
349 echo "File $custom_ocs not found!"
350 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
351 echo "$msg_program_stop"
352 exit 1
353 fi
354
355 # Format the lang variable. This is for clonezilla live running, not for ocs-iso.
356 case "$ocs_lang" in
357 zh_TW.BIG5|zh_TW.big5|tw.BIG5)
358 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
359 echo "For Traditional Chinese locale, Clonezilla live only supports unicode (zh_TW.UTF-8), not Big5 encoding (zh_TW.BIG5). Force to use UTF-8 for Traditional Chinese in Clonezilla live."
360 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
361 ocs_lang="zh_TW.UTF-8" ;;
362 zh_TW.UTF-8|zh_TW.utf8|tw.UTF-8|tw.utf8)
363 ocs_lang="zh_TW.UTF-8" ;;
364 esac
365
366 # Decide where is the $LIVE_MEDIA
367 get_live_media_mnt_point &>/dev/null
368
369 # Some temp dirs
370 # Thanks to Orgad Shaneh. Since the temp files from Clonezilla live won't take too much space, we just use /tmp/ to store these temp files.
371 #if [ -w ./ ]; then
372 # ISOSYSLNX_TMP="$(mktemp -d ./isolnx.XXXXXX)"
373 # WD_TMP="$(mktemp -d ./iso_wd.XXXXXX)"
374 #else
375 # ISOSYSLNX_TMP="$(mktemp -d /tmp/isolnx.XXXXXX)"
376 # WD_TMP="$(mktemp -d /tmp/iso_wd.XXXXXX)"
377 #fi
378 ISOSYSLNX_TMP="$(mktemp -d /tmp/ocs_isosyslnx.XXXXXX)"
379 WD_TMP="$(mktemp -d /tmp/ocs_iso_wd.XXXXXX)"
380
381 #
382 trap clean_tmp_dir HUP INT QUIT TERM EXIT
383
384 # Try to find if it is running on live cd/usb already
385 if [ -z "$template_mode" ]; then
386 if [ -n "$LIVE_MEDIA" ]; then
387 # It's running from Clonezilla live media, use the existing resource
388 template_mode="from-booting-live-media"
389 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
390 echo "Found a Clonezilla live media... Will use that as a template..."
391 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
392 else
393 template_mode="from-downloaded-live-media"
394 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
395 echo "No Clonezilla live media was found... Will use the downloaded template from Clonezilla repository..."
396 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
397 fi
398 fi
399
400 if [ "$template_mode" = "from-downloaded-live-media" ]; then
401 if [ ! -f "$DEBIAN_ISO" ]; then
402 echo "We need Debian live CD for Clonnezilla to create clonezilla cd."
403 echo "Downloadling the iso file from $DEBIAN_ISO_URL..."
404 wget $DEBIAN_ISO_URL
405 get_iso_rc=$?
406 # validate it
407 if [ "$get_iso_rc" -eq 0 ]; then
408 echo -n "Validating $DEBIAN_ISO... "
409 md5_tmp="$(mktemp -d /tmp/isomd5.XXXXX)"
410 # wget http://opensource.nchc.org.tw/drbl-core/iso/MD5SUMS
411 echo -n "Downloading $md5_file_url... "
412 wget $wget_opt -P "$md5_tmp" $md5_file_url
413 if ! grep -w "$DEBIAN_ISO" $md5_tmp/MD5SUMS | md5sum -c; then
414 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
415 echo "$DEBIAN_ISO is broken! Something went wrong! Try to remove $DEBIAN_ISO and run this program again."
416 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
417 echo "$msg_program_stop"
418 exit 1
419 fi
420 else
421 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
422 echo "Unable to download $DEBIAN_ISO_URL!"
423 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
424 echo "$msg_program_stop"
425 exit 1
426 fi
427 else
428 echo "A template iso ($DEBIAN_ISO) was found!"
429 fi
430 fi
431
432 allow_limited_size_flag=""
433 if [ "$insert_mode" = "prog_and_img" ]; then
434 # 2 cases:
435 # (1) normal_menu_with_insert_image=no, i.e. only restore menu. ocs-live-restore is the main program.
436 # If it's not batch mode for clonezilla live (especially for restoring), by default we have to append "-x --restore-only", and especially before any other parameters, so that ocs-sr will run like:
437 # ocs-sr -l $ocs_lang -p true -x --restore-only -b restoredisk sarge_image
438 # (2) normal_menu_with_insert_image=yes, i.e. normal menu. ocs-live-general is the main program. Threfore no extra param.
439 if [ "$ocs_live_batch" = "no" ]; then
440 case "$normal_menu_with_insert_image" in
441 no) ocs_live_extra_param="-x --restore-only $ocs_live_extra_param" ;;
442 yes) ocs_live_extra_param="" ;;
443 esac
444 fi
445
446 echo "Creating clonezilla ISO with image(s) $ocs_image from $image_path..."
447 # here we put ocs-live-restore as ocs-live inside live cd, and it will be shown as /$LIVE_MEDIA/ocs-live when using in running live CD.
448 # use the 1st image name as iso filename
449 iso_label_tag="$(echo $ocs_image | awk -F" " '{print $1}')"
450 # mkisofs only allow 32 characters for volume ID
451 iso_label_tag="${iso_label_tag:0:31}"
452 ocs_imgs_with_abs_path=""
453 for im in $ocs_image; do
454 if [ ! -d "$image_path/$im" ]; then
455 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
456 echo "$image_path/$im $msg_NOT_found!"
457 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
458 echo "$msg_program_stop"
459 exit 1
460 fi
461 if [ -z "$allow_limited_size_flag" ]; then
462 if [ -n "$(find $image_path/$im -size +${iso9660_file_size_limit} -print)" ]; then
463 allow_limited_size_flag="yes"
464 fi
465 fi
466 # we will put all the images in $ocsroot/ inside ISO file.
467 # Since we will always use /home/partimag as the image root in Clonezilla live, here the path in the created iso is /home/partimag/
468 ocs_imgs_with_abs_path="$ocs_imgs_with_abs_path /home/partimag/$im/=$image_path/$im/"
469 convert_ocs_format_from_1.5_to_2.0_or_newer $image_path/$im/
470 check_file_size_in_ocs_image $image_path/$im/
471 img_size="$(du -ms $image_path/$im/ | awk -F" " '{print $1}')" # unit: MB
472 img_size_sum="$((img_size_sum+img_size))"
473 done
474 else
475 echo "Creating clonezilla Live CD ISO file..."
476 # if version_no is not set, use date (Ex. 20070409)
477 [ -z "$version_no" ] && version_no="$(date +%Y%m%d)"
478 iso_label_tag="${version_no}"
479 fi
480 boot_menu_opt="--version-no $iso_label_tag"
481
482 if [ -n "$target_iso_prefix" ]; then
483 target_iso="${target_iso_prefix}.iso"
484 else
485 target_iso="clonezilla-live-${iso_label_tag}.iso"
486 fi
487 echo "The output file name is: $target_iso."
488
489 if [ "$template_mode" = "from-booting-live-media" ]; then
490 DEBIAN_ISO_TMP="$LIVE_MEDIA"
491 else
492 DEBIAN_ISO_TMP="$(mktemp -d /tmp/ocs-iso.XXXXXX)"
493 mount -o loop,ro $DEBIAN_ISO $DEBIAN_ISO_TMP
494 fi
495
496 #
497 # Possible kernel/initrd paths are /casper (created by casper) or /live (created by live-initramfs)
498 # Find the kernel and initrd in $DEBIAN_ISO_TMP/casper or $DEBIAN_ISO_TMP/live
499 # Ex: $DEBIAN_ISO_TMP/casper/vmlinuz1, /$DEBIAN_ISO_TMP/casper/initrd1.img
500 # $live_sys_files_dir_list is from drbl-ocs.conf.
501 # Possible kernel/initrd paths are /casper (created by casper) or /live (created by live-initramfs)
502 sys_files_dir=""
503 for i in $live_sys_files_dir_list; do
504 krnfile_full_path="$(find $DEBIAN_ISO_TMP/$i/ -maxdepth 1 -name "vmlinuz*" -print 2>/dev/null)"
505 if [ -n "$krnfile_full_path" ]; then
506 krnfile="$(basename $krnfile_full_path)"
507 sys_files_dir="$i"
508 irdfile_full_path="$(find $DEBIAN_ISO_TMP/$i/ -maxdepth 1 -name "initrd*" -print)"
509 irdfile="$(basename $irdfile_full_path)"
510 break
511 fi
512 done
513
514 #
515 if [ -z "$sys_files_dir" ]; then
516 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
517 echo "No system files from template live iso are found! Something went wrong!"
518 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
519 echo "$msg_program_stop"
520 exit 1
521 fi
522
523 if [ -z "$krnfile" -o -z "$irdfile" ]; then
524 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
525 echo "Kernel and initrd files NOT found in path $DEBIAN_ISO_TMP/$sys_files_dir/!"
526 echo "$msg_program_stop"
527 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
528 exit 1
529 fi
530
531 if [ "$template_mode" = "from-booting-live-media" ]; then
532 # From boot media (clonezilla live), DEBIAN_ISO_TMP is LIVE_MEDIA
533 # The dirs/files in Clonezilla live:
534 # -r--r--r-- 1 root root 117 2010-05-21 21:17 Clonezilla-Live-Version
535 # -r--r--r-- 1 root root 18K 2010-05-21 21:05 COPYING
536 # dr-xr-xr-x 2 root root 2.0K 2010-05-21 21:17 isolinux/
537 # dr-xr-xr-x 2 root root 2.0K 2010-05-21 21:17 live/
538 # dr-xr-xr-x 2 root root 2.0K 2010-05-21 21:17 syslinux/
539 # dr-xr-xr-x 5 root root 2.0K 2010-05-21 21:17 utils/
540 # We need all of them.
541 template_iso_size="$(LC_ALL=C du -Lmsc $LIVE_MEDIA/{Clonezilla-Live-Version,COPYING,isolinux,$sys_files_dir,syslinux,utils} | tail -n 1 | awk -F" " '{print $1}')"
542 else
543 # From iso file (debian-live-for-ocs.iso)
544 # The dirs/files in Debian live for OCS:
545 # dr-xr-xr-x 3 root root 4.0K 2010-05-28 18:03 doc/
546 # dr-xr-xr-x 2 root root 4.0K 2010-05-28 18:03 isolinux/
547 # dr-xr-xr-x 2 root root 2.0K 2010-05-28 18:03 live/
548 # -r--r--r-- 1 root root 3.7K 2010-05-28 18:03 md5sum.txt
549 # We only need dirs isolinux and live only
550 template_iso_size="$(LC_ALL=C du -Lmsc $DEBIAN_ISO_TMP/{isolinux,$sys_files_dir} | tail -n 1 | awk -F" " '{print $1}')"
551 fi
552 target_iso_size="$(($template_iso_size + $img_size_sum))"
553
554 #
555 BOOT_ITEM_DIR=$ISOSYSLNX_TMP/$sys_files_dir
556 [ ! -d $BOOT_ITEM_DIR ] && mkdir $BOOT_ITEM_DIR
557 echo -n "Copying the system files to working dir... This might take a few minutes... "
558 cp -af $DEBIAN_ISO_TMP/$sys_files_dir $ISOSYSLNX_TMP/
559 RC=$?
560 if [ "$RC" -ne 0 ]; then
561 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
562 echo "Failed to copy system files to working dir..."
563 echo "$msg_program_stop"
564 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
565 exit 1
566 fi
567 echo "done!"
568
569 ################################################################################
570 # Section edited by S. Georgaras <sng@hellug.gr>
571 #
572 # echo "Estimated target ISO file \"$target_iso\" size: $target_iso_size MB"
573 # if [ "$target_iso_size" -gt "$FILE_LIMIT" ]; then
574 # [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
575 # echo "$msg_ocs_iso_too_big_for_DVD"
576 # [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
577 # echo "$msg_are_u_sure_u_want_to_continue"
578 # echo -n "[y/N] "
579 # read cont_ans
580 # case "$cont_ans" in
581 # y|Y|[yY][eE][sS])
582 # echo $msg_ok_let_do_it
583 # ;;
584 # *)
585 # echo "Abort!"
586 # exit 2
587 # esac
588 # elif [ "$target_iso_size" -gt "$CD_FILE_LIMIT" ]; then
589 # [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
590 # echo "$msg_ocs_iso_too_big_for_CD"
591 # [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
592 # echo "$msg_are_u_sure_u_want_to_continue"
593 # echo -n "[y/N] "
594 # read cont_ans
595 # case "$cont_ans" in
596 # y|Y|[yY][eE][sS])
597 # echo $msg_ok_let_do_it
598 # ;;
599 # *)
600 # echo "Abort!"
601 # exit 2
602 # esac
603 # fi
604
605 ################################################################################
606
607 # output setting for clonezilla live
608 mkdir -p $WD_TMP/etc/ocs
609
610 # Decide ocs_live_run
611 # $DRBL_SCRIPT_PATH/sbin/custom-ocs is copied from $LIVE_MEDIA/pkg/custom-ocs by /etc/ocs/ocs-live.d/S03prep-drbl-clonezilla when booting
612 if [ -n "$custom_ocs" ]; then
613 custom_ocs_opt="/pkg/custom-ocs=$custom_ocs"
614 ocs_live_run="custom-ocs"
615 else
616 if [ "$insert_mode" = "prog_and_img" ]; then
617 case "$normal_menu_with_insert_image" in
618 no) ocs_live_run="ocs-live-restore" ;;
619 yes) ocs_live_run="ocs-live-general" ;;
620 esac
621 else # prog_only mode
622 ocs_live_run="ocs-live-general"
623 fi
624 fi
625
626 # Create the iso image file
627 # isolinux should be rw, so we have to copy it, and exclude the one in iso image.
628 mkdir -p $ISOSYSLNX_TMP/isolinux/ $ISOSYSLNX_TMP/syslinux/
629 # rsync -a --exclude f*.txt --exclude boot.cat --exclude isolinux.txt --exclude isolinux.bin --exclude splash.rle --exclude doc $DRBL_SCRIPT_PATH/pkg/syslinux/* $ISOSYSLNX_TMP/isolinux/
630 # we have to overwrite isolinux.bin since vesamenu.c32 should be same version with that.
631 # For isolinux
632 cp -af $isolinux_file $pxelinux_simple_vesamenu $pxelinux_simple_menu $pxelinux_memdisk_file $pxelinux_bg_img $ocs_logo_img_png $pxelinux_chain_file $ISOSYSLNX_TMP/isolinux/
633 # For syslinux
634 cp -af $pxelinux_simple_vesamenu $pxelinux_simple_menu $pxelinux_memdisk_file $pxelinux_bg_img $ocs_logo_img_png $pxelinux_chain_file $ISOSYSLNX_TMP/syslinux/
635 # Copy the EFI boot files
636 if [ -e "$DEBIAN_ISO_TMP/EFI/boot/bootia32.efi" -a -e "$DEBIAN_ISO_TMP/EFI/boot/bootx64.efi" ]; then
637 cp -af $DEBIAN_ISO_TMP/EFI $ISOSYSLNX_TMP/
638 cp -af $ocs_logo_grub2_img_png $ISOSYSLNX_TMP/EFI/boot/
639 fi
640
641 etherboot_zlilo="$($query_pkglist_cmd drbl-etherboot 2>/dev/null | grep -E "eb-.*-etherboot-pci.zlilo$")"
642 # we have to force it name as etherboot.zdsk, since isolinux only uses the "plain" ISO 9660 filenames, i.e. it does not support Rock Ridge or Joliet filenames.
643 # ref: http://syslinux.zytor.com/archives/2006-October/007440.html
644 # "-" will be regards as "_" if you want to use "-" for isolinux.
645 # In syslinux on vfat, etherboot.zlilo is too long, make it ever shorter as eb.zli
646 if [ -n "$etherboot_zlilo" ]; then
647 # This is run in DRBL server
648 cp -af $etherboot_zlilo $BOOT_ITEM_DIR/eb.zli
649 else
650 # This is run in Clonezilla live with casper or live mechanism
651 for i in $live_sys_files_dir_list; do
652 if [ -e "$LIVE_MEDIA/$i/eb.zli" ]; then
653 cp -af $LIVE_MEDIA/$i/eb.zli $BOOT_ITEM_DIR/eb.zli
654 break
655 fi
656 done
657 fi
658 # same reason, we have to use different name in isolinux
659 # gPXE is deprecated, we will use iPXE. We keep this gpxe part for ref only.
660 gpxe_lkn="$($query_pkglist_cmd gpxe 2>/dev/null | grep -E "gpxe.lkrn$")"
661 if [ -n "$gpxe_lkn" ]; then
662 # This is run in DRBL server
663 cp -af $gpxe_lkn $BOOT_ITEM_DIR/gpxe.lkn
664 else
665 # This is run in Clonezilla live with casper or live mechanism
666 for i in $live_sys_files_dir_list; do
667 if [ -e "$LIVE_MEDIA/$i/gpxe.lkn" ]; then
668 cp -af $LIVE_MEDIA/$i/gpxe.lkn $BOOT_ITEM_DIR/gpxe.lkn
669 break
670 fi
671 done
672 fi
673 # same reason, we have to use different name in isolinux
674 ipxe_lkn="$($query_pkglist_cmd ipxe 2>/dev/null | grep -E "ipxe.lkrn$")"
675 if [ -n "$ipxe_lkn" ]; then
676 # This is run in DRBL server
677 cp -af $ipxe_lkn $BOOT_ITEM_DIR/ipxe.lkn
678 else
679 # This is run in Clonezilla live with casper or live mechanism
680 for i in $live_sys_files_dir_list; do
681 if [ -e "$LIVE_MEDIA/$i/ipxe.lkn" ]; then
682 cp -af $LIVE_MEDIA/$i/ipxe.lkn $BOOT_ITEM_DIR/ipxe.lkn
683 break
684 fi
685 done
686 fi
687 # same reason, we have to use different name in isolinux
688 if [ -e "$fdos_img_src" ] ; then
689 cp -af $fdos_img_src $BOOT_ITEM_DIR/freedos.img
690 else
691 # This is run in Clonezilla live with casper or live mechanism
692 for i in $live_sys_files_dir_list; do
693 if [ -e "$LIVE_MEDIA/$i/freedos.img" ]; then
694 cp -af $LIVE_MEDIA/$i/freedos.img $BOOT_ITEM_DIR/freedos.img
695 break
696 fi
697 done
698 fi
699 # $memtest86_file (memtest86) is 9 characters, will go wrong when it's FAT (usb flash drive). We use memtest to overwrite the one comes from Debian live.
700 # Since live helper will put memtest in casper, we can choose to copy it or not.
701 # If we really want to use the memtest from drbl, we have to remove $DEBIAN_ISO_TMP/casper/memtest before doing mkisofs, otherwise it will complain like:
702 # Using MEMTEST000.;1 for /tmp/ocs-iso.E15902/casper/memtest (memtest)
703 # genisoimage: Error: '/tmp/isolnx.V15903/casper/memtest' and '/tmp/ocs-iso.E15902/casper/memtest' have the same Rock Ridge name 'memtest'.
704 # Unable to sort directory /tmp/ocs-iso.E15902/casper
705 # since $DEBIAN_ISO_TMP/casper/memtest is read-only, we can not remove it. Later we will exclude that later by mkisofs.
706 if [ -e "$memtest86_file" ]; then
707 cp -af $memtest86_file $BOOT_ITEM_DIR/memtest
708 else
709 # This is run in Clonezilla live with casper or live mechanism
710 for i in $live_sys_files_dir_list; do
711 if [ -e "$LIVE_MEDIA/$i/memtest" ]; then
712 cp -af $LIVE_MEDIA/$i/memtest $BOOT_ITEM_DIR/memtest
713 break
714 fi
715 done
716 fi
717
718 # Excluding list for mkisofs
719 for i in $live_sys_files_dir_list; do
720 if [ -e "$DEBIAN_ISO_TMP/$i/memtest" ]; then
721 mkiso_exclude_list="$mkiso_exclude_list $i/memtest"
722 break
723 fi
724 done
725 mkiso_exclude_opt=""
726 for i in $mkiso_exclude_list; do
727 mkiso_exclude_opt="$mkiso_exclude_opt -x $DEBIAN_ISO_TMP/$i"
728 done
729
730 # Find the boot param $boot_param
731 get_live_boot_param $DEBIAN_ISO_TMP/isolinux
732
733 #
734 if [ -n "$ocs_image" ]; then
735 # Image is included
736 # For isolinux
737 ocs-live-boot-menu $ocs_live_boot_menu_option -l $lang_answer -f $VGA_MODE_DEF -b $bg_mode -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $ocs_logo_img_png $boot_menu_opt --boot-param "$boot_param $live_extra_boot_param $supp_boot_param_ocs_live_iso ocs_live_run=\"$ocs_live_run\" ocs_live_extra_param=\"$ocs_live_extra_param\" ocs_live_keymap=\"$ocs_live_keymap\" ocs_live_batch=\"$ocs_live_batch\" ocs_lang=\"$ocs_lang\"" --title "clonezilla live with img $ocs_image" isolinux $ISOSYSLNX_TMP/isolinux/
738 # For syslinux
739 ocs-live-boot-menu $ocs_live_boot_menu_option -l $lang_answer -f $VGA_MODE_DEF -b $bg_mode -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $ocs_logo_img_png $boot_menu_opt --boot-param "$boot_param $live_extra_boot_param $supp_boot_param_ocs_live_dev ocs_live_run=\"$ocs_live_run\" ocs_live_extra_param=\"$ocs_live_extra_param\" ocs_live_keymap=\"$ocs_live_keymap\" ocs_live_batch=\"$ocs_live_batch\" ocs_lang=\"$ocs_lang\"" --title "clonezilla live with img $ocs_image" syslinux $ISOSYSLNX_TMP/syslinux/
740 # For grub2 efi
741 if [ -e "$ISOSYSLNX_TMP/EFI/boot/bootia32.efi" -a -e "$ISOSYSLNX_TMP/EFI/boot/bootx64.efi" ]; then
742 ocs-live-boot-menu $ocs_live_boot_menu_option -l $lang_answer -f $VGA_MODE_DEF -b $bg_mode -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $ocs_logo_grub2_img_png $boot_menu_opt --boot-param "$boot_param $live_extra_boot_param $supp_boot_param_ocs_live_dev ocs_live_run=\"$ocs_live_run\" ocs_live_extra_param=\"$ocs_live_extra_param\" ocs_live_keymap=\"$ocs_live_keymap\" ocs_live_batch=\"$ocs_live_batch\" ocs_lang=\"$ocs_lang\"" --title "clonezilla live with img $ocs_image" grub2-efi $ISOSYSLNX_TMP/EFI/boot/
743 fi
744 else
745 # No image is included
746 # For isolinux
747 ocs-live-boot-menu $ocs_live_boot_menu_option -l $lang_answer -f $VGA_MODE_DEF -b $bg_mode -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $ocs_logo_img_png $boot_menu_opt --boot-param "$boot_param $live_extra_boot_param $supp_boot_param_ocs_live_iso ocs_live_run=\"$ocs_live_run\" ocs_live_extra_param=\"$ocs_live_extra_param\" ocs_live_keymap=\"$ocs_live_keymap\" ocs_live_batch=\"$ocs_live_batch\" ocs_lang=\"$ocs_lang\"" isolinux $ISOSYSLNX_TMP/isolinux/
748 # For syslinux
749 ocs-live-boot-menu $ocs_live_boot_menu_option -l $lang_answer -f $VGA_MODE_DEF -b $bg_mode -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $ocs_logo_img_png $boot_menu_opt --boot-param "$boot_param $live_extra_boot_param $supp_boot_param_ocs_live_dev ocs_live_run=\"$ocs_live_run\" ocs_live_extra_param=\"$ocs_live_extra_param\" ocs_live_keymap=\"$ocs_live_keymap\" ocs_live_batch=\"$ocs_live_batch\" ocs_lang=\"$ocs_lang\"" syslinux $ISOSYSLNX_TMP/syslinux/
750 # For grub2 efi
751 if [ -e "$ISOSYSLNX_TMP/EFI/boot/bootia32.efi" -a -e "$ISOSYSLNX_TMP/EFI/boot/bootx64.efi" ]; then
752 ocs-live-boot-menu $ocs_live_boot_menu_option -l $lang_answer -f $VGA_MODE_DEF -b $bg_mode -k /$sys_files_dir/$krnfile -i /$sys_files_dir/$irdfile -m $ocs_logo_grub2_img_png $boot_menu_opt --boot-param "$boot_param $live_extra_boot_param $supp_boot_param_ocs_live_dev ocs_live_run=\"$ocs_live_run\" ocs_live_extra_param=\"$ocs_live_extra_param\" ocs_live_keymap=\"$ocs_live_keymap\" ocs_live_batch=\"$ocs_live_batch\" ocs_lang=\"$ocs_lang\"" grub2-efi $ISOSYSLNX_TMP/EFI/boot/
753 fi
754 fi
755
756 #
757 echo "Preparing syslinux, syslinux.exe, makeboot.sh, and makeboot.bat in dir utils... "
758 # If it's in Clonezilla live environment, we have those files
759 if [ -e "$LIVE_MEDIA/utils/linux/syslinux" -a \
760 -e "$LIVE_MEDIA/utils/mbr/mbr.bin" -a \
761 -e "$LIVE_MEDIA/utils/win32/syslinux.exe" ]; then
762 cp -rf $LIVE_MEDIA/utils $ISOSYSLNX_TMP
763 else
764 isolinux_ver="$(LC_ALL=C strings $ISOSYSLNX_TMP/isolinux/isolinux.bin | grep "^ISOLINUX" | awk -F" " '{print $2}')"
765 put_syslinux_makeboot_for_usb_flash $ISOSYSLNX_TMP $isolinux_ver
766 fi
767 if [ -d "$ISOSYSLNX_TMP/utils" ]; then
768 utils_files_dir_graft_point="/utils/=$ISOSYSLNX_TMP/utils/"
769 fi
770
771 # put version tag
772 # The content is like clonezilla-live-20070308
773 echo "clonezilla-live-${iso_label_tag}" > $ISOSYSLNX_TMP/Clonezilla-Live-Version
774 echo "This Clonezilla live iso file was created by this command:" >> $ISOSYSLNX_TMP/Clonezilla-Live-Version
775 echo "$prog $prog_option" >> $ISOSYSLNX_TMP/Clonezilla-Live-Version
776
777 # $sys_files_dir maybe /casper, /live or /isolinux. If it is isolinux, we can not list them twice otherwise mkisofs will go wrong.
778 if [ "$sys_files_dir" != "isolinux" ]; then
779 sys_files_dir_graft_point="/isolinux/=$ISOSYSLNX_TMP/isolinux/ /syslinux/=$ISOSYSLNX_TMP/syslinux/ /$sys_files_dir/=$ISOSYSLNX_TMP/$sys_files_dir/"
780 else
781 sys_files_dir_graft_point="/isolinux/=$ISOSYSLNX_TMP/isolinux/ /syslinux/=$ISOSYSLNX_TMP/syslinux/"
782 fi
783
784 #
785 if [ -d "$ISOSYSLNX_TMP/EFI" ]; then
786 sys_files_dir_graft_point="$sys_files_dir_graft_point /EFI/=$ISOSYSLNX_TMP/EFI"
787 fi
788
789 # If template_mode="from-booting-live-media", then there is /COPYING and /Clonezilla-Live-Version, then we should not assign that.
790 doc_insert_in_root=""
791 if [ -e "$DEBIAN_ISO_TMP/COPYING" ]; then
792 doc_insert_in_root="/COPYING=$DEBIAN_ISO_TMP/COPYING"
793 else
794 doc_insert_in_root="/COPYING=$DRBL_SCRIPT_PATH/doc/COPYING"
795 fi
796 if [ -e "$DEBIAN_ISO_TMP/Clonezilla-Live-Version" ]; then
797 doc_insert_in_root="$doc_insert_in_root /Clonezilla-Live-Version=$DEBIAN_ISO_TMP/Clonezilla-Live-Version"
798 else
799 doc_insert_in_root="$doc_insert_in_root /Clonezilla-Live-Version=$ISOSYSLNX_TMP/Clonezilla-Live-Version"
800 fi
801
802 #
803 allow_limited_size_opt=""
804 if [ "$allow_limited_size_flag" = "yes" ]; then
805 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
806 echo "Since there is at least one file larger than ${iso9660_file_size_limit}B in the image file, we turn on the option -allow-limited-size for genisoimage. This also implies enabling UDF format instead of iso9660."
807 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
808 allow_limited_size_opt="-allow-limited-size"
809 fi
810
811 # Remove the existing iso
812 [ -e "$target_iso" ] && rm -f $target_iso
813
814 # Build the EFI boot image. This is especially for iso file. Not for USB stick.
815 efi_img_opt=""
816 if [ "$enabled_EFI" = "true" ]; then
817 # The following codes are referred from Fedora
818 EFI_BOOTIMG_TMP="$(mktemp -d /tmp/efi-boot.XXXXXX)"
819 EFI_BOOTTREE="$DEBIAN_ISO_TMP/EFI"
820 EFI_IMGTREE="$ISOSYSLNX_TMP/EFI-imgs"
821 EFI_IMG="$EFI_IMGTREE/efiboot.img"
822 mkdir -p $EFI_IMGTREE
823 rm -rf $ISOSYSLNX_TMP/.disk
824 rm -f $EFI_IMG
825
826 BOOTDISKSIZE="$(LC_ALL=C du -kcs $EFI_BOOTTREE | tail -n1 | awk '{print $1}')"
827 BOOTDISKSIZE="$(LC_ALL=C expr $BOOTDISKSIZE + 100)"
828 echo "The size of the $EFI_IMG is $BOOTDISKSIZE"
829 mkdosfs -n OCS-EFI -C $EFI_IMG $BOOTDISKSIZE >/dev/null
830 mount -o loop,shortname=winnt,umask=0077 -t vfat $EFI_IMG $EFI_BOOTIMG_TMP
831 mkdir -p $EFI_BOOTIMG_TMP/EFI/
832 cp -R $EFI_BOOTTREE/* $EFI_BOOTIMG_TMP/EFI/
833 umount $EFI_BOOTIMG_TMP
834 if [ -d "$EFI_BOOTIMG_TMP" -a -n \
835 "$(echo $EFI_BOOTIMG_TMP | grep -e "efi-boot")" ]; then
836 rm -rf $EFI_BOOTIMG_TMP
837 fi
838
839 # Create an info file for grub2 to autodetect the cd root
840 # Ref: http://www.sysresccd.org/forums/viewtopic.php?f=5&t=4410
841 mkdir $ISOSYSLNX_TMP/.disk
842 echo -n "[Clonezilla]" > $ISOSYSLNX_TMP/.disk/info
843
844 efi_img_opt="-eltorito-alt-boot -efi-boot EFI-imgs/efiboot.img -no-emul-boot"
845 efi_img_graft_opt="/EFI-imgs/=$EFI_IMG /.disk/=$ISOSYSLNX_TMP/.disk"
846 fi
847
848 ############################################################################
849 #
850 # Section added by S. Georgaras <sng@hellug.gr>
851 # Just for debugging...
852 #
853 ############################################################################
854 # echo "genisoimage \
855 # -A "Clonezilla live CD" \
856 # -V "$iso_label_tag" \
857 # -publisher "DRBL/Clonezilla http://drbl.name http://clonezilla.org" \
858 # -f -r -J -l $allow_limited_size_opt \
859 # -b isolinux/isolinux.bin -c isolinux/boot.cat \
860 # -no-emul-boot -boot-load-size 4 -boot-info-table \
861 # $mkiso_exclude_opt \
862 # -graft-points \
863 # $sys_files_dir_graft_point \
864 # $utils_files_dir_graft_point \
865 # $doc_insert_in_root \
866 # $ocs_imgs_with_abs_path \
867 # $custom_ocs_opt \
868 # $include_dir_graft_point
869 # "
870 #
871 # echo "DEBIAN_ISO_TMP=$DEBIAN_ISO_TMP"
872 # echo "mkiso_exclude_opt = $mkiso_exclude_opt"
873 # echo "allow_limited_size_opt = $allow_limited_size_opt"
874 # echo "sys_files_dir_graft_point = $sys_files_dir_graft_point"
875 # echo "utils_files_dir_graft_point = $utils_files_dir_graft_point"
876 # echo "doc_insert_in_root = $doc_insert_in_root"
877 # echo "ocs_imgs_with_abs_path = $ocs_imgs_with_abs_path"
878 # echo "custom_ocs_opt = $custom_ocs_opt"
879 # echo "include_dir_graft_point = $include_dir_graft_point"
880 # echo
881 # echo "ocs_image=$ocs_image"
882 # echo "image_path=$image_path"
883 #
884 # read
885 ############################################################################
886
887
888
889 # if [ -z "$ORIGINAL_INSERT_MODE" ];then
890 # A_LINE=`grep 'append initrd=/live/initrd.img'/tmp/ocs_isos*/isolinux/isolinux.cfg | sed '2,$d'`
891 # PARAM=`echo "$A_LINE" | sed 's/.*ocs_live_extra_param="\([^"]*\)".*/\1/'`
892 # KEYMAP=`echo "$A_LINE" | sed 's/.*ocs_live_keymap="\([^"]*\)".*/\1/'`
893 # LANG=`echo "$A_LINE" | sed 's/.*ocs_lang="\([^"]*\)".*/\1/'`
894 # if [ -z "$going2RAM" ];then
895 # #cp /restorecd/isolinux-restore-cd.cfg /tmp/ocs_isos*/isolinux/isolinux.cfg
896 # cfg_orig=/restorecd/isolinux-restore-cd.cfg
897 # else
898 # #cp /restorecd/isolinux-restore-cd-ram.cfg /tmp/ocs_isos*/isolinux/isolinux.cfg
899 # cfg_orig=/restorecd/isolinux-restore-cd-ram.cfg
900 # fi
901 # # replace with current values
902 # sed "s|ocs_live_extra_param=\"[^\"]*\"|ocs_live_extra_param=\"$PARAM\"|
903 # s|ocs_live_keymap=\"[^\"]*\"|ocs_live_keymap=\"$KEYMAP\"|
904 # s|ocs_lang=\"[^\"]*\"|ocs_lang=\"$LANG\"|
905 # " "$cfg_orig" > /tmp/ocs_isos*/isolinux/isolinux.cfg
906
907 # cust-menu -publisher "DRBL/Clonezilla http://drbl.name http://clonezilla.org" -V "$iso_label_tag" "$ORIGINAL_INSERT_MODE" "$going2RAM"
908 cust-menu -publisher "DRBL/Clonezilla http://drbl.name http://clonezilla.org" -V "$iso_label_tag" "$ORIGINAL_INSERT_MODE"
909 # fi
910
911 # Fix missing "boot=live"
912 for n in /tmp/ocs_isos*/isolinux/isolinux.cfg /tmp/ocs_isos*/syslinux/syslinux.cfg;do
913 if [ -e "$n" ];then
914 sed 's/boot=[^ ]* //
915 s{initrd=/live/initrd.img{initrd=/live/initrd.img boot=live {' "$n" > "$n".tmp && mv "$n".tmp "$n"
916 fi
917 done
918
919 # if [ -n "$going2RAM" ];then
920 # ocs_imgs_with_abs_path=''
921 # fi
922
923 if [ -e /tmp/isodata ];then
924 iso_label_tag=`sed '2d' /tmp/isodata`
925 isoPublisher=`sed '1d' /tmp/isodata`
926 rm /tmp/isodata 2>/dev/null
927 fi
928
929
930 # make iso file
931 genisoimage \
932 -A "Clonezilla live CD" \
933 -V "$iso_label_tag" \
934 -publisher "$isoPublisher" \
935 -f -r -J -l $allow_limited_size_opt \
936 -b isolinux/isolinux.bin -c isolinux/boot.cat \
937 -no-emul-boot -boot-load-size 4 -boot-info-table \
938 $mkiso_exclude_opt $efi_img_opt \
939 -graft-points \
940 $sys_files_dir_graft_point \
941 $utils_files_dir_graft_point \
942 $doc_insert_in_root \
943 $ocs_imgs_with_abs_path \
944 $efi_img_graft_opt \
945 $custom_ocs_opt \
946 $include_dir_graft_point \
947 | \
948 (
949 case "$output_mode" in
950 "cdwriter")
951 wodim dev=$output_dev -data -eject -v -
952 ;;
953 *)
954 # use /dev/stdout as the bridge
955 cat - > $target_iso
956 ;;
957 esac
958 )
959
960 rc=$?
961 if [ "$rc" -gt 0 ]; then
962 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
963 echo "Something went wrong!"
964 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
965 clean_tmp_dir
966 [ -n "$target_iso" -a -f "$target_iso" ] && rm -fv $target_iso
967 echo "$msg_program_stop"
968 exit 1
969 fi
970
971 # unmount all iso file
972 umount $DEBIAN_ISO_TMP &>/dev/null
973
974 # Clean the tmp working directory
975 echo "Cleaning tmp dirs..."
976 clean_tmp_dir
977
978 #
979 if [ -e "$target_iso" ]; then
980 if type isohybrid &>/dev/null; then
981 echo -n "Isohybriding $target_iso... "
982 isohybrid $target_iso
983 echo "done!"
984 fi
985 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
986 echo "$msg_burn_clonezilla_img_iso: $target_iso"
987 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
988 fi

Properties

Name Value
svn:executable *

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26