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

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