Debian Codegraph @

pkg/syslinux/makeboot.sh

raw symbols SCIP
1 #!/bin/bash
2
3 ######
4 # Author: Steven Shiau <steven _at_ clonezilla org>, Ceasar Sun <ceasar _at_ clonezilla org>
5 # License: GPL
6 # Description: Program to make USB flash drive (FAT, EXT, BTRFS , XFS or NTFS) bootable by syslinux or extlinux
7 # Main steps:
8 # 1. Checking if partition table correct (on boundary, bootable)
9 # 2. cat mbr
10 # 3. Run "syslinux -f -i" or "extlinux -i"
11 #
12 # Update history:
13 # 2016/3/7 by Ceasar
14 # 1. Fix: use "findmnt" to get mount path
15 # 2. Fix: consider mount path with "space" character ex: "/media/user/USB\ DISK"
16 # 2016/8/27 by David Tonhofer
17 # 1. Rewrite some codes to reuse.
18 # 2. Add comments.
19 ######
20
21 set -u
22
23 # Append PATH
24 export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
25
26 # Settings
27 ocs_batch_mode="false"
28
29 #
30 prog="$(basename $0)"
31 path_of_prog="$(LC_ALL=C cd "$(dirname "$0")/../../"; pwd)"
32
33 # Check if terminal supports colors output
34 colors_no="$(LC_ALL=C tput colors 2>/dev/null)"
35
36 BOOTUP=""
37 if [ -n "$colors_no" ]; then
38 if [ "$colors_no" -ge 8 ]; then
39 [ -z ${SETCOLOR_SUCCESS:-''} ] && SETCOLOR_SUCCESS="echo -en \\033[1;32m"
40 [ -z ${SETCOLOR_FAILURE:-''} ] && SETCOLOR_FAILURE="echo -en \\033[1;31m"
41 [ -z ${SETCOLOR_WARNING:-''} ] && SETCOLOR_WARNING="echo -en \\033[1;33m"
42 [ -z ${SETCOLOR_NORMAL:-''} ] && SETCOLOR_NORMAL="echo -en \\033[0;39m"
43 BOOTUP="color"
44 fi
45 fi
46
47 #
48 msg_are_u_sure_u_want_to_continue='Are you sure you want to continue?'
49 msg_you_have_to_enter_yes_or_no="You have to enter 'y', 'yes', 'n' or 'no'. Please enter it again!"
50 msg_do_you_want_to_make_it_bootable="Do you want to mark it as bootable ?"
51
52 #
53 USAGE() {
54 echo "$prog - To make the device bootable with syslinux/extlinux"
55 echo "Usage: $prog [OPTION] partition_device_holding_clonezilla_filetree"
56 echo "Options:"
57 echo "-b, --batch-mode batch, unattended mode. Use carefully! DANGEROUS!!!"
58 echo "-L, --LABEL STRING set device via LABEL if LABEL exists"
59 echo "-U, --UUID STRING set device via UUID"
60 echo "This script is assumed to ACTUALLY RESIDE IN THE CORRECT PLACE OF THE CLONEZILLA FILE TREE!"
61 echo "The path to it is used to find other files!"
62 echo "Note:"
63 echo " Device assignment priority: Partition name > UUID > LABEL (if not only one NAME-TYPE is assigned)"
64 echo "Ex:"
65 echo "To make \"/dev/sdg1\" bootable on GNU/Linux:"
66 echo " $prog /dev/sdg1"
67 echo "To make device label \"LABEL_STRING\" bootable on GNU/Linux:"
68 echo " $prog -L LABEL_STRING"
69 echo "To make device with UUID \"UUID_STRING\" bootable on GNU/Linux:"
70 echo " $prog -U UUID_STRING"
71 }
72 # Check if root or not
73 check_if_root() {
74 if [ ! "$UID" = "0" ]; then
75 echo
76 echo "[$LOGNAME] You need to run this script \"`basename $0`\" as root."
77 echo
78 exit 1
79 fi
80 }
81 #
82 to_continue_or_not() {
83 local prompt_msg="$1"
84 continue_choice=""
85 while [ -z "$continue_choice" ]; do
86 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
87 echo "$prompt_msg"
88 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
89 echo -n "[y/n] "
90 read continue_choice
91 case "$continue_choice" in
92 y|Y|[yY][eE][sS])
93 echo "OK! Let's do it!" ;;
94 n|N|[nN][oO])
95 echo "Program terminated!"
96 exit 1
97 ;;
98 *)
99 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
100 echo "$msg_you_have_to_enter_yes_or_no!"
101 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
102 echo "--------------------------------------------"
103 ;;
104 esac
105 done
106 } # end of to_continue_or_not
107 #
108 get_diskname() {
109 local disk=${1#/dev/*}
110
111 if [ -n "$disk" ]; then
112 echo "$disk" | sed -e 's/^\([^0-9]*\)[0-9]*$/\1/g' \
113 -e 's/^\(.*[0-9]\{1,\}\)p[0-9]\{1,\}$/\1/g'
114 fi
115 } # end of get_diskname
116 #
117 get_part_number() {
118 local disk=${1#/dev/*}
119 local num=""
120
121 if [ -n "$disk" ]; then
122 num=$(echo "$disk" | sed -e 's/^[^0-9]*\([0-9]*\)$/\1/g' \
123 -e 's/^.*[0-9]\{1,\}\(p[0-9]\{1,\}\)$/\1/g')
124 fi
125
126 echo $num
127 } # end of get_part_number
128 #
129 check_if_syslinux_runs() {
130 local sys_exec="$1"
131 local lrc
132 # Check if the libc6-i386 (debian/ubuntu) files exists, which is required
133 # for running 32-bit syslinux
134 # E.g. On Debian AMD64 system without installing libc6-i386,
135 # $ ldd syslinux
136 # not a dynamic executable
137 # If libc6-i386 is installed:
138 # $ ldd syslinux
139 # linux-gate.so.1 => (0xf77dd000)
140 # libc.so.6 => /lib32/libc.so.6 (0xf7661000)
141 # /lib/ld-linux.so.2 (0xf77e0000)
142 # It's easier we use "syslinux -h" to test if it runs:
143 # $ ls -alFh ./syslinux
144 # -rwxrwxr-x 1 steven steven 209K Oct 7 00:32 ./syslinux*
145 # $ ./syslinux -h
146 # bash: ./syslinux: No such file or directory
147 # $ echo $?
148 # 127
149 # The above is the case which libc6-i386 is not installed, and the
150 # return code is 127.
151 if [ -z "$sys_exec" ]; then
152 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
153 echo "Variable sys_exec was not assigned!"
154 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
155 echo "Program terminated!"
156 exit 1
157 fi
158 if [ ! -e "$sys_exec" ]; then
159 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
160 echo "File \"$sys_exec\" does not exist!"
161 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
162 echo "Program terminated!"
163 exit 1
164 fi
165 $sys_exec -h 2>/dev/null >/dev/null
166 lrc=$?
167 if [ "$lrc" -ne 0 ]; then
168 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
169 echo "File to run $sys_exec."
170 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
171 echo "Program terminated!"
172 exit 1
173 fi
174 return $lrc
175 } # end of check_if_syslinux_runs
176 #
177 is_partition() {
178 # //NOTE// If new RE* is added, remember to check the function check_if_disk_busy_before_create_partition and get_not_busy_disks_or_parts have to be modified, too.
179 # IDE and SCSI disk partition: /dev/hda1, /dev/hdb1, /dev/sda1, /dev/sdb1...
180 # KVM virtual disk partition: /dev/vda1, /dev/vdb1...
181 # Xen virtual disk partition: /dev/xvda1, /dev/xvdb1, /dev/xdvc1...
182 # CCISS RAID disk partition: /dev/cciss/c0d0p1, /dev/cciss/c0d1p1...
183 # SD card: /dev/mmcblk0p1, /dev/mmcblk0p2, /dev/mmcblk0p3...
184 # NBD device: /dev/nbd0p1, /dev/nbd0p2...
185 # NVME device: /dev/nvme0n1p1, /dev/nvme0n1p2, /dev/nvme1n1p1, /dev/nvme1n1p2
186 # FakeRAID: with nodmraid boot parameter, /dev/md126p1, /dev/md126p2...
187 # Mylex ExtremeRAID-2000 SCSI RAID controller: /dev/rd/c0d0p1, /dev/rd/c0d1p1...
188 # Compaq Smart Array controller: /dev/ida/c0d0p1, /dev/ida/c0d1p2...
189 local dev_=${1#/dev/*}
190 local RE1='x?[hsv]d[a-z]+[0-9]+'
191 local RE2='i2o/hd[a-z]+[0-9]+'
192 local RE3='cciss/c[0-9]d[0-9]p[0-9]+'
193 local RE4='mmcblk[0-9]+p+[0-9]+'
194 local RE5='md[0-9]+p+[0-9]+'
195 local RE6='rd/c[0-9]d[0-9]p[0-9]+'
196 local RE7='ida/c[0-9]d[0-9]p[0-9]+'
197 local RE8='nvme[0-9]+n[0-9]+p+[0-9]+'
198 local RE9='nbd[0-9]+p+[0-9]+'
199 local rc=1
200 local fs_
201
202 if [ -z "$dev_" ]; then
203 return 1
204 fi
205 echo $dev_ | grep -Eq "^($RE1|$RE2|$RE3|$RE4|$RE5|$RE6|$RE7|$RE8|$RE9)$"
206 rc=$?
207
208 return $rc
209 } # end of is_partition
210
211 #
212 export LANG=C
213
214 target_part_label=''
215 target_part_uuid=''
216
217 #
218 while [ $# -gt 0 ]; do
219 case "$1" in
220 -b|--batch) ocs_batch_mode="true"; shift;;
221 -L|--LABEL) shift
222 if [ -z "$(echo $1 |grep ^-.)" ]; then
223 # only accept argument if it doesn't look like an option
224 target_part_label=$1
225 shift;
226 fi
227 [ -z "$target_part_label" ] && USAGE && exit 1
228 ;;
229 -U|--UUID) shift
230 if [ -z "$(echo $1 |grep ^-.)" ]; then
231 # only accept argument if it doesn't look like an option
232 target_part_uuid=$1
233 shift;
234 fi
235 [ -z "$target_part_uuid" ] && USAGE && exit 1
236 ;;
237 -*) echo "${0}: ${1}: invalid option" >&2
238 USAGE >& 2
239 exit 2 ;;
240 *) break ;;
241 esac
242 done
243
244 #
245 check_if_root
246 if [ "$#" -ne 1 ]; then
247 USAGE
248 exit 1
249 fi
250 target_part="$1"
251
252 if ! type parted &>/dev/null; then
253 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
254 echo 'Program "parted" was not found on this GNU/Linux system. Please install it.'
255 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
256 echo "Program terminated!"
257 exit 1
258 fi
259 if ! type blkid &>/dev/null; then
260 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
261 echo 'Program "blkid" was not found on this GNU/Linux system. Please install it.'
262 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
263 echo "Program terminated!"
264 exit 1
265 fi
266 if ! type mcopy &>/dev/null; then
267 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
268 echo 'Program "mcopy" was not found on this GNU/Linux system. Please install it. On Debian or Ubuntu Linux, you can install it by: sudo apt-get install mtools'
269 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
270 echo "Program terminated!"
271 exit 1
272 fi
273
274 if [ -n "$target_part_label" -a -z "$target_part" ] ; then
275 target_part_via_label="$(LC_ALL=C blkid | grep -iE "^/dev/[hsuv][bd][a-z]+[[:digit:]]+.+LABEL=\"$target_part_label\".*" | grep -oE -w '^/dev/[hsuv][bd][a-z]+[[:digit:]]+'| head -n 1)"
276 fi
277
278 if [ -n "$target_part_uuid" -a -z "$target_part" ] ; then
279 target_part_via_uuid="$(LC_ALL=C blkid | grep -iE "^/dev/[hsuv][bd][a-z]+[[:digit:]]+.+UUID=\"$target_part_uuid\".*" | grep -oE -w '^/dev/[hsuv][bd][a-z]+[[:digit:]]+'| head -n 1)"
280 fi
281
282 if [ -z "$target_part" ] ; then
283 [ -z "$target_part_via_label" -a -n "$target_part_via_uuid" ] && target_part=$target_part_via_uuid
284 [ -n "$target_part_via_label" -a -z "$target_part_via_uuid" ] && target_part=$target_part_via_label
285 [ -n "$target_part_via_label" -a -n "$target_part_via_uuid" -a "$target_part_via_label" != "$target_part_via_uuid" ] && target_part=$target_part_via_uuid
286 fi
287
288 #
289 if [ -z "$target_part" ]; then
290 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
291 echo "No target partition could be determined!"
292 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
293 USAGE
294 exit 1
295 fi
296 # Make sure target_part is partition device name, not disk device name
297 if ! is_partition $target_part ; then
298 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
299 echo "\"$target_part\" is NOT a valid partition name!"
300 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
301 USAGE
302 exit 1
303 fi
304
305 # Get the running OS arch
306 os_arch="$(LC_ALL=C uname -m)"
307 case "$os_arch" in
308 x86_64) arch_d="x64" ;;
309 i[3456]86) arch_d="x86" ;;
310 *) arch_d="" ;;
311 esac
312 if [ -z "$arch_d" ]; then
313 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
314 echo "Not supported OS. This running OS is \"$os_arch\", not x86 architecture."
315 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
316 echo "Program terminated!"
317 exit 1
318 fi
319 #
320 pt_dev="$(basename $target_part)" # e.g. sdc1
321 hd_dev="$(get_diskname $target_part)" # e.g. sdc
322 target_disk="/dev/$hd_dev" # e.g. /dev/sdc
323 pt_dev_no="$(get_part_number $target_part)" # e.g. 1
324
325 # If the destination disk is not MBR partition table (e.g. it's GPT), exit. This program only works for MBR disk.
326 if [ -z "$(LC_ALL=C parted -s $target_disk print | grep -iE "^Partition Table:" | grep -iE "msdos")" ]; then
327 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
328 echo "The partition table of $target_disk is not for MBR (Master Boot Record). Its layout is:"
329 LC_ALL=C parted -s $target_disk print
330 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
331 echo "This program is for making a bootable disk with MBR partition table."
332 echo "For GPT disk, there is no need to run this program. Just make sure the partition is FAT32 with ID=ef00 and all the files are copied on that. That's all."
333 echo "Program terminated!"
334 exit 1
335 fi
336
337 # Get machine info:
338 on_this_machine=""
339 dev_model_shown=""
340 if type dmidecode &>/dev/null; then
341 machine_name="$(LANG=C dmidecode -s system-product-name 2>/dev/null | head -n 1)"
342 if [ -z "$machine_name" -o "$machine_name" = "To Be Filled By O.E.M." ]; then
343 dev_model_shown="Unknown product name"
344 else
345 dev_model_shown="$machine_name"
346 fi
347 on_this_machine="on this machine \"$dev_model_shown\""
348 fi
349
350 #
351 if ! grep -qEw $pt_dev /proc/partitions; then
352 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
353 echo "$target_part was NOT found!"
354 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
355 echo "Available disk(s) and partition(s) $on_this_machine :"
356 echo "--------------------------------------------"
357 cat /proc/partitions
358 echo "--------------------------------------------"
359 echo "Program terminated!"
360 exit 1
361 fi
362
363 #
364 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
365 echo "This command will install MBR and syslinux/extlinux bootloader on $target_disk"
366 echo "Clonezilla files are assumed to be on $target_part"
367 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
368 echo "--------------------------------------------"
369 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
370 echo "Machine: $dev_model_shown:"
371 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
372 parted -s $target_disk print
373 echo "--------------------------------------------"
374
375 if [ "$ocs_batch_mode" = "false" ]; then
376 to_continue_or_not "$msg_are_u_sure_u_want_to_continue"
377 echo "--------------------------------------------"
378 fi
379
380 # 0. Check if partition is a FAT partition or NTFS partition
381 # parted -s /dev/hda1 print
382 # Disk /dev/hda1: 8590MB
383 # Sector size (logical/physical): 512B/512B
384 # Partition Table: loop
385 #
386 # Number Start End Size File system Flags
387 # 1 0.00kB 8590MB 8590MB fat32
388 # part_fs="$(LC_ALL=C parted -s $target_disk print | grep -E "^[[:space:]]*${pt_dev_no}\>" | awk -F" " '{print $6}')"
389 blkinfo="$(mktemp /tmp/blkinfo.XXXXXX)"
390 LC_ALL=C blkid -c /dev/null $target_part | grep -o -E '\<TYPE="[^[:space:]]*"($|[[:space:]]+)' > $blkinfo
391 TYPE=""
392 . $blkinfo
393
394 echo "File system of $target_part: $TYPE"
395 case "$TYPE" in
396 fat16|fat32|vfat) mode="syslinux";;
397 ntfs|ext[2-4]|btrfs|xfs|ufs|ffs) mode="extlinux";;
398 *)
399 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
400 echo "$target_part: this doesn't look like a valid FAT, NTFS, ext2/3/4 or btrfs file system."
401 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
402 echo "Program terminated!"
403 exit 1
404 ;;
405 esac
406
407 echo "--------------------------------------------"
408 # 1. Check if partition start/end on cylinder boundary
409 # //NOTE// This is not really required. Comment it on Sep/21/2010.
410 #if [ -n "$(LANG=C fdisk -l $target_disk | grep -iE "(not start on cylinder boundary|not end on cylinder boundary)")" ]; then
411 # [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
412 # echo "Some partition does not start or end on cylinder boundary! This disk will not be able to boot via syslinux!"
413 # [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
414 # echo "Program terminated!"
415 # exit 1
416 #fi
417
418 # 2. Bootable ?
419 bootable="$(LANG=C fdisk -l $target_disk | grep -Ew "^$target_part" | awk -F" " '{print $2}')"
420 if [ "$bootable" != "*" ]; then
421 echo "$pt_dev is not marked as bootable! The partition table of $target_disk:"
422 echo "--------------------------------------------"
423 echo $dev_model_shown:
424 parted -s $target_disk print
425 echo "--------------------------------------------"
426 if [ "$ocs_batch_mode" = "false" ]; then
427 to_continue_or_not "$msg_do_you_want_to_make_it_bootable"
428 fi
429 echo "Running: parted -s $target_disk set $pt_dev_no boot on"
430 parted -s $target_disk set $pt_dev_no boot on
431 echo "--------------------------------------------"
432 fi
433
434 # 3. Install MBR
435 if [ "$ocs_batch_mode" = "false" ]; then
436 to_continue_or_not "Do you want to install MBR on $target_disk $on_this_machine ?"
437 fi
438 echo "Running: cat \"$path_of_prog/utils/mbr/mbr.bin\" > $target_disk"
439 cat "$path_of_prog/utils/mbr/mbr.bin" > $target_disk
440 if [ "$?" -ne 0 ]; then
441 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
442 echo "Failed to write bootloader into MBR of $target_disk"
443 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
444 echo "Program terminated!"
445 exit 1
446 fi
447
448 echo "--------------------------------------------"
449 # 4.
450 if [ "$ocs_batch_mode" = "false" ]; then
451 # The bootloader has already been installed, now we need to write the syslinux/extlinux
452 # boot files to the partition (is it necessary to ask the user again?)
453 to_continue_or_not "Do you want to install the $mode boot files on $target_part $on_this_machine ?"
454 fi
455 # Since most of the cases when makeboot.sh is run, all the files are in FAT (USB flash drive normally uses FAT), we have to make syslinux executable.
456 #
457 # Check if $target_part is mounted or not
458 mnt_pnt="$(LC_ALL=C findmnt -nr -o target -S $target_part )"
459 flag_mount=""
460 if [ -z "$mnt_pnt" ]; then
461 # Not mounted. Mount it.
462 destfs_tmpd="$(mktemp -d /tmp/destfs_tmpd.XXXXXX)"
463 mount $target_part $destfs_tmpd
464 rc=$?
465 flag_mount="mounted"
466 else
467 # Already mounted.
468 destfs_tmpd=$mnt_pnt
469 rc=0
470 fi
471 # Create the syslinux directory in the destination partition
472 if [ "$rc" -eq 0 ]; then
473 mkdir -p "$destfs_tmpd/syslinux"
474 else
475 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
476 echo "Failed to mount partition $target_part!"
477 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
478 echo "Program terminated!"
479 exit 1
480 fi
481
482 # Create manipulable copy (may not be needed depending on the situation)
483 linux_tmpd="$(mktemp -d /tmp/linux_tmp.XXXXXX)"
484 [ $? -eq 0 ] || exit 1
485
486 echo "A filesystem supporting Unix file mode for $mode is required. Copying $mode to $linux_tmpd"
487 cp -fv "$path_of_prog/utils/linux/$arch_d/$mode" "$linux_tmpd"
488 chmod u+x "$linux_tmpd/$mode"
489
490 check_if_syslinux_runs "$linux_tmpd/$mode"
491 rc=$?
492
493 if [ "$rc" -eq 0 ]; then
494 case "$mode" in
495 syslinux)
496 echo "Running: \"$linux_tmpd/syslinux\" -d syslinux -f -i \"$target_part\""
497 # http://www.syslinux.org/wiki/index.php?title=SYSLINUX#Linux
498 "$linux_tmpd/syslinux" -d syslinux -f -i "$target_part"
499 s_rc="$?"
500 ;;
501 extlinux)
502 echo "Running: \"$linux_tmpd/extlinux\" -i \"$destfs_tmpd/syslinux\""
503 # http://www.syslinux.org/wiki/index.php?title=EXTLINUX
504 "$linux_tmpd/extlinux" -i "$destfs_tmpd/syslinux"
505 s_rc="$?"
506 ;;
507 esac
508 if [ "$s_rc" -ne 0 ]; then
509 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
510 echo "Failed to run $mode in installation mode!"
511 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
512 echo "Program terminated!"
513 exit 1
514 fi
515 # Success
516 if [ "$mode" = syslinux ]; then
517 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
518 echo "//NOTE// If your USB flash drive fails to boot (maybe buggy BIOS), try to use \"syslinux -d syslinux -fs $target_part\", i.e. running with \"-fs\"."
519 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
520 fi
521 [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS
522 echo "$mode ran successfully in installation mode."
523 echo "Done!"
524 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
525 else
526 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
527 echo "Failed to run $mode!"
528 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
529 echo "Program terminated!"
530 exit 1
531 fi
532
533 # Cleanup temporary copy
534 if [ -d "$linux_tmpd" -a -n "$(echo $linux_tmpd | grep "linux_tmp" )" ]; then
535 rm -rf $linux_tmpd
536 fi
537
538 # Umount destination if we mounted it
539 if mountpoint $destfs_tmpd >/dev/null 2>&1; then
540 if [ "$flag_mount" = "mounted" ]; then
541 umount $destfs_tmpd
542 fi
543 fi
544
545 # Remove mountpoint if we created it
546 if [ -d "$destfs_tmpd" -a -n "$(echo $destfs_tmpd | grep "destfs_tmpd" )" ]; then
547 rm -rf $destfs_tmpd
548 fi