slitaz-tools view tinyutils/bootfloppybox @ rev 435

improve firewall and iptables_rules (thanks gokhlayeh)
author Rohit Joshi <jozee@slitaz.org>
date Fri Mar 12 12:01:54 2010 +0000 (2010-03-12)
parents 652e107d3457
children 14ecc1b226b2
line source
1 #! /bin/sh
2 #
3 # Gtkdialog box for the mount command. Part of SliTaz tools.
4 #
5 VERSION=20081121
7 # Check if user is root.
8 check_root()
9 {
10 if test $(id -u) != 0 ; then
11 echo -e "
12 You must be root to run `basename $0`. Please type 'su' and
13 root password to become super-user.\n"
14 exit 0
15 fi
16 }
18 # This function is used after each screen to contine or abort install.
19 check_retval()
20 {
21 case $retval in
22 1)
23 rm -f /tmp/floppybox.grub.menu
24 echo -e "\nVoluntary exit.\n" && exit 0 ;;
25 255)
26 rm -f /tmp/floppybox.grub.menu
27 echo -e "ESC pressed.\n" && exit 0 ;;
28 esac
29 }
31 select_floppy()
32 {
33 DEVICE="$DIALOG --title \" Floppy device \" --backtitle \"Boot Floppy Creation\" --clear --extra-button --extra-label \"Format\" --colors --radiolist \"
34 Select boot device
35 \" 18 70 50"
36 on=on
37 for i in /sys/devices/platform/floppy.*/block:*; do
38 [ -d $i ] || continue
39 DEVICE="$DEVICE /dev/${i#*block:} 'Floppy in ${i#*block:}' $on"
40 on=off
41 done
42 DEVICE="$DEVICE floppy \"cdrom image file boot.iso\" $on"
43 DEVICE="$DEVICE cdrom \"floppy image file boot.fd\" off 2>&1 1>&3"
44 exec 3>&1
45 DEVICE=`eval $DEVICE`
46 retval=$?
47 exec 3>&-
48 check_retval
49 if [ "$retval" = "3" ]; then
50 case "$DEVICE" in
51 /dev/*) fdformat -n $DEVICE;;
52 esac
53 fi
54 }
56 mkmenu()
57 {
58 if [ "$1" = "grub4dos" ]; then
59 SAVEDEFAULT="save default"
60 cat > /tmp/floppybox.grub.menu <<EOT
61 # grub4dos menu
62 default /default
63 EOT
64 else
65 SAVEDEFAULT="savedefault"
66 cat > /tmp/floppybox.grub.menu <<EOT
67 # grub menu
68 default saved
69 EOT
70 fi
71 cat >> /tmp/floppybox.grub.menu <<EOT
72 timeout 8
73 color yellow/brown light-green/black
75 EOT
76 entry=0
77 [ -f /boot/gpxe ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
78 title gPXE (Boot from the Web, PXE/iSCSI/AoE support)
79 kernel /boot/gpxe $(dd if=/boot/gpxe bs=1 skip=519 count=255 2>/dev/null | strings)
81 EOT
82 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
83 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
84 title Smart Boot Manager (text - boot floppy, hard disk or CD/DVD)
85 kernel /boot/memdisk floppy c=80 h=2 s=18
86 initrd /boot/btmgr.gz
88 EOT
89 http://mirror.slitaz.org/boot/plpbt.bin
90 [ -f /usr/share/boot/plpbt.bin ] \
91 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
92 title Plop Boot Manager (graphic - boot floppy, hard disk, CD/DVD or USB)
93 kernel /boot/plpbt.bin
95 EOT
96 [ -f /usr/share/boot/etherboot ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
97 title Etherboot (LAN boot, PXE or NBI)
98 kernel /boot/etherboot
100 EOT
101 [ -f /usr/share/boot/memtest.lzma -a -f /usr/share/boot/memdisk.lzma ] \
102 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
103 title Memtest86+ (Test system memory)
104 kernel /boot/memdisk floppy c=80 h=2 s=18
105 initrd /boot/memtest.gz
107 EOT
108 [ "$1" = "grub4dos" ] && entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
109 title Windows (scan ntldr)
110 fallback $(($entry -3 + 1))
111 find --set-root /ntldr
112 chainloader /ntldr
113 $SAVEDEFAULT --wait=2
115 title Windows (scan cmldr)
116 fallback $(($entry -3 + 2))
117 find --set-root /cmldr
118 chainloader /cmldr
119 $SAVEDEFAULT --wait=2
121 title Windows (scan io.sys)
122 fallback $(($entry -3 + 3))
123 find --set-root /io.sys
124 chainloader /io.sys
125 $SAVEDEFAULT --wait=2
127 EOT
128 entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
129 title Windows (example on /dev/hda1)
130 rootnoverify (hd0,0)
131 chainloader +1
132 $SAVEDEFAULT
134 title Slitaz Frugal (example on /dev/hda1)
135 root (hd0,0)
136 kernel /boot/bzImage rw root=/dev/null vga=normal
137 initrd /boot/rootfs.gz
138 $SAVEDEFAULT
140 title Slitaz Installed (example on /dev/hda2)
141 root (hd0,1)
142 kernel /boot/bzImage ro root=/dev/hda2 vga=normal
143 $SAVEDEFAULT
145 EOT
146 [ "$1" = "grub4dos" ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
147 title Slitaz cdrom image (example on /dev/hda1, DEFRAGMENTED)
148 map (hd0,0)/boot/slitaz-cooking.iso (hd1)
149 map --hook
150 kernel (hd1)/boot/bzImage rw root=/dev/null vga=normal
151 initrd (hd1)/boot/rootfs.gz
152 $SAVEDEFAULT
154 EOT
155 false && [ -f /usr/share/boot/grub.exe.lzma ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
156 title Grub4Dos
157 kernel /boot/grub/grub.exe --config-file="configfile (fd0)/boot/grub/menu4dos.lst"
159 EOT
160 }
162 install_grub()
163 {
164 LOOP=""
165 GRUB_DEV=${DEVICE#/dev/}
166 GRUB_DEV=${GRUB_DEV%% *}
167 case "$DEVICE" in
168 floppy*)
169 LOOP="-o loop"
170 GRUB_DEV=fd0
171 DEVICE=boot.fd
172 dd if=/dev/zero of=$DEVICE bs=18k count=80;;
173 esac
174 grep -qs "^# $2 menu" /tmp/floppybox.grub.menu || mkmenu $2
175 case "$DEVICE" in
176 /dev/*|boot.fd)
177 yes y | mke2fs $DEVICE
178 mkdir /media/floppy
179 mount $LOOP $DEVICE /media/floppy
180 if [ "$2" = "grub4dos" ]; then
181 mkdir -p /media/floppy/boot
182 unlzma -c /usr/share/boot/grldr.lzma > /media/floppy/grldr
183 cp $1/boot/* /media/floppy/boot 2> /dev/null
184 cp /tmp/floppybox.grub.menu /media/floppy/menu.lst
185 umount -d /media/floppy
186 bootlace --floppy --sectors-per-track=18 --heads=2 \
187 --chs --ext2 $DEVICE
188 else
189 mkdir -p /media/floppy/boot/grub
190 cp /usr/lib/grub/i386-pc/stage? /media/floppy/boot/grub
191 cp -a $1/boot /media/floppy
192 cp /tmp/floppybox.grub.menu /media/floppy/boot/grub/menu.lst
193 grub-set-default --root-directory=/media/floppy 0
194 echo "($GRUB_DEV) $(losetup | grep $DEVICE | cut -d: -f1)" > $1/device.map
195 [ -n "$LOOP" ] && LOOP="--device-map=$1/device.map"
196 grub $LOOP --batch <<EOT
197 root ($GRUB_DEV)
198 setup ($GRUB_DEV)
199 quit
200 EOT
201 umount -d /media/floppy
202 fi ;;
203 cdrom*)
204 mkdir -p $1/boot/grub 2> /dev/null
205 cp /tmp/floppybox.grub.menu $1/boot/grub/menu.lst
206 if [ "$2" = "grub4dos" ]; then
207 unlzma -c /usr/share/boot/grldr.lzma > $1/boot/grub/grldr
208 genisoimage -R -o boot.iso -b boot/grub/grldr \
209 -c boot/boot.cat -no-emul-boot -boot-load-seg 0x1000 \
210 -hide boot/boot.cat -input-charset iso8859-1 $1
211 else
212 cp /usr/lib/grub/i386-pc/stage2_eltorito $1/boot/grub
213 genisoimage -R -o boot.iso -b boot/grub/stage2_eltorito \
214 -c boot/boot.cat -no-emul-boot -boot-load-size 4 \
215 -hide boot/boot.cat -input-charset iso8859-1 \
216 -boot-info-table $1
217 fi ;;
218 esac
219 }
221 # write a 32 bits data
222 # usage: storelong offset data32 file
223 storelong()
224 {
225 printf "00000 %02X %02X %02X %02X \n" \
226 $(( $2 & 255 )) $(( ($2>>8) & 255 )) \
227 $(( ($2>>16) & 255 )) $(( ($2>>24) & 255 )) | \
228 hexdump -R | dd bs=1 conv=notrunc of=$3 seek=$(( $1 )) 2> /dev/null
229 }
231 # read a 32 bits data
232 # usage: getlong offset file
233 getlong()
234 {
235 dd if=$2 bs=1 skip=$(( $1 )) count=4 2> /dev/null | \
236 hexdump -e '"" 1/4 "%d" "\n"'
237 }
239 floppyset()
240 {
241 KERNEL="$1"
242 INITRD="$2"
243 shift 2
244 CMDLINE="$@"
246 # bzImage offsets
247 SetupSzOfs=497
248 SyssizeOfs=500
249 CodeAdrOfs=0x214
250 RamfsAdrOfs=0x218
251 RamfsLenOfs=0x21C
252 ArgPtrOfs=0x228
254 # boot+setup address
255 SetupBase=0x90000
257 stacktop=0x9E00
259 bs=/tmp/bs$$
261 # Get and patch boot sector
262 dd if=$KERNEL bs=512 count=1 of=$bs 2> /dev/null
263 uudecode <<EOT | dd of=$bs conv=notrunc 2> /dev/null
264 begin-base64 644 -
265 v/Sd/GgAkAcxyQYXify7eACO2cU3sQbzpY7ZiSeMRwKg8X2YQAYfxkX4P/qz
266 GFFLdfyXmEHoPgG+AAKATBGAx0QkAJwDdA7oZAG+KAI5HHIuR4scVuhAAV+L
267 NehQAbAgzRCwCM0QTpjNFjwIdAOIBK07NXTy6CoBPAp14oh8/onmsA+/9AH+
268 TRyxBbSTiUQcsAGJRBSZiVQQiVQYZjHbQ9PjS2YDHWbT62gAEAe/gAAp+5xz
269 AgHfU1Yx2+jaAF65AIC0h/5EHM0VW5133KEaAki/HAKxCThEHHKwMcDNE+oA
270 ACCQsEYoyL65AejCAF3rKYD5E3IEOMF3boD+AnIEOOZ3b4D9UHN5YIH9AAZ0
271 JwZSUVOWtAJQuQYAUbEEwcUEsA8h6ASQJxRAJ+h1AOLusCDNEFnirpjNE2Ex
272 9q2RrZKtUCjIdwKwAZg5+HICifhQUrQCzRNalV5YcpYp9wHxweYJAfM4wXUm
273 iMj+xrEBOOZ1HIj0/sW2ADwTdRKA/VByDbUAYL68AegkAJjNFmGjBABSUWaP
274 BgAACf91nhYHsDEsA7QOuwcAzRA8DXTzw7AN6O//rAjAdfjDWDoASW5zZXJ0
275 IG5leHQgZmxvcHB5IGFuZCBwcmVzcyBhbnkga2V5IHRvIGNvbnRpbnVlLgcN
276 AA==
277 ====
278 EOT
280 # Get setup
281 setupsz=$(getlong $SetupSzOfs $bs)
282 setupszb=$(( $setupsz & 255 ))
283 dd if=$KERNEL bs=512 skip=1 count=$setupszb 2> /dev/null >> $bs
285 # Store cmdline after setup
286 if [ -n "$CMDLINE" ]; then
287 echo -n "$CMDLINE" | dd bs=512 count=1 conv=sync 2> /dev/null >> $bs
288 storelong ArgPtrOfs $(( $SetupBase + $stacktop )) $bs
289 fi
291 # Compute initramfs size
292 initrdlen=0
293 padding=0
294 for i in $( echo $INITRD | sed 's/,/ /' ); do
295 [ -s "$i" ] || continue
296 initrdlen=$(( $initrdlen + $padding ))
297 padding=$(stat -c %s $i)
298 initrdlen=$(( $initrdlen + $padding ))
299 padding=$(( 4096 - ($padding & 4095) ))
300 [ $padding -eq 4096 ] && padding=0
301 done
302 Ksize=$(( $(getlong $SyssizeOfs $bs)*16 ))
303 Kpad=$(( (($Ksize+4095)/4096)*4096 - Ksize ))
304 if [ $initrdlen -ne 0 ]; then
305 Kbase=$(getlong $CodeAdrOfs $bs)
306 storelong $RamfsAdrOfs \
307 $(( (0x1000000 - $initrdlen) & 0xFFFF0000 )) $bs
308 storelong $RamfsLenOfs $initrdlen $bs
309 fi
311 # Output boot sector + setup + cmdline
312 dd if=$bs 2> /dev/null
314 # Output kernel code
315 dd if=$KERNEL bs=512 skip=$(( $setupszb + 1 )) 2> /dev/null
317 # Pad to next sector
318 Kpad=$(( 512 - ($(stat -c %s $KERNEL) & 511) ))
319 [ $Kpad -eq 512 ] || dd if=/dev/zero bs=1 count=$Kpad 2> /dev/null
321 # Output initramfs
322 padding=0
323 for i in $( echo $INITRD | sed 's/,/ /' ); do
324 [ -s "$i" ] || continue
325 [ $padding -ne 0 ] && dd if=/dev/zero bs=1 count=$padding
326 dd if=$i 2> /dev/null
327 padding=$(( 4096 - ($(stat -c %s $i) & 4095) ))
328 [ $padding -eq 4096 ] && padding=0
329 done
331 # Cleanup
332 rm -f $bs
333 }
335 while true; do
337 if [ "$1" == "call" ]; then
338 case "$2" in
339 mkmenu) mkmenu $3;;
340 mkfloppies)
341 shift 2
342 floppyset $@ | split -b 1440k /dev/stdin floppy$$
343 i=1
344 ls floppy$$* | while read file ; do
345 output=floppy.$(printf "%03d" $i)
346 cat $file /dev/zero | dd bs=1k count=1440 of=$output conv=sync 2> /dev/null
347 rm -f $file
348 i=$(( $i + 1 ))
349 done;;
350 install)
351 DIR=/tmp/mkbootfloppy$$
352 mkdir -p $DIR
353 DEVICE=$4
354 file=$5
355 case "$3" in
356 grub*)
357 mkdir -p $DIR/boot/grub
358 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
359 && cat /usr/share/boot/btmgr /dev/zero | \
360 dd bs=18k count=80 | gzip -9 > \
361 $DIR/boot/btmgr.gz \
362 && unlzma -c /usr/share/boot/memdisk.lzma > \
363 $DIR/boot/memdisk
364 [ -f /usr/share/boot/plpbt.bin ] \
365 && cp /usr/share/boot/plpbt.bin $DIR/boot
366 [ -f /usr/share/boot/etherboot ] \
367 && cp /usr/share/boot/etherboot $DIR/boot
368 [ -f /boot/gpxe ]\
369 && cp /boot/gpxe $DIR/boot
370 [ -f /usr/share/boot/memtest.lzma -a \
371 -f /usr/share/boot/memdisk.lzma ] \
372 && unlzma -c /usr/share/boot/memtest.lzma | \
373 cat - /dev/zero | dd bs=18k count=80 | \
374 gzip -9 > $DIR/boot/memtest.gz \
375 && unlzma -c /usr/share/boot/memdisk.lzma > \
376 $DIR/boot/memdisk
377 install_grub $DIR $3
378 ;;
379 *)
380 case "$file" in
381 *.lzma) action="unlzma -c";;
382 *.gz) action="zcat";;
383 *) action="cat";;
384 esac
385 case "$DEVICE" in
386 /dev/*) $action $file > $DEVICE;;
387 flopp*) $action $file | cat - /dev/zero | \
388 dd bs=18k count=80 > boot.fd;;
389 cdrom*)
390 mkdir -p $DIR/boot/grub
391 case "$3" in
392 btmgr|memtest)
393 $action $file | cat - /dev/zero | \
394 dd bs=18k count=80 | \
395 gzip -9 > $DIR/boot/$3.gz
396 unlzma -c /usr/share/boot/memdisk.lzma \
397 > $DIR/boot/memdisk
398 cat > /tmp/floppybox.grub.menu << EOT
399 # grub menu
400 timeout 0
401 title $3
402 kernel /boot/memdisk floppy c=80 h=2 s=18
403 initrd /boot/$3.gz
404 EOT
405 ;;
406 *) $action $file > $DIR/boot/$3
407 cat > /tmp/floppybox.grub.menu << EOT
408 # grub menu
409 timeout 0
410 title $3
411 kernel /boot/$3
412 EOT
413 ;;
414 esac
415 install_grub $DIR grub
416 ;;
417 esac
418 ;;
419 esac
420 rm -rf $DIR
421 ;;
422 get-plop)
423 mkdir -p /tmp/get-plop$$
424 PLOP_URL=http://mirror.slitaz.org/boot/plpbt.bin
425 wget -O - $PLOP_URL > /tmp/get-plop$$/plpbt.bin
426 VERSION="$(strings /tmp/get-plop$$/plpbt.bin \
427 | grep 'Boot Manager v' | sed 's/.* v\([0-9\.]*\) .*/\1/')"
428 mkdir -p $(dirname /tmp/get-plop$$/plop-$VERSION/fs/$3)
429 mv /tmp/get-plop$$/plpbt.bin \
430 /tmp/get-plop$$/plop-$VERSION/fs/$3
431 if [ -s /tmp/get-plop$$/plop-$VERSION/fs/$3 ]; then
432 cat > /tmp/get-plop$$/plop-$VERSION/receipt <<EOT
433 PACKAGE="plop"
434 VERSION="$VERSION"
435 CATEGORY="non-free"
436 SHORT_DESC="Plop boot manager."
437 WEB_SITE="http://www.plop.at/en/bootmanager.html"
438 EOT
439 ( cd /tmp/get-plop$$ ; tazpkg pack plop-$VERSION )
440 tazpkg install /tmp/get-plop$$/plop-$VERSION.tazpkg
441 fi
442 rm -rf /tmp/get-plop$$
443 ;;
444 *) echo "Invalid command $0 $@" 1>&2
445 exit 1;;
446 esac
447 exit 0
448 fi
450 if [ -z "$XAUTHORITY" ]; then
452 : ${DIALOG=dialog}
454 DEVICE=/dev/fd0
455 while true; do
456 exec 3>&1
457 ID_SOURCE=`$DIALOG --title " Choose a boot floppy " \
458 --backtitle "Boot Floppy Creation on $DEVICE" --clear \
459 --extra-button --extra-label "Change floppy" \
460 --yes-label "Install" \
461 --no-label "Quit" \
462 --colors --radiolist "
463 Create a floppy or a cdrom to boot a LiveCD in a PXE network...
464 May need a floppy disk in drive. Erase the whole floppy disk.
465 " 18 70 50\
466 SmartBtmgr "Boot any partition or ATAPI CD-ROM." on \
467 Plop "Boot USB harddisk floppy or CD/DVD." off \
468 Etherboot "Replacement for proprietary PXE ROMs." off \
469 gPXE "Boot from http://boot.slitaz.org/" off \
470 Memtest86+ "Memory failures detection tool." off \
471 Grub4DOS "Enhanced grub version supporting NTFS." off \
472 Grub "Boot loader with command shell." off 2>&1 1>&3`
473 retval=$?
474 exec 3>&-
475 check_retval
476 if [ "$retval" = "3" ]; then
477 select_floppy
478 continue;
479 fi
480 while read key file pkg; do
481 [ "$key" = "$ID_SOURCE" ] || continue
482 if [ ! -f "$file" ]; then
483 $DIALOG --title " Install package " --colors \
484 --backtitle "Boot Floppy Creation" --clear \
485 --yes-label "Install" \
486 --no-label "Quit" \
487 --yesno "The package $pkg is not yet installed. Install it ?" 18 70
488 retval=$?
489 if [ "$pkg" = "plop" ]; then
490 bootfloppybox call get-plop $file
491 else
492 tazpkg get-install $pkg
493 fi
494 fi
495 bootfloppybox call install "$pkg" "$DEVICE" "$file"
496 exit 0
497 done <<EOT
498 SmartBtmgr /usr/share/boot/btmgr btmgr
499 Plop /usr/share/boot/plpbt.bin plop
500 Etherboot /usr/share/boot/etherboot etherboot
501 gPXE /boot/gpxe gpxe
502 Memtest86+ /usr/share/boot/memtest.lzma memtest
503 Grub4DOS /usr/share/boot/grldr.lzma grub4dos
504 Grub /usr/sbin/grub grub
505 EOT
506 done
507 fi
508 #
509 # Describe gPXE arguments.
510 #
511 export HELP='
512 <window title="gPXE forced url" icon-name="gtk-floppy">
513 <vbox>
514 <text use-markup="true">
515 <label>"
516 <b>Web boot parameters</b>"
517 </label>
518 </text>
519 <frame>
520 <text wrap="true" width-chars="58" use-markup="true">
521 <label>
522 "Without parameters (i.e. with an empty Boot URL) gPXE will perform a normal PXE boot: IP configuration with DHCP and download the DHCP bootfile with TFTP.
524 You can override the DHCP bootfile with a Boot URL such as <i>tftp://192.168.0.1/pxe/pxeloader</i>, <i>http://mirror.slitaz.org/pxe/pxelinux.0</i>, or <i>x-tftm://192.168.0.201//lts/vmlinuz.ltsp</i>.
526 You can override IP configuration too (useful without a DHCP server), example: <i>ip=192.168.0.10/24 gw=192.168.0.1 dns=192.168.0.1 nodhcp url=http://mirror.slitaz.org/pxe/pxelinux.0</i>
528 The <i>nodhcp</i> keyword avoids dhcp timeouts and the <i>url=</i> keyword is optional when the url is the only one argument.
530 Comma separated URL lists are supported. The PXE client will try to load the first URL. If the load fails, it will try the next URL, and so on.
531 "
532 </label>
533 </text>
534 </frame>
535 </vbox>
536 </window>
537 '
538 #
539 # Create floppy image set
540 #
541 export IMAGE_SET='
542 <window title="Image set generator" icon-name="gtk-floppy">
543 <vbox>
544 <text use-markup="true">
545 <label>
546 "
547 <b>Create a boot floppy set.</b>
548 "
549 </label>
550 </text>
551 <text wrap="false" width-chars="44" use-markup="true">
552 <label>
553 "
554 The total size of the kernel and the initramfs must not
555 increase 14-15Mb due to the tiny boot loader design.
556 "
557 </label>
558 </text>
559 <frame>
560 <vbox>
561 <hbox>
562 <text use-markup="true">
563 <label>"<b>Kernel : </b>"</label>
564 </text>
565 <entry accept="filename">
566 <label>Select a linux kernel</label>
567 <variable>KERNEL</variable>
568 </entry>
569 <button>
570 <input file stock="gtk-open"></input>
571 <action type="fileselect">KERNEL</action>
572 </button>
573 </hbox>
574 <hbox>
575 <text use-markup="true">
576 <label>"<b>Initramfs : </b>"</label>
577 </text>
578 <entry accept="filename">
579 <label>Select an initramfs/initrd file</label>
580 <variable>INITRD</variable>
581 </entry>
582 <button>
583 <input file stock="gtk-open"></input>
584 <action type="fileselect">INITRD</action>
585 </button>
586 </hbox>
587 <hbox>
588 <text use-markup="true">
589 <label>"<b>Cmdline : </b>"</label>
590 </text>
591 <entry>
592 <label>Enter kernel arguments</label>
593 <variable>CMDLINE</variable>
594 <default>rw root=/dev/null autologin</default>
595 </entry>
596 </hbox>
597 <hbox>
598 <text use-markup="true">
599 <label>"<b>Output directory : </b>"</label>
600 </text>
601 <entry accept="directory">
602 <label>Select output directory</label>
603 <variable>OUTPUTDIR</variable>
604 <default>/tmp</default>
605 </entry>
606 <button>
607 <input file stock="gtk-open"></input>
608 <action type="fileselect">OUTPUTDIR</action>
609 </button>
610 </hbox>
611 </vbox>
612 </frame>
613 <hbox>
614 <button>
615 <input file icon="forward"></input>
616 <label>Create image set</label>
617 <action>cd $OUTPUTDIR; bootfloppybox call mkfloppies $KERNEL $INITRD $CMDLINE</action>
618 <action type="closewindow">IMAGE_SET</action>
619 </button>
620 <button>
621 <input file icon="gtk-close"></input>
622 <action type="closewindow">IMAGE_SET</action>
623 </button>
624 </hbox>
625 </vbox>
626 </window>
627 '
628 #
629 # Read/write floppy images
630 #
631 export FLOPPY_IMAGE='
632 <window title="Floppy image manager" icon-name="gtk-floppy">
633 <vbox>
634 <frame Floppy disk drive>
635 <hbox>
636 <text use-markup="true">
637 <label>"<b>Device : </b>"</label>
638 </text>
639 <combobox>
640 <variable>DEVICE</variable>'
641 for i in /sys/devices/platform/floppy.*/block:*; do
642 [ -d $i ] || continue
643 FLOPPY_IMAGE="$FLOPPY_IMAGE
644 <item>/dev/${i#*block:}</item>"
645 done
646 FLOPPY_IMAGE="$FLOPPY_IMAGE
647 </combobox>
648 <button>
649 <label>Format floppy</label>
650 <input file icon=\"media-floppy\"></input>
651 <action>fdformat -n $DEVICE</action>
652 </button>
653 </hbox>
654 </frame>
655 <frame Floppy image file>
656 <hbox>
657 <text use-markup=\"true\">
658 <label>\"<b>File : </b>\"</label>
659 </text>
660 <entry accept=\"filename\">
661 <label>Select a floppy image</label>
662 <variable>IMAGE</variable>
663 </entry>
664 <button>
665 <input file stock=\"gtk-open\"></input>
666 <action type=\"fileselect\">IMAGE</action>
667 </button>
668 </hbox>
669 </frame>
670 <hbox>
671 <button>
672 <input file icon=\"reload\"></input>
673 <label>Create image set</label>
674 <action type=\"launch\">IMAGE_SET</action>
675 </button>
676 <button>
677 <input file icon=\"go-jump\"></input>
678 <label>Write image to floppy</label>
679 <action>dd if=\$IMAGE of=\$DEVICE</action>
680 </button>
681 <button>
682 <input file icon=\"undo\"></input>
683 <label>Get floppy image</label>
684 <action>dd if=\$DEVICE of=\$IMAGE</action>
685 </button>
686 <button>
687 <input file icon=\"gtk-close\"></input>
688 <action type=\"closewindow\">FLOPPY_IMAGE</action>
689 </button>
690 </hbox>
691 </vbox>
692 </window>
693 "
694 #
695 # Write bootfloppy image to floppy device.
696 #
697 BOOT_DIALOG='
698 <window title="bootfloppybox" icon-name="gtk-floppy">
699 <vbox>
701 <text use-markup="true">
702 <label>
703 "
704 <b>SliTaz - Bootfloppybox</b>"
705 </label>
706 </text>
707 <text wrap="false" width-chars="44" use-markup="true">
708 <label>
709 "
710 Create a floppy or a cdrom to boot a LiveCD in a PXE network or the WEB...
711 May need a floppy disk in drive. Erase the whole floppy disk.
712 "
713 </label>
714 </text>
716 <frame Floppy disk drive>
717 <hbox>
718 <text use-markup="true">
719 <label>"<b>Device : </b>"</label>
720 </text>
721 <combobox>
722 <variable>DEVICE</variable>'
723 for i in /sys/devices/platform/floppy.*/block:*; do
724 [ -d $i ] || continue
725 BOOT_DIALOG="$BOOT_DIALOG
726 <item>/dev/${i#*block:}</item>"
727 done
728 tmp=' <item>floppy image (boot.fd)</item>
729 <item>cdrom image (boot.iso)</item>
730 </combobox>
731 <button>
732 <label>Format floppy</label>
733 <input file icon="media-floppy"></input>
734 <action>case "$DEVICE" in /dev/*) fdformat -n $DEVICE;; esac</action>
735 </button>
736 </hbox>
737 </frame>
738 <notebook labels="LiveCD|USB|PXE Network|WEB Network|Memory Test|Windows|Expert">
739 '
740 BOOT_DIALOG="$BOOT_DIALOG$tmp"
741 while read name file pkg desc; do
742 tmp="<frame $name>
743 <hbox>
744 <text wrap=\"true\" width-chars=\"44\" use-markup=\"true\">
745 <label>
746 \"
747 $(echo -e $desc)
748 \"
749 </label>
750 </text>
751 </hbox>
752 <hbox>
753 "
754 if [ -f $file ]; then
755 if [ "$pkg" = "grub" -o "$pkg" = "grub4dos" ]; then
756 tmp="$tmp
757 <button>
758 <label>Grub menu</label>
759 <input file icon=\"accessories-text-editor\"></input>
760 <action>bootfloppybox call mkmenu $pkg</action>
761 <action type=\"lauch\">leafpad /tmp/floppybox.grub.menu</action>
762 </button>
763 "
764 elif [ "$pkg" = "etherboot" ]; then
765 tmp="$tmp
766 <button>
767 <input file icon=\"browser\"></input>
768 <label>Wiki</label>
769 <action>firefox http://wiki.slitaz.org/doku.php?id=quickstart:pxe &</action>
770 </button>
771 "
772 elif [ "$pkg" = "gpxe" ]; then
773 tmp="$tmp
774 <text wrap=\"true\" use-markup=\"true\">
775 <label> \"<b>Boot URL:</b>\" </label>
776 </text>
777 <entry>
778 <default>$(dd if=$file bs=1 skip=519 count=255 2>/dev/null | strings)</default>
779 <variable>URL</variable>
780 </entry>
781 </hbox>
782 <hbox>
783 <button>
784 <input file icon=\"browser\"></input>
785 <label>Wiki</label>
786 <action>firefox http://wiki.slitaz.org/doku.php?id=quickstart:pxe &</action>
787 </button>
788 <button help>
789 <action type=\"launch\">HELP</action>
790 </button>
791 <button>
792 <label>Update</label>
793 <input file icon=\"reload\"></input>
794 <action>echo -n \"\$URL\" | cat - /dev/zero | dd conv=notrunc bs=1 count=255 seek=519 of=$file 2>/dev/null</action>
795 </button>
796 "
797 fi
798 receipt=/var/lib/tazpkg/installed/$pkg/receipt
799 if [ -f $receipt ]; then
800 . $receipt
801 tmp="$tmp
802 <button>
803 <input file icon=\"browser\"></input>
804 <label>Web</label>
805 <action>firefox $WEB_SITE &</action>
806 </button>
807 "
808 fi
809 tmp="$tmp
810 <button>
811 <label>Write floppy</label>
812 <input file icon=\"forward\"></input>
813 <action>bootfloppybox call install \"$pkg\" \"\$DEVICE\" \"$file\"</action>
814 </button>
815 </hbox>
816 </frame>
817 "
818 else
819 tmp2="tazpkg get-install $pkg --forced"
820 [ "$pkg" = "plop" ] && tmp2="bootfloppybox call get-plop $file"
821 tmp="$tmp
822 <text wrap=\"true\" width-chars=\"34\" use-markup=\"true\">
823 <label>
824 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
825 </label>
826 </text>
827 <button>
828 <input file icon=\"go-jump\"></input>
829 <label>Install</label>
830 <action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
831 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"$tmp2 ; sleep 2\"</action>
832 <action type=\"exit\">restart</action>
833 </button>
834 </hbox>
835 </frame>
836 "
837 fi
838 BOOT_DIALOG="$BOOT_DIALOG$tmp"
839 done <<EOT
840 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot any partition or ATAPI CD-ROM.
841 Plop /usr/share/boot/plpbt.bin plop This non free Boot Manager can boot a floppy disk, hardisk, USB or CD/DVD. Hit Ctrl-ESC for text mode.
842 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement for proprietary PXE or NBI ROMs.
843 gPXE /boot/gpxe gpxe PXE / iSCSI / AoE network bootloader.
844 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
845 Grub4DOS /usr/share/boot/grldr.lzma grub4dos Enhanced grub version supporting NTFS.
846 Grub /usr/sbin/grub grub General purpose boot loader with command shell.
847 EOT
848 tmp='
849 </notebook>
850 <hbox>
851 <button>
852 <input file icon="media-cdrom"></input>
853 <label>Burn cdrom image</label>
854 <action>burnbox</action>
855 </button>
856 <button>
857 <input file icon="media-floppy"></input>
858 <label>Manage floppy image</label>
859 <action type="launch">FLOPPY_IMAGE</action>
860 </button>
861 <button>
862 <input file icon="exit"></input>
863 <label>Exit</label>
864 <action type="exit">Exit</action>
865 </button>
866 </hbox>
868 </vbox>
869 </window>
870 '
871 BOOT_DIALOG="$BOOT_DIALOG$tmp"
872 export BOOT_DIALOG
874 # Only root can create floppy.
875 check_root
876 gtkdialog --program=BOOT_DIALOG | grep -q 'EXIT="restart"' && continue
877 rm -f /tmp/floppybox.grub.menu
878 exit 0
879 done