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

syslinux/iso2exe: add --undo
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Dec 17 12:25:20 2014 +0100 (2014-12-17)
parents 3e7ad70145ce
children aa3f469a31d7
line source
1 #!/bin/sh
3 DIALOG=dialog
5 get()
6 {
7 od -j $1 -N ${3:-2} -t u${3:-2} -An $2 2> /dev/null ||
8 hexdump -s $1 -n ${3:-2} -e "\"\" 1/${3:-2} \"%d\"" $2
9 }
11 getarg()
12 {
13 sed "/$1=/!d;s/.*$1=\\([^ ]*\\).*/\\1/" /proc/cmdline
14 }
16 mount_proc()
17 {
18 mount -t proc /proc /proc
19 mount -t sysfs /sys /sys
20 udevd --daemon 2> /dev/null && udevadm trigger && sleep 5
21 }
23 umount_proc()
24 {
25 killall udevd 2> /dev/null
26 umount /sys/fs/fuse/connections 2> /dev/null
27 umount /sys
28 umount /proc
29 }
31 gettazboot()
32 {
33 echo "Creating $(basename $1) ..."
34 O=$(($(get 66 /mnt/$ISO) - 0xC0))
35 L=$((0x7EE0 - $(get 24 /mnt/$ISO) - $O))
36 S=$((32+$L))
37 P=$((($S+511)/512))
38 E=$((4096-(32*$P)))
39 for i in 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
40 -2 0 256 -16 28 0x6C53 0x5469 0x7A61; do
41 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) | \
42 xargs echo -en
43 done > $1
44 dd bs=1 count=$L skip=$(echo $O) if=/mnt/$ISO >> $1 2> /dev/null
45 }
47 checkmagic()
48 {
49 [ -s $1 ] && [ $(getarg magic) == $(get 24 $1 4) ]
50 }
52 getiso()
53 {
54 mkdir -p /media/cdrom
55 blkid | while read dev info ; do
56 mount ${dev%:} /mnt
57 if checkmagic /mnt/$ISO; then
58 mount -o loop,ro /mnt/$ISO /media/cdrom
59 echo "Found $ISO on ${dev%:}"
60 break
61 fi
62 umount /mnt
63 done
64 }
66 uncpio()
67 {
68 echo "Extracting $(basename $1) ..."
69 case $(get 0 $1) in
70 *35615) ( zcat || gunzip ) ;;
71 *\ 93) unlzma ;;
72 *) cat ;;
73 esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
74 }
76 getuuid()
77 {
78 dev=$(mount | sed '/ \/mnt /!d;s/ .*//;s|/dev/||;q')
79 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/"
80 }
82 tazusbinitfs()
83 {
84 PAD=$(($(stat -c %s $1) % 4))
85 [ $PAD -ne 0 ] && dd if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
86 mkdir -p /tmp/fs/etc /tmp/fs/lib /tmp/fs/home
87 cp -a /etc/locale.conf /tmp/fs/etc 2> /dev/null
88 cp -a /etc/keymap.conf /tmp/fs/etc 2> /dev/null
89 sed 's/ .*//' /proc/modules | while read mod ; do
90 find /lib/modules/ | grep $mod.ko | \
91 sed 's|.*|cp & /tmp/fs/lib|' | sh
92 done
93 cat > /tmp/fs/init1 <<EOT
94 #!/bin/sh
95 sed -i 's|sbin/init|init2|' /init
96 exec /init
97 EOT
98 cat > /tmp/fs/init2 <<EOT
99 #!/bin/sh
101 mount -t proc /proc /proc
102 grep -q debug /proc/cmdline && debug=true && set -x
103 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
104 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
105 mount / -o remount,rw
106 mkdir /mnt/dos
107 rm -f /cmdline 2> /dev/null
108 mount / -o remount,ro
109 mnt=/mnt/dos/\${v#*/}
110 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
111 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
112 mount \$dev /mnt/dos
113 mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
114 mount --bind \$mnt /home
115 [ "\$debug" = "true" ] && sh
116 umount /proc
117 exec /sbin/init
118 EOT
119 chmod 755 /tmp/fs/init?
120 cp -a /tmp/fs/* /
121 ( cd /tmp/fs ; find * | cpio -o -H newc ) | gzip -9 >> $1
122 }
124 mkinitrd()
125 {
126 echo "Creating $(basename $1) ..."
127 for i in bin lib dev proc tmp mnt etc ; do
128 mkdir -p /tmp/fs/$i
129 done
130 for i in /dev/console /dev/null /dev/tty /dev/tty1 /dev/tty2 /dev/fuse \
131 /dev/hd* /dev/sd* ; do
132 cp -a $i /tmp/fs$i
133 done
134 for i in /bin/busybox $(which mount.posixovl) $(which blkid); do
135 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
136 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib
137 cp $i /tmp/fs/bin
138 done
139 cp -a /lib/ld-* /tmp/fs/lib
140 for i in $(busybox | sed '/Current/,$!d'); do
141 [ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,}
142 done
143 ln -s /proc/mounts /tmp/fs/etc/mtab
144 sed 's/ .*//' /proc/modules | while read mod ; do
145 find /lib/modules/ | grep $mod.ko | \
146 sed 's|.*|cp & /tmp/fs/lib|' | sh
147 done
148 cat > /tmp/fs/init <<EOT
149 #!/bin/sh
151 arg()
152 {
153 grep -q \$1 /proc/cmdline &&
154 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
155 echo "\$2 \$val"
156 }
158 mount -t proc /proc /proc
159 arg debug "shell" && debug=true && set -x
160 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
161 arg mount "Mount device"
162 mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt
163 arg subroot "Change root to directory"
164 mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
165 mount --bind /mnt /mnt/\$val/mnt/dos
166 #mount -o size=0 -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
167 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
168 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
169 [ "$debug" = "true" ] && sh
170 umount /proc
171 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
172 EOT
173 chmod +x /tmp/fs/init
174 ( cd /tmp/fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
175 rm -rf /tmp/fs
176 }
178 is_loram()
179 {
180 [ -s /lib/squashfs.ko* ]
181 }
183 ls_r()
184 {
185 ls -r $@ 2> /dev/null || ls $@
186 }
188 doinstall()
189 {
190 mkdir -p /mnt/slitaz/boot /mnt/slitaz/mnt/dos
191 if ! mount.posixovl -F /mnt/slitaz -- \
192 -oallow_other -odefault_permissions -osuid; then
193 echo "Can't install SliTaz. Abort."
194 sleep 5
195 return 1
196 fi
197 echo "Install root filesystem in /slitaz..."
198 if [ -n "$1" ]; then
199 if [ -d /media/cdrom/fs ]; then
200 ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9
201 else
202 ls_r /media/cdrom/boot/rootfs* | xargs cat
203 fi > /mnt/slitaz/boot/rootfs.gz
204 tazusbinitfs /mnt/slitaz/boot/rootfs.gz
205 initrd=rootfs.gz
206 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
207 else
208 if [ -d /media/cdrom/fs ]; then
209 cp -a /media/cdrom/fs/. /mnt/slitaz
210 elif is_loram ; then
211 for i in /media/cdrom/boot/rootfs?.* ; do
212 [ -s $(basename $i) ] && continue
213 cpio -i $i
214 done
215 for i in $(ls_r /media/cdrom/boot/rootfs*); do
216 mount -o loop,ro $i /sqfs/mnt
217 cp -a /sqfs/mnt/. /mnt/slitaz
218 umount -d /sqfs/mnt
219 done
220 else
221 for i in $(ls_r /media/cdrom/boot/rootfs*); do
222 uncpio $i /mnt/slitaz
223 done
224 fi
225 cp -a /etc/locale.conf /tmp/slitaz/etc 2> /dev/null
226 cp -a /etc/keymap.conf /tmp/slitaz/etc 2> /dev/null
227 mkinitrd /mnt/slitaz/boot/initrd
228 initrd=initrd
229 extraargs="mount=$(getuuid) subroot=slitaz"
230 fi
231 echo "Install boot files..."
232 for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \
233 /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \
234 /media/cdrom/README /media/cdrom/boot/memtest* ; do
235 [ -s $i ] && cp $i /mnt/slitaz/boot
236 done
237 for i in /mnt/slitaz/boot/memtest /mnt/slitaz/boot/*pxe* ; do
238 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
239 mv $i $i.exe
240 done
241 gettazboot /mnt/slitaz/boot/tazboot.exe
242 unix2dos > /mnt/slitaz/boot/tazboot.cmd <<EOT
243 kernel=/slitaz/boot/bzimage
244 initrd=/slitaz/boot/$initrd
245 rw root=/dev/null $extraargs autologin
246 EOT
247 unix2dos /mnt/slitaz/boot/he* /mnt/slitaz/boot/opt* \
248 /mnt/slitaz/boot/README
249 [ -d /mnt/slitaz/usr/sbin -a ! -x /mnt/slitaz/usr/sbin/mount.posixovl ] &&
250 cp $(which mount.posixovl) /mnt/slitaz/usr/sbin
251 false &&
252 ! grep -qs tazboot /mnt/boot.ini && echo "Update boot.ini ..." &&
253 unix2dos >> /mnt/boot.ini <<EOT
254 C:\\slitaz\\boot\\tazboot.exe="SliTaz"
255 EOT
256 false &&
257 grep -qis menuitem /mnt/config.sys && ! grep -qi tazboot /mnt/config.sys &&
258 echo "Update config.sys ..." &&
259 sed -i 's/menudefault/menuitem SLITAZ, SliTaz\r\n&/' /mnt/config.sys &&
260 unix2dos >> /mnt/config.sys <<EOT
261 [SLITAZ]
262 install=\\slitaz\\boot\\tazboot.exe
263 EOT
264 return 0
265 }
267 install()
268 {
269 $DIALOG --clear \
270 --title " SliTaz UMSDOS way installation " \
271 --yes-label "Install" --yesno \
272 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
273 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
274 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
275 To uninstall SliTaz, you have only to remove this directory.
276 The file \\boot.ini or \\config.sys may be modified too.\n\n
277 SliTaz may run slowly on 'UMSDOS way' installation due to the
278 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
279 To do a traditional installation with disk partitioning,
280 start SliTaz Live with 'SliTaz RAM boot' menu.\n
281 " 19 70
282 [ $? -eq 0 ] || return
283 doinstall || return
284 [ -x /mnt/slitaz/sbin/init ] || return
285 umount -d /media/cdrom
286 umount_proc
287 exec chroot /mnt/slitaz /sbin/init
288 }
290 installtaz()
291 {
292 $DIALOG --clear \
293 --title " SliTaz TAZUSB way installation " \
294 --yes-label "Install" --yesno \
295 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
296 DOS/Windows partition. You will see your files from /mnt/dos.\n\n
297 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
298 To uninstall SliTaz, you have only to remove this directory.
299 The file \\boot.ini or \\config.sys may be modified too.\n\n
300 The filesystem is loaded entirely into memory upon boot to
301 increase responsiveness. Only /home lands on hard disk.\n\n
302 To do a traditional installation with disk partitioning,
303 start SliTaz Live with 'SliTaz RAM boot' menu.\n
304 " 19 70
305 [ $? -eq 0 ] || return
306 doinstall tazusblike || return
307 if [ -d /media/cdrom/fs ]; then
308 cp -a /media/cdrom/fs/. /
309 else
310 for i in $(ls_r /media/cdrom/boot/rootfs*); do
311 unlzma < $i | (cd / ; cpio -idmu )
312 done
313 fi
314 cp /tmp/fs/etc/* /etc
315 echo "/home=$(getuuid)/slitaz" > /cmdline
316 [ -x /init1 ] || return
317 umount -d /media/cdrom
318 umount /mnt/slitaz
319 rm -f /dev/cdrom
320 umount /mnt
321 mkdir /mnt/dos
322 umount_proc
323 exec /init1
324 }
326 tazboot()
327 {
328 $DIALOG --clear \
329 --title " SliTaz bootloader for DOS " \
330 --yes-label "Install" --yesno \
331 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
332 a bzImage linux kernel, multiple initramfs, a kernel command line and
333 an ISO image file loopback (retrieves files from an ISO file).\n\n
334 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
335 [initrd=<rootfs>[,<rootfs2>...]] [iso=<isofile>] cmdline args ...]\n\n
336 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
337 Examples for tazboot.cmd:\n\n\
338 iso=\\isos\\slitaz-4.0.iso\n\
339 kernel=boot/bzImage\n\
340 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
341 rw root=/dev/null autologin\n\n\
342 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
343 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n
344 " 24 78
345 [ $? -eq 0 ] || return
346 gettazboot /mnt/tazboot.exe
347 }
349 md5()
350 {
351 echo "Checking files..."
352 ( cd /media/cdrom ; md5sum -c md5sum ) > /tmp/data
353 $DIALOG --clear \
354 --title " Checked files " \
355 --textbox /tmp/data 24 78
356 rm -f /tmp/data
357 }
359 readme()
360 {
361 $DIALOG --clear \
362 --title " Readme " \
363 --textbox /media/cdrom/README 24 78
364 }
366 bootlog()
367 {
368 $DIALOG --clear \
369 --title " Linux boot messages " \
370 --textbox /tmp/dmesg 24 78
371 }
373 memtest()
374 {
375 $DIALOG --clear \
376 --title " Memtest86 " \
377 --yes-label "Install" --yesno \
378 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
379 computers. BIOS based memory tests are a quick, cursory check and often
380 miss many of the failures that are detected by Memtest86.\n
381 " 12 70
382 [ $? -eq 0 ] || return
383 cp /media/cdrom/boot/memtest /mnt/memtest.exe
384 }
386 fdmemtest()
387 {
388 $DIALOG --clear \
389 --title " Create a Memtest86 boot floppy " \
390 --yes-label "Create floppy" --yesno \
391 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
392 computers. BIOS based memory tests are a quick, cursory check and often
393 miss many of the failures that are detected by Memtest86.\n\n
394 Please insert a blank disk in floppy drive.\n
395 " 12 70
396 [ $? -eq 0 ] || return
397 dd if=/media/cdrom/boot/memtest of=/dev/fd0
398 }
400 pxe()
401 {
402 $DIALOG --clear \
403 --title " SliTaz Web boot " \
404 --yes-label "Install" --yesno \
405 "\nBoot your operating system from the internet and enjoy a full system
406 working entirely in RAM with speed and stability in mind. The Linux Kernel
407 and the complete SliTaz compressed root filesystem will be loaded into RAM
408 from the Web using PXE and HTTP protocols.\n
409 " 12 70
410 [ $? -eq 0 ] || return
411 pxe=$(ls /media/cdrom/boot/?pxe)
412 cp $pxe /mnt/$(basename $pxe).exe
413 }
415 fdpxe()
416 {
417 $DIALOG --clear \
418 --title " Create a SliTaz Web boot floppy " \
419 --yes-label "Create floppy" --yesno \
420 "\nBoot your operating system from the internet and enjoy a full system
421 working entirely in RAM with speed and stability in mind. The Linux Kernel
422 and the complete SliTaz compressed root filesystem will be loaded into RAM
423 from the Web using PXE and HTTP protocols.\n\n
424 Please insert a blank disk in floppy drive.\n
425 " 12 70
426 [ $? -eq 0 ] || return
427 dd if=/media/cdrom/boot/?pxe of=/dev/fd0
428 }
430 gotposixovl()
431 {
432 mount.posixovl 2>&1 | grep -qi usage &&
433 echo -en "\"$1\" \"$2\""
434 }
436 xfile()
437 {
438 [ -n "$(which $1)" ] && echo -en "\"$2\" \"$3\""
439 }
441 cdfile()
442 {
443 [ -s /media/cdrom/$1 ] && echo -en "\"$2\" \"$3\""
444 }
446 cdexe()
447 {
448 [ $(get 0 /media/cdrom/$1 2> /dev/null || echo 0) -eq 23117 ] &&
449 echo -en "\"$2\" \"$3\""
450 }
452 fddata()
453 {
454 [ $(get 28 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] &&
455 echo -en "\"$1\" \"$2\""
456 }
458 fdbootstrap()
459 {
460 sz=$((512 * $(echo $(get 28 /mnt/$ISO 1))))
461 $DIALOG --clear \
462 --title " Create a floppy bootstrap " \
463 --yes-label "Continue" --yesno \
464 "\nThe floppy will install a driver to access the ISO file
465 on your hard disk and will emulate a CD-ROM during the boot process.\n\n
466 Please insert a floppy in drive now.\n
467 " 10 70
468 [ $? -eq 0 ] || return
469 dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=512 \
470 skip=$(( $(get 66 /mnt/$ISO) - $sz ))
471 echo "$ISO" | dd of=/dev/fd0 bs=512 seek=1 count=1
472 dd if=/mnt/$ISO of=/dev/fd0 bs=1 count=$sz seek=2 \
473 skip=$(( $(get 66 /mnt/$ISO) - $sz + 512 ))
474 }
476 usbdev()
477 {
478 sleep 5
479 DEV="$(grep -l 1 /sys/block/*/removable | \
480 sed 's|/sys/block/\(.*\)/removable|\1|')"
481 [ -n "$DEV" ] || return
482 exec 3>&1
483 device=`$DIALOG --clear \
484 --title " Select your USB key " \
485 --menu "\nPlease select the USB key according to its known size.\n\n" \
486 14 70 4 \
487 $(for i in $DEV ; do
488 echo "/dev/$i $(( $(cat /sys/block/$i/size) / 1024 ))MB"
489 done) \
490 2>&1 1>&3`
491 retval=$?
492 exec 3>&-
493 [ $retval -eq 0 ]
494 }
496 usbbootkey()
497 {
498 $DIALOG --clear \
499 --title " Create a USB boot key " \
500 --yes-label "Continue" --yesno \
501 "\nThe USB key will be used like a CD-ROM. You will not be able to write
502 any data on it.\n\n
503 You should choose 'USB key read/write installation' to be
504 able to save the package updates or your own configuration and data files.\n\n
505 Please plug your USB stick in now.\n
506 " 13 70
507 [ $? -eq 0 ] || return
508 usbdev || return
509 dd if=/mnt/$ISO of=$device
510 }
512 usbkey()
513 {
514 $DIALOG --clear \
515 --title " Create a SliTaz USB key " \
516 --yes-label "Continue" --yesno \
517 "\nUnlike a hard drive install, the filesystem is kept in a compressed
518 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
519 This should increase responsiveness, protect the filesystem against
520 accidental corruption and reduce read/writes to the USB drive.
521 Once setup, the tazusb utility can rewrite the root filesystem
522 with any changes you have made since booting up,
523 giving the effective benefits of a hard drive install.\n\n
524 /home is mounted on boot using the UUID of your particular flash drive.
525 Unlike a device name, the UUID has the benefit of never changing from machine
526 to machine.\n\n
527 Please plug your USB stick in now.\n
528 " 19 70
529 [ $? -eq 0 ] || return
530 usbdev || return
531 exec 3>&1
532 format=`$DIALOG --clear \
533 --title " Select the filesystem " \
534 --radiolist "\nPlease select the filesystem type to create.\n\n\
535 The filesystem creation will erase all the data \
536 in the USB key." 14 70 4 \
537 "none" "Do not erase the USB key" on \
538 "ext3" "Ext3 journaling filesystem" off \
539 "ext2" "Ext2 filesystem" off \
540 "fat32" "Windows FAT32 filesystem" off \
541 2>&1 1>&3`
542 retval=$?
543 exec 3>&-
544 [ $retval -eq 0 ] || return
545 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
546 tazusb gen-iso2usb /mnt/$ISO $device
547 }
549 mount_loram()
550 {
551 is_loram || return
552 insmod /lib/squashfs.ko* 2> /dev/null
553 if [ -d /media/cdrom/fs ]; then
554 ln -s /media/cdrom/fs /sqfs
555 else
556 mkdir /sqfs
557 mount -o loop,ro -t squashfs /rootfs*.gz /sqfs
558 fi
559 ln -s /sqfs/lib/* lib
560 ln -s /sqfs/usr /sqfs/var /
561 for i in dmesg basename tr od reboot poweroff getty sync ; do
562 ln -s /sqfs/bin/busybox /bin/$i
563 done
564 }
566 umount_loram()
567 {
568 is_loram || return
569 rm /var /usr
570 umount -d /sqfs
571 rmdir /sqfs
572 }
574 text()
575 {
576 umount_loram
577 umount -d /media/cdrom
578 rm -f /dev/cdrom
579 umount /mnt
580 umount_proc
581 exec /init
582 }
584 live()
585 {
586 n=0
587 for i in $(ls_r /media/cdrom/boot/rootfs* 2> /dev/null); do
588 [ $((n++)) -eq 0 ] || uncpio $i
589 done
590 text
591 }
593 restart()
594 {
595 sync
596 [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
597 reboot -f
598 }
600 stop()
601 {
602 sync
603 [ ! -L /sqfs ] && umount -d /media/cdrom && umount /mnt
604 poweroff -f
605 }
607 shell()
608 {
609 getty -n -l /bin/ash 38400 tty1 || sh
610 }
612 BIN=bin/mount.posixovl
613 [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \
614 /usr/s$BIN 2> /dev/null || mv /bin/mount.posixovl.iso2exe /$BIN
615 mount_proc
616 ISO="$(getarg iso | sed 's/.://;s|\\|/|g')"
617 getiso
618 mount_loram
619 case "${ISO##*/}$(getarg mode)" in
620 *install*|*INSTALL*) install ;;
621 *live*|*LIVE*) live ;;
622 *text*|*TEXT*) text ;;
623 esac
624 which $DIALOG 2> /dev/null || live
625 dmesg > /tmp/dmesg
627 while true; do
628 keymap="$(cat /etc/keymap.conf 2> /dev/null)"
629 locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2> /dev/null)"
630 cat > /tmp/dialog <<EOT
631 $DIALOG --clear \
632 --title " Welcome to SliTaz " \
633 --menu "" 21 70 15 \
634 $(xfile tazkeymap "tazkeymap" "Select keyboard ($keymap)") \
635 $(xfile tazlocale "tazlocale" "Select locale ($locale)") \
636 $(cdfile boot/bzImage "live" "SliTaz RAM boot") \
637 "text" "SliTaz RAM boot (text mode only)" \
638 $(cdfile README "readme" "Show the README file") \
639 $(cdfile md5sum "md5" "Check ISO files") \
640 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
641 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
642 $(xfile tazusb "usbkey" "USB key read/write installation") \
643 $(cdfile boot/bzImage "usbbootkey" "USB boot key (read only)") \
644 $(fddata "fdbootstrap" "Floppy bootstrap") \
645 $(cdfile boot/bzImage "tazboot" "Get tazboot.exe Linux loader") \
646 $(cdexe boot/memtest "memtest" "Get Memtest86") \
647 $(cdfile boot/memtest "fdmemtest" "Create a Memtest86 boot floppy") \
648 $(cdexe boot/gpxe "pxe" "Get SliTaz Web boot utility") \
649 $(cdfile boot/gpxe "fdpxe" "Create a SliTaz Web boot floppy") \
650 $(cdexe boot/ipxe "pxe" "Get SliTaz Web boot utility") \
651 $(cdfile boot/ipxe "fdpxe" "Create a SliTaz Web boot floppy") \
652 $(xfile reboot "restart" "Restart the computer") \
653 $(xfile poweroff "stop" "Power off") \
654 "bootlog" "Linux boot messages" \
655 "shell" "Shell prompt" \
657 EOT
658 exec 3>&1
659 value=$(sh /tmp/dialog 2>&1 1>&3)
660 retval=$?
661 exec 3>&-
662 [ $retval -eq 0 ] || continue
663 $value
664 done