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