wok-6.x view syslinux/stuff/iso2exe/init @ rev 16047

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