wok view syslinux/stuff/iso2exe/init @ rev 21506

Update some web_site
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu May 02 18:27:43 2019 +0200 (2019-05-02)
parents ada21ebe1860
children daaaf5face8a
line source
1 #!/bin/sh
3 DIALOG=dialog
5 ddq()
6 {
7 dd $@ 2> /dev/null
8 }
10 get()
11 {
12 od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null ||
13 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" $2
14 }
16 getarg()
17 {
18 sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline
19 }
21 clear()
22 {
23 echo -e "\x1B[1;1H\x1B[J"
24 }
26 xless()
27 {
28 [ $(wc -l < "$1") -gt 22 ] &&
29 sed 's/..3.;4.m/===/g;$s/.*/&\n---\nPress q to continue/' "$1" | less ||
30 { cat "$1"
31 [ "$2" ] || return
32 echo -e "$2"
33 read n
34 }
35 }
37 tinydialog()
38 {
39 clear
40 label=""
41 while [ "$1" ]; do
42 case "$1" in
43 --title) title=" \x1B[30;47m$2\x1B[37;40m\n"
44 echo -e $title; shift ;;
45 --yes-label) label="$2" ; shift ;;
46 --textbox)
47 xless "$2" "\nPress RETURN to continue."
48 break;;
49 --gauge)
50 t=" "
51 echo -e "$t$2\n"
52 while read pct ; do
53 s=" "
54 s="$s$pct%$s"
55 pct=$((($pct*63)/100))
56 echo -en "\r$t\x1B[30;47m$(echo "$s" | cut -c-$pct)\x1B[37;40m$(echo "$s" | cut -c$(($pct+1))-)"
57 done
58 break;;
59 --yesno)
60 while true; do
61 clear
62 echo "$2" | sed 's/\\n\\n/\\n/g;s/\\n/\n/g'
63 echo -en " <- 1:${label:-Yes} 2:Cancel\r"
64 read x
65 case "$x" in
66 ''|Y*|y*|1) return 0;;
67 N*|n*|2|0) return 1;;
68 esac
69 done ;;
70 --menu|--radiolist)
71 [ "$1" = "--menu" ] && shft=2 || shft=3
72 label=""
73 [ "$2" ] && label="\n$2"
74 shift 5
75 echo -e "$title$label\n0 Cancel" > /tmp/data
76 n=1
77 while [ "$1" ]; do
78 eval key_$n='$1'
79 echo "$((n++)) $2"
80 shift $shft
81 done >> /tmp/data
82 while ! grep -q "^$n " /tmp/data ; do
83 clear
84 xless /tmp/data
85 echo -en "\n <- Enter the selection number\r"
86 read n
87 done 2> /dev/null
88 rm -f /tmp/data
89 [ $n -eq 0 ] && return 1
90 eval echo -n \$key_$n 1>&2
91 return 0;;
92 esac
93 shift
94 done
95 }
97 mount_proc()
98 {
99 mount -t proc /proc /proc
100 mount -t sysfs /sys /sys
101 udevd --daemon 2> /dev/null && udevadm trigger && sleep 5
102 }
104 umount_proc()
105 {
106 killall udevd 2> /dev/null
107 umount /sys/fs/fuse/connections 2> /dev/null
108 umount /sys
109 umount /proc
110 }
112 bytes2bin()
113 {
114 for i in $@ ; do
115 printf '\\\\x%02X' $(($i&255))
116 done | xargs echo -en
117 }
119 words2bin()
120 {
121 for i in $@ ; do
122 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
123 done | xargs echo -en
124 }
126 gettazboot()
127 {
128 echo -e "\nCreating $(basename $1) ..."
129 X=$(($(get 20 /mnt/$ISO) - 0xC0))
130 [ $X -lt 30000 ] && X=$((0x7FF0))
131 O=$(($(get 64 /mnt/$ISO) - 0xC0))
132 L=$(($X - $(get 24 /mnt/$ISO) - $O))
133 S=$((32+$L))
134 P=$((($S+511)/512))
135 E=$((4096-(32*$P)))
136 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
137 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
138 ddq bs=1 count=$(echo $L) skip=$(echo $O) if=/mnt/$ISO >> $1
139 }
141 checkmagic()
142 {
143 [ -s $1 ] && [ $(getarg magic) = $(get 18 $1 2) ]
144 }
146 getiso()
147 {
148 mkdir -p /media/cdrom
149 for dev in /sys/block/?d?/?d??* ; do
150 mount /dev/$(basename $dev) /mnt
151 if checkmagic /mnt/$ISO; then
152 mount -o loop,ro /mnt/$ISO /media/cdrom
153 echo "Found $ISO on $(basename $dev)"
154 return 0
155 fi
156 umount /mnt
157 done 2> /dev/null
158 return 1
159 }
161 uncpio()
162 {
163 [ -s "$1" ] || return
164 echo -en "\n Extracting $(basename $1) ..."
165 case $(get 0 $1) in
166 *35615) ( zcat || gunzip ) ;;
167 *14333) unxz ;;
168 *\ 93) unlzma ;;
169 *) cat ;;
170 esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
171 }
173 dotwait()
174 {
175 echo -n "${1:-Install filesystem}.."
176 echo -n > /tmp/wait
177 while [ -e /tmp/wait ]; do
178 echo -n "." > /dev/tty0
179 sleep 1
180 done &
181 }
183 getuuid()
184 {
185 dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q')
186 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/"
187 }
189 tazusbinitfs()
190 {
191 PAD=$(($(stat -c %s $1) % 4))
192 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
193 mkdir -p /tmp/fs/etc /tmp/fs/lib /tmp/fs/home
194 cp -a /etc/locale.conf /tmp/fs/etc 2> /dev/null
195 cp -a /etc/keymap.conf /tmp/fs/etc 2> /dev/null
196 sed 's/ .*//' /proc/modules | while read mod ; do
197 find /lib/modules/ | grep $mod.ko | \
198 sed 's|.*|cp & /tmp/fs/lib|' | sh
199 done
200 cat > /tmp/fs/init1 <<EOT
201 #!/bin/sh
202 sed -i 's|sbin/init|init2|' /init
203 exec /init
204 EOT
205 cat > /tmp/fs/init2 <<EOT
206 #!/bin/sh
208 mount -t proc /proc /proc
209 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
210 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
211 mount / -o remount,rw
212 mkdir /mnt/dos
213 rm -f /cmdline 2> /dev/null
214 mount / -o remount,ro
215 mnt=/mnt/dos/\${v#*/}
216 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
217 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
218 mount \$dev /mnt/dos
219 mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
220 mount --bind \$mnt /home
221 mount -o size=0,ro -t tmpfs tmpfs \$mnt
222 umount /proc
223 exec /sbin/init
224 EOT
225 chmod 755 /tmp/fs/init?
226 cp -a /tmp/fs/* /
227 ( cd /tmp/fs ; find * | cpio -o -H newc ) | gzip -9 >> $1
228 }
230 mkinitrd()
231 {
232 echo
233 dotwait "Creating $(basename $1) "
234 for i in bin lib dev proc tmp mnt etc ; do
235 mkdir -p /tmp/fs/$i
236 done
237 for i in /dev/console /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d* ; do
238 cp -a $i /tmp/fs$i
239 done
240 for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
241 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
242 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib
243 cp $i /tmp/fs/bin
244 done
245 cp -a /lib/ld-* /tmp/fs/lib
246 for i in $(busybox | sed '/Current/,$!d'); do
247 [ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,}
248 done
249 ln -s /proc/mounts /tmp/fs/etc/mtab
250 sed 's/ .*//' /proc/modules | while read mod ; do
251 find /lib/modules/ | grep $mod.ko | \
252 sed 's|.*|cp & /tmp/fs/lib|' | sh
253 done
254 cat > /tmp/fs/init <<EOT
255 #!/bin/sh
257 arg()
258 {
259 grep -q \$1 /proc/cmdline &&
260 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
261 echo "\$2 \$val"
262 }
264 mount -t proc /proc /proc
265 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
266 arg mount "Mount device"
267 mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
268 arg subroot "Change root to directory"
269 mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
270 mount --bind /mnt /mnt/\$val/mnt/dos
271 mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
272 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
273 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
274 umount /proc
275 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
276 EOT
277 chmod +x /tmp/fs/init
278 ( cd /tmp/fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
279 rm -rf /tmp/fs /tmp/wait
280 }
282 is_loram()
283 {
284 [ -s /lib/modules/squashfs.ko* ]
285 }
287 ls_r()
288 {
289 ls -r $@ 2> /dev/null || ls $@
290 }
292 doinstall()
293 {
294 mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos
295 if ! mount.posixovl -F /mnt/slitaz -- \
296 -oallow_other -odefault_permissions -osuid; then
297 echo "Can't install SliTaz. Abort."
298 sleep 5
299 return 1
300 fi
301 dotwait "Install root filesystem in /slitaz.."
302 if [ "$1" ]; then
303 if [ -d /media/cdrom/fs ]; then
304 ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9
305 else
306 ls_r /media/cdrom/boot/rootfs*gz | xargs cat
307 fi > /mnt/slitaz/boot/rootfs.gz
308 tazusbinitfs /mnt/slitaz/boot/rootfs.gz
309 initrd=rootfs.gz
310 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
311 else
312 if [ -d /media/cdrom/fs ]; then
313 cp -a /media/cdrom/fs/. /mnt/slitaz
314 elif is_loram ; then
315 for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
316 losetup -o 124 /dev/loop7 $i
317 mount -t squashfs -o ro /dev/loop7 /sqfs/mnt
318 cp -a /sqfs/mnt/. /mnt/slitaz
319 umount /sqfs/mnt
320 losetup -d /dev/loop7
321 done
322 else
323 for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
324 uncpio $i /mnt/slitaz
325 done
326 fi
327 mkinitrd /mnt/slitaz/boot/initrd
328 initrd=initrd
329 extraargs="mount=$(getuuid) subroot=slitaz"
330 fi
331 echo -en "\nInstall boot files..."
332 for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
333 /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
334 /media/cdrom/README /media/cdrom/boot/memtest* ; do
335 [ -s $i ] && cp $i /mnt/slitaz/boot
336 done
337 for i in /mnt/slitaz/boot/memtest /mnt/slitaz/boot/*pxe ; do
338 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
339 mv $i $i.exe
340 done
341 cp /etc/keymap.conf /etc/locale.conf /mnt/slitaz/etc 2> /dev/null
342 gettazboot /mnt/slitaz/boot/tazboot.exe
343 unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT
344 kernel=/slitaz/boot/bzimage
345 initrd=/slitaz/boot/$initrd
346 rw root=/dev/null $extraargs autologin
347 EOT
348 unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \
349 /mnt/slitaz/boot/README
350 [ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] &&
351 cp $(which mount.posixovl) /mnt/slitaz/usr/sbin
352 rm -f /tmp/wait
353 false &&
354 [ -s /mnt/boot.ini ] && ! grep -qs tazboot /mnt/boot.ini &&
355 echo "Update boot.ini ..." && unix2dos >> /mnt/boot.ini <<EOT
356 C:\\slitaz\\boot\\tazboot.exe="SliTaz"
357 EOT
358 false &&
359 grep -qis menuitem /mnt/config.sys && ! grep -qi tazboot /mnt/config.sys &&
360 echo "Update config.sys ..." &&
361 sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' /mnt/config.sys &&
362 unix2dos >> /mnt/config.sys <<EOT
363 [SLITAZ]
364 install=\\slitaz\\boot\\tazboot.exe
365 EOT
366 return 0
367 }
369 install()
370 {
371 $DIALOG --clear --title " SliTaz UMSDOS way installation " \
372 --yes-label "Install" --yesno \
373 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
374 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
375 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
376 To uninstall SliTaz, you have only to remove this directory.
377 The file \\boot.ini or \\config.sys may be modified too.\n\n
378 SliTaz may run slowly on the 'UMSDOS way' installation due to the
379 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
380 To do a traditional installation with disk partitioning,
381 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
382 [ $? -eq 0 ] || return
383 doinstall || return
384 [ -x /mnt/slitaz/sbin/init ] || return
385 umount -d /media/cdrom
386 umount_proc
387 exec chroot /mnt/slitaz /sbin/init
388 }
390 installtaz()
391 {
392 $DIALOG --clear --title " SliTaz TAZUSB way installation " \
393 --yes-label "Install" --yesno \
394 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
395 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
396 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
397 To uninstall SliTaz, you have only to remove this directory.
398 The file \\boot.ini or \\config.sys may be modified too.\n\n
399 The filesystem is loaded entirely into memory upon boot to
400 increase responsiveness. Only /home lands on the hard disk.\n\n
401 To do a traditional installation with disk partitioning,
402 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
403 [ $? -eq 0 ] || return
404 doinstall tazusblike || return
405 dotwait
406 if [ -d /media/cdrom/fs ]; then
407 cp -a /media/cdrom/fs/. /
408 else
409 for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
410 uncpio $i
411 done
412 fi
413 cp /tmp/fs/etc/* /etc
414 echo "/home=$(getuuid)/slitaz" > /cmdline
415 rm -f /tmp/wait
416 [ -x /init1 ] || return
417 umount -d /media/cdrom
418 umount /mnt/slitaz
419 rm -f /dev/cdrom
420 umount /mnt
421 mkdir /mnt/dos
422 umount_proc
423 exec /init1
424 }
426 tazboot()
427 {
428 $DIALOG --clear --title " SliTaz bootloader for DOS " \
429 --yes-label "Install" --yesno \
430 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
431 any linux kernel, multiple initramfs, a kernel command line and
432 an ISO image file loopback (retrieves files from an ISO file).\n\n
433 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
434 [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] cmdline args ...]\n\n
435 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
436 Examples for tazboot.cmd:\n\n\
437 bootfrom=\\isos\\slitaz-4.0.iso\n\
438 kernel=boot/bzImage\n\
439 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
440 rw root=/dev/null autologin\n\n\
441 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
442 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n" 24 78
443 [ $? -eq 0 ] || return
444 gettazboot /mnt/tazboot.exe
445 }
447 md5()
448 {
449 dotwait "Checking files"
450 ( cd /media/cdrom ; ${1:-md5sum -c md5sum*} | sort ) > /tmp/data
451 rm -f /tmp/wait
452 $DIALOG --clear --title " Checked files " --textbox /tmp/data 24 78
453 rm -f /tmp/data
454 }
456 gotcdfile()
457 {
458 for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \
459 "/media/cdrom/*/isolinux/$1" ; do
460 file=$(ls $i 2> /dev/null | sed q)
461 [ -s "$file" ] && break
462 done
463 }
465 sha()
466 {
467 gotcdfile "sha*sum*"
468 sha=$(basename $file)
469 md5 "${sha%sum*}sum -c ${file#/media/cdrom/}"
470 }
472 readme()
473 {
474 gotcdfile "README*"
475 $DIALOG --clear --title " Readme " --textbox $file 24 78
476 }
478 bootlog()
479 {
480 $DIALOG --clear --title " Linux boot messages " \
481 --textbox /tmp/dmesg 24 78
482 }
484 bzimage()
485 {
486 $DIALOG --clear --title " Create linux.exe ? " \
487 --yes-label "Install" --yesno \
488 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
489 The cmdline arguments are supported except initrd=,
490 vga= (you can try 'rdev -v') and mem= (partially).
491 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n
492 " 12 70
493 [ $? -eq 0 ] || return
494 cp /media/cdrom/boot/bzImage /mnt/linux.exe
495 }
497 memtest()
498 {
499 $DIALOG --clear --title " Create memtest.exe ? " \
500 --yes-label "Install" --yesno \
501 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
502 computers. BIOS based memory tests are a quick, cursory check and often
503 miss many of the failures that are detected by Memtest86.\n" 12 70
504 [ $? -eq 0 ] && gotcdfile "memtest*" && cp $file /mnt/memtest.exe
505 }
507 mkfat12()
508 {
509 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
510 J=$(($(get 3 $1 1) + 0x02))
511 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
512 [ $R -lt 2500 ] || return
513 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
514 ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
515 G="18 0 2 0 0 0 0 0"
516 [ $J -gt 25 ] || G=""
517 F=0
518 for i in 1 2 3; do
519 F=$((((2880-$R-$F-$F)*3+1023)/1024))
520 done
521 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
522 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
523 $G | ddq bs=1 of=/dev/fd0
524 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
525 for i in $R $(($R+$F)) ; do
526 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
527 done
528 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
529 }
531 mkfloppy()
532 {
533 dotwait "Create a $(basename $1 .exe) boot floppy"
534 ddq if=$1 of=/dev/fd0
535 mkfat12 $1
536 rm -f /tmp/wait
537 }
539 fdmemtest()
540 {
541 $DIALOG --clear --title " Create a Memtest86 boot floppy " \
542 --yes-label "Create floppy" --yesno \
543 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
544 computers. BIOS based memory tests are a quick, cursory check and often
545 miss many of the failures that are detected by Memtest86.\n\n
546 Please insert a blank disk in floppy drive.\n" 12 70
547 [ $? -eq 0 ] && gotcdfile "memtest*" && mkfloppy $file
548 }
550 pxe()
551 {
552 gotcdfile "?pxe*"
553 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
554 --yes-label "Install" --yesno \
555 "\nBoot your operating system from the internet and enjoy a full system
556 working entirely in RAM with speed and stability in mind. The Linux Kernel
557 and the complete SliTaz compressed root filesystem will be loaded into RAM
558 from the Web using PXE and HTTP protocols.\n" 12 70
559 [ $? -eq 0 ] || return
560 cp $file /mnt/$(basename $file .exe).exe
561 }
563 fdpxe()
564 {
565 $DIALOG --clear --title " Create a SliTaz Web boot floppy " \
566 --yes-label "Create floppy" --yesno \
567 "\nBoot your operating system from the internet and enjoy a full system
568 working entirely in RAM with speed and stability in mind. The Linux Kernel
569 and the complete SliTaz compressed root filesystem will be loaded into RAM
570 from the Web using PXE and HTTP protocols.\n\n
571 Please insert a blank disk in floppy drive.\n" 12 70
572 [ $? -eq 0 ] && gotcdfile "?pxe*" && mkfloppy $file
573 }
575 gotposixovl()
576 {
577 mount.posixovl 2>&1 | grep -qi usage &&
578 echo -en "\"$1\" \"$2\""
579 }
581 xfile()
582 {
583 [ "$(which $1)" ] && echo -en "\"$2\" \"$3\""
584 }
586 cdfile()
587 {
588 gotcdfile "$1" && echo -en "\"$2\" \"$3\""
589 }
591 isbzImage()
592 {
593 [ $(get 514 $file 4) -eq 1400005704 ] &&
594 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
595 }
597 cdfilex()
598 {
599 gotcdfile "$1" &&
600 [ "$(which kexec)" ] &&
601 isbzImage &&
602 echo -en "\"$2\" \"$3\""
603 }
605 cdfilef()
606 {
607 [ -e /sys/block/fd0 ] && cdfile "$@"
608 }
610 cdexe()
611 {
612 gotcdfile "$1" &&
613 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
614 echo -en "\"$2\" \"$3\""
615 }
617 fddata()
618 {
619 [ -e /sys/block/fd0 ] &&
620 [ $(get 26 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
621 echo -en "\"$1\" \"$2\""
622 }
624 ishybrid()
625 {
626 [ $(get 510 $ISO 2> /dev/null || echo 0) -eq 43605 ] || return
627 C=$((2048*$(get $(((17*2048) + 71)) /mnt/$ISO 4)))
628 [ $(get $C /mnt/$ISO 4) -eq 1 ] || return
629 [ $(get $(($C+30)) /mnt/$ISO 4) -eq $((0x88AA55)) ] || return
630 C=$((2048*$(get $(($C+40)) /mnt/$ISO 4)))
631 [ $(get $(($C+64)) /mnt/$ISO 4) -eq 1886961915 ] &&
632 echo -en "\"$1\" \"$2\""
633 }
635 burnable()
636 {
637 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
638 [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\""
639 }
641 blankable()
642 {
643 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
644 [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\""
645 }
647 burniso()
648 {
649 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
650 -eject -multi "$ISO"
651 }
653 blankcd()
654 {
655 wodim -v -blank=fast
656 }
658 customsector()
659 {
660 echo $(get 32848 "/mnt/$ISO" 4)
661 }
663 hascustomconf()
664 {
665 [ "$(ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | ddq bs=1 count=6)" \
666 = "#!boot" ]
667 }
669 gotcustomconf()
670 {
671 hascustomconf && echo -en "\"$1\" \"$2\""
672 }
674 getcustomconf()
675 {
676 cd ${1:-/mnt}
677 ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | while read line; do
678 case "$line" in
679 \#!boot*) ;;
680 append=*) echo ${line#append=} > cmdline && ls -l cmdline ;;
681 initrd:*) cnt=${line#initrd:}
682 { ddq bs=512 count=$(($cnt / 512));
683 ddq bs=1 count=$(($cnt % 512)); } > initrd &&
684 ls -l initrd
685 break ;;
686 *) break ;;
687 esac
688 done
689 cd - > /dev/null
690 [ -z "$1" ] && echo -e "\rPress RETURN to continue." && read n
691 }
693 gotisomd5()
694 {
695 [ "$(which md5sum 2> /dev/null)" ] &&
696 [ $(get 0 /mnt/$ISO) -eq 23117 ] &&
697 [ $(get 18 /mnt/$ISO) -ne 0 ] && echo -en "\"$1\" \"$2\""
698 }
700 isomd5()
701 {
702 dotwait "Checking iso image"
703 [ "$(ddq if=/mnt/$ISO bs=2k skip=16 \
704 count=$(($(get 32848 /mnt/$ISO 4)-16)) | md5sum)" = \
705 "$(ddq if=/mnt/$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
706 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
707 echo -en "\rChecking iso hybrid boot..."
708 n=$(($(get 2 /mnt/$ISO)-1+($(get 4 /mnt/$ISO)-1)*512))
709 if [ $n -lt 40000 -a $n -gt 32768 ]; then
710 s=$(get 0 /mnt/$ISO 2 $n | awk '{ i+= $0 } END { print i }')
711 [ $(((1+$s+$(get $(($n+1)) /mnt/$ISO 1)) % 65536)) -eq 0 ] &&
712 echo "OK" || echo "ERROR"
713 fi
714 if hascustomconf; then
715 echo -en "\rChecking iso custom config..."
716 TMP=/tmp/$(basename $0)$$md5
717 md5="$(ddq bs=2k skip=$(customsector) if=/mnt/$ISO | while read line; do
718 case "$line" in
719 \#!boot*) echo ${line#*boot } > $TMP ;;
720 append=*) echo $line ;;
721 initrd:*) echo $line
722 cnt=${line#initrd:}
723 ddq bs=512 count=$((cnt / 512))
724 ddq bs=1 count=$((cnt % 512))
725 break ;;
726 *) break ;;
727 esac
728 done | md5sum | cut -c1-32)"
729 [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
730 rm -f $TMP
731 fi
732 rm -f /tmp/wait
733 echo -e "\rPress RETURN to continue."
734 read n
735 }
737 if [ "$1" = "--build" ]; then #install-begin
738 cp $0 $0.tmp
739 uuencode -m - < ifmem.bin | sed -e 's|^[ \t]*||;s|[ \t]*###.*||' \
740 -e 's| *;;|;;|;s|\t\t*|\t|g' \
741 -e '/^ifmemcode$/r/dev/stdin' -e '/^ifmemcode$/d' -i $0.tmp
742 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
743 -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0.tmp
744 mv -f $0.tmp $0; exit
745 fi #install-end
746 parse_isolinux()
747 {
748 awk 'BEGIN { IGNORECASE=1 }
749 function multi(n)
750 {
751 auto=$n
752 for (--n; n < NF; n+=2) {
753 s=$n
754 if (s ~ /M$/) s = substr(s,0,length(s)-1)
755 else s /= 1024
756 sizes=int(s) " " sizes
757 }
758 next
759 }
760 {
761 if ($1 == "LABEL") {
762 label=$2
763 if (auto == "") auto=label
764 }
765 if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
766 if ($1 == "INITRD") initrd[label]=$2
767 if ($1 == "APPEND") {
768 i=2
769 if (kernel[label] ~ "ifmem.c32") multi(3)
770 if (kernel[label] ~ "c32box.c32") {
771 if ($2 == "linux") { kernel[label]=$3; i=4 }
772 if ($2 == "ifmem") multi(4)
773 }
774 if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
775 while (i <= NF) {
776 if ($i ~ "^initrd=") initrd[label]=substr($i,8)
777 else cmdline[label]=cmdline[label] " " $i
778 i++
779 }
780 }
781 }
782 END {
783 print "KERNEL=\"" kernel[auto] "\""
784 print "INITRD=\"" initrd[auto] "\""
785 print "CMDLINE=\"" substr(cmdline[auto],2) "\""
786 print "SIZES=\"" sizes "\""
787 }'
788 }
790 locase()
791 {
792 echo "$1" | tr [A-Z] [a-z]
793 }
795 ifmemcode()
796 {
797 uudecode <<EOT
798 ifmemcode
799 EOT
800 }
802 floppyset()
803 {
804 gotcdfile isolinux.cfg
805 parse_isolinux < $file > /tmp/var$$
806 . /tmp/var$$
807 for i in /media/cdrom/$KERNEL $(dirname $file)/$KERNEL /media/cdrom/$(locase $KERNEL) \
808 $(dirname $file)/$(locase $KERNEL); do
809 [ -s $i ] && KERNEL=$i && break
810 done
811 rm -f /tmp/var$$
812 [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
813 n=$(($(get 497 $KERNEL 1)+1))
814 ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
815 uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc
816 bootloader
817 EOT
818 pos=$(($n*512))
819 if [ -n "$CMDLINE" ]; then
820 echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
821 bytes2bin $n | ddq conv=notrunc \
822 bs=1 seek=497 count=1 of=/tmp/fd$$
823 words2bin $pos | ddq conv=notrunc \
824 bs=1 seek=34 count=2 of=/tmp/fd$$
825 [ $(get 518 $KERNEL 4) -ge 514 ] &&
826 words2bin 32768 9 | ddq conv=notrunc \
827 bs=1 seek=552 count=4 of=/tmp/fd$$
828 fi
829 syssize=$(echo $(get 500 /tmp/fd$$ 4))
830 ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
831 ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$
832 base=$(stat -c %s /tmp/fd$$)
833 len=
834 if [ "$INITRD" ]; then
835 l=0
836 for i in ${INITRD//,/ }; do
837 for j in /media/cdrom/$i $(dirname $KERNEL)/$i /media/cdrom/$(locase $i) \
838 $(dirname $KERNEL)/$(locase $i); do
839 [ -s $j ] && i=$j && break
840 done
841 ddq if=$i >> /tmp/fd$$
842 l=$(($l+$(stat -c %s $i)))
843 r=$((4 - ($l % 4)))
844 if [ $r -ne 4 ]; then
845 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
846 l=$(($l + $r))
847 fi
848 case "$i:$INITRD" in
849 *rootfs.gz:*rootfs.gz,*) continue ### loram
850 esac
851 len="$len $l"; l=0
852 done
853 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
854 words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
855 conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
856 fi
857 n=$(echo $len | wc -w)
858 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
859 i=$(($(get 494 /tmp/fd$$)))
860 bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
861 seek=496 count=1 of=/tmp/fd$$
862 else
863 i=$(($pos + 0x1FC - ($n*4)))
864 bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
865 conv=notrunc seek=494 count=3 of=/tmp/fd$$
866 s=$(($i - 2*$(echo "$SIZES" | wc -w)))
867 p=$(($s - $(ifmemcode | wc -c)))
868 ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
869 words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
870 bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
871 ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
872 fi
873 for r in $len ; do
874 words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
875 bs=1 seek=$i count=4 of=/tmp/fd$$
876 i=$(($i + 4))
877 done
878 split -b 1440k /tmp/fd$$ fd$$
879 rm -f /tmp/fd$$
880 n=1; i=0; r=0
881 set -- $len
882 ls fd$$* | while read file ; do
883 if [ $i -gt $(($1+$base)) ]; then
884 shift
885 r=$(($r+100)); n=0; i=0; base=0
886 fi
887 ddq of=$file bs=18k seek=80 count=0
888 i=$(($i+1474560))
889 printf "mv %s fd%03d.img\n" $file $(($r+$n))
890 n=$(($n+1))
891 done | sh
892 ls fd???.img
893 mv fd???.img /mnt
894 }
896 fdbootstrap()
897 {
898 sz=$((512 * $(echo $(get 26 /mnt/$ISO 1))))
899 $DIALOG --clear --title " Create a floppy bootstrap " \
900 --yes-label "Continue" --yesno \
901 "\nThe floppy will install a driver to access the ISO file
902 on your hard disk and will emulate a CD-ROM during the boot process.\n\n
903 Please insert a floppy in drive now.\n" 10 70
904 [ $? -eq 0 ] || return
905 ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=512 \
906 skip=$(( $(get 64 /mnt/$ISO) - $sz ))
907 echo "$ISO" | ddq of=/tmp/bootiso bs=512 seek=1 count=1
908 ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=$sz seek=2 \
909 skip=$(( $(get 64 /mnt/$ISO) - $sz + 512 ))
910 mkfloppy /tmp/bootiso
911 rm -f /tmp/bootiso
912 }
914 usbdev()
915 {
916 dotwait "Wait 5 seconds for USB devices"
917 sleep 5
918 rm -f /tmp/wait
919 DEV="$(grep -l 1 /sys/block/*/removable | \
920 sed 's|/sys/block/\(.*\)/removable|\1|')"
921 grep -qs 1 /sys/block/$DEV/ro && return
922 [ "$DEV" ] || return
923 cat > /tmp/dialog <<EOT
924 $DIALOG --clear --title " Select your USB key " \
925 --menu "\nPlease select the USB key according to its known size.\n\n" \
926 14 70 4 \
927 $(for i in $DEV ; do
928 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
929 done)
930 EOT
931 exec 3>&1
932 device=$(. /tmp/dialog 2>&1 1>&3)
933 retval=$?
934 exec 3>&-
935 [ $retval -eq 0 ]
936 }
938 tazusbmsg()
939 {
940 [ "$(which tazusb 2> /dev/null)" ] || return
941 echo "You should choose 'USB key read/write installation' to be
942 able to save the package updates or your own configuration and data files.\n\n"
943 }
945 usbbootkey()
946 {
947 $DIALOG --clear --title " Create a USB boot key " \
948 --yes-label "Continue" --yesno \
949 "\nThe USB key will be used like a CD-ROM. You will not be able to write
950 any data on the boot partition.\n\n
951 An extra FAT32 partition will be created with the remaining free space.\n\n
952 $(tazusbmsg)Please plug your USB stick in now.\n" 16 70
953 [ $? -eq 0 ] || return
954 usbdev || return
956 ### perform dd in progress bar
957 max=$(($(cat /sys/block/loop0/size)/2048))
958 i=0; ddq if=/mnt/$ISO bs=1024k | (
959 while ddq bs=1024k count=1 ; do
960 i=$(($i + 1))
961 [ $i -gt $max ] && break
962 echo $((($i*100)/$max)) | dialog --gauge \
963 " The ISO image transfer can be long. Please wait..." \
964 6 70 0 > /dev/tty0 2>&1
965 done ) > $device
967 ### partition + fat32 format for the remaining space
968 for p in 0 16; do
969 get $((450+$p)) $device 2 12 | xargs echo | {
970 read dx cx ol oh ll lh
971 [ $dx -eq $((0x3F17)) ] || continue
972 cx=$(($cx & 0xFF00))
973 ofs=$(($ll+($lh<<16)))
974 n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs))
975 m=$(($cx+($n/8)))
976 [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00))
977 m=$((($m & 0xFF00)+(($m>>16)<<6)))
978 words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \
979 $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \
980 ddq bs=1 seek=$((462-$p)) of=$device
981 if [ "$(which mkdosfs 2> /dev/null)" ]; then
982 losetup -o $((512*$ofs)) /dev/loop2 $device
983 mkdosfs -n "SLITAZ BOOT" /dev/loop2
984 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \
985 ddq bs=1 seek=28 of=/dev/loop2
986 sync
987 losetup -d /dev/loop2
988 fi
989 }
990 done
991 }
993 usbkey()
994 {
995 $DIALOG --clear --title " Create a SliTaz USB key " \
996 --yes-label "Continue" --yesno \
997 "\nUnlike a hard drive install, the filesystem is kept in a compressed
998 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
999 This should increase responsiveness, protect the filesystem against
1000 accidental corruption and reduce read/writes to the USB drive.
1001 Once setup, the tazusb utility can rewrite the root filesystem
1002 with any changes you have made since booting up,
1003 giving the effective benefits of a hard drive install.\n\n
1004 /home is mounted on boot using the UUID of your particular flash drive.
1005 Unlike a device name, the UUID has the benefit of never changing from machine
1006 to machine.\n\n
1007 Please plug your USB stick in now.\n" 19 70
1008 [ $? -eq 0 ] || return
1009 usbdev || return
1010 exec 3>&1
1011 format=`$DIALOG --clear --title " Select the filesystem " \
1012 --radiolist "\nPlease select the filesystem type to create.\n\n\
1013 The filesystem creation will erase all the data \
1014 in the USB key." 14 70 4 \
1015 "none" "Do not erase the USB key" on \
1016 "ext3" "Ext3 journaling filesystem" off \
1017 "ext2" "Ext2 filesystem" off \
1018 "fat32" "Windows FAT32 filesystem" off \
1019 2>&1 1>&3`
1020 retval=$?
1021 exec 3>&-
1022 [ $retval -eq 0 ] || return
1023 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
1024 tazusb gen-iso2usb /mnt/$ISO $device
1027 mount_loram()
1029 is_loram || return
1030 insmod /lib/modules/squashfs.ko* 2> /dev/null
1031 if [ -d /media/cdrom/fs ]; then
1032 ln -s /media/cdrom/fs /sqfs
1033 else
1034 mkdir /sqfs
1035 mount -o loop,ro -t squashfs /rootfs*.gz /sqfs
1036 fi
1037 cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /sqfs/dev/[hs]d* /dev
1038 ln -s /sqfs/lib/* lib
1039 ln -fs /sqfs/usr /sqfs/var /
1040 mkdir /etc && cp /sqfs/etc/dialogrc /etc 2> /dev/null
1043 umount_loram()
1045 is_loram || return
1046 rm /var /usr
1047 umount -d /sqfs
1048 rmdir /sqfs 2> /dev/null || rm -f /sqfs
1051 dosync()
1053 sync
1054 umount_loram
1055 umount -d /media/cdrom
1056 rm -f /dev/cdrom
1057 umount /mnt
1058 umount_proc
1061 text()
1063 init=
1064 cmdline="$(cat /proc/cmdline)"
1065 if hascustomconf; then
1066 getcustomconf /tmp > /dev/null
1067 [ -s /tmp/cmdline ] &&
1068 cmdline="$cmdline $(cat /tmp/cmdline)" &&
1069 init="$(sed '/rdinit=/!d;s/.*rdinit=\([^ ]*\).*/\1/' < /tmp/cmdline)"
1070 [ -s /tmp/initrd ] && uncpio /tmp/initrd
1071 fi
1072 dosync
1073 exec ${init:-/init} $cmdline
1076 live()
1078 n=0
1079 dotwait "Extract filesystem..."
1080 for i in $(ls_r /media/cdrom/boot/rootfs*gz); do
1081 grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
1082 [ $((n++)) -eq 0 ] || uncpio $i
1083 done
1084 rm -f /tmp/wait
1085 text
1088 restart()
1090 dosync
1091 reboot -f
1094 stop()
1096 dosync
1097 poweroff -f
1100 dokexec()
1102 kexec -l $file || return
1103 dosync
1104 kexec -e
1107 runmemtest()
1109 gotcdfile "memtest*" && dokexec
1112 runpxe()
1114 gotcdfile "?pxe*" && dokexec
1117 flavdata()
1119 [ $(get 1024 /mnt/$ISO) -eq 35615 ] && n=2 ||
1120 n=$((1+$(get 417 /mnt/$ISO 1)))
1121 [ $n -eq 4 ] && n=20
1122 [ $(get $(($n*512)) /mnt/$ISO) -eq 35615 ] || n=13
1123 ddq if=/mnt/$ISO bs=512 skip=$n count=20 | zcat 2>/dev/null
1126 hasflavinfo()
1128 [ "$(flavdata | ddq bs=1 count=7)" = "0707010" ] &&
1129 echo -en "\"$1\" \"$2\""
1132 showfavinfo()
1134 mkdir -p /tmp/data
1135 flavdata | ( cd /tmp/data ; cpio -i )
1136 file=/tmp/data/info
1137 cat /tmp/data/*desc > $file
1138 for i in /tmp/data/*list* ; do
1139 echo "=== extra ${i#*list} files"
1140 cat $i
1141 done >> $file
1142 $DIALOG --clear --title " Flavor info " --textbox $file 24 78
1143 rm -rf /tmp/data
1146 flavor()
1148 cd /mnt
1149 name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
1150 echo "Create ${name:=flavor}.flavor..."
1151 tazlito iso2flavor "/mnt/$ISO" $name
1152 ls -l $name.flavor 2> /dev/null || sleep 5
1153 cd - > /dev/null
1156 shell()
1158 trap text 2
1159 getty -n -l /bin/ash 38400 tty1 2> /dev/null || sh
1162 BIN=bin/mount.posixovl
1163 [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \
1164 /usr/s$BIN 2> /dev/null || mv /bin/mount.posixovl.iso2exe /$BIN 2> /dev/null
1165 mount_proc
1166 for i in /sys/block/*/dev /sys/block/*/*/dev ; do
1167 [ -s "$i" ] || continue
1168 n=${i%/dev}
1169 n=/dev/${n##*/}
1170 [ -e $n ] && continue
1171 mknod $n b $(sed 's/:/ /' < $i)
1172 done
1173 ISO="$(getarg bootfrom | sed 's/.://;s|\\|/|g')"
1174 getiso || text 2> /dev/null
1175 mount_loram
1176 case "${ISO##*/}$(getarg mode)" in
1177 *install*|*INSTALL*) install ;;
1178 *live*|*LIVE*) live ;;
1179 *text*|*TEXT*) text ;;
1180 esac
1181 which $DIALOG 2> /dev/null || DIALOG=tinydialog
1182 dmesg > /tmp/dmesg
1184 isotitle="$(blkid /mnt/$ISO | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
1185 -c %y /media/cdrom | sed 's/ .*//') $(basename $ISO)"
1186 while true; do
1187 trap shell 2
1188 keymap="$(cat /etc/keymap.conf 2> /dev/null)"
1189 locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2> /dev/null)"
1190 cat > /tmp/dialog <<EOT
1191 $DIALOG --clear --title " ${isotitle:-Welcome to Linux} " \
1192 --menu "" 23 70 17 \
1193 $(xfile tazkeymap "tazkeymap" "Select keyboard (${keymap:-none})") \
1194 $(xfile tazlocale "tazlocale" "Select locale (${locale:-none})") \
1195 $(cdfile boot/bzImage "live" "Linux RAM boot (full desktop)") \
1196 "text" "Linux RAM boot" \
1197 $(cdfile "README*" "readme" "Show the README file") \
1198 $(gotcustomconf "getcustomconf" "Get custom config") \
1199 $(gotisomd5 "isomd5" "Check the ISO image") \
1200 $(cdfile "md5sum*" "md5" "Check the ISO files") \
1201 $(cdfile "sha*sum*" "sha" "Check the ISO files") \
1202 $(burnable "burniso" "Burn the ISO image") \
1203 $(blankable "blankcd" "Blank the CD/DVD") \
1204 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
1205 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
1206 $(xfile tazusb "usbkey" "USB key read/write installation") \
1207 $(ishybrid "usbbootkey" "USB boot key (read only)") \
1208 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
1209 $(xfile tazlito "flavor" "Get flavor file") \
1210 $(fddata "fdbootstrap" "Create a floppy bootstrap") \
1211 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
1212 "tazboot" "Get tazboot.exe Linux loader" \
1213 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \
1214 $(cdexe "memtest*" "memtest" "Get Memtest86 DOS/EXE file") \
1215 $(cdfilef "memtest*" "fdmemtest" "Create a Memtest86 boot floppy") \
1216 $(:||cdfilex "memtest*" "runmemtest" "Start Memtest86") \
1217 $(cdexe "?pxe*" "pxe" "Get SliTaz Web boot DOS/EXE utility") \
1218 $(cdfilef "?pxe*" "fdpxe" "Create a SliTaz Web boot floppy") \
1219 $(:||cdfilex "?pxe*" "runpxe" "Start the SliTaz Web boot utility") \
1220 $(xfile reboot "restart" "Restart the computer") \
1221 $(xfile poweroff "stop" "Power off") \
1222 "bootlog" "Linux boot messages" \
1223 "shell" "Shell prompt"
1224 EOT
1225 exec 3>&1
1226 value=$(. /tmp/dialog 2>&1 1>&3)
1227 retval=$?
1228 exec 3>&-
1229 [ $retval -eq 0 ] || continue
1230 $value
1231 done