slitaz-tools annotate tinyutils/bootfloppybox @ rev 393

Added tag 3.3 for changeset b27d8925b831
author Christophe Lincoln <pankso@slitaz.org>
date Thu Oct 01 21:57:15 2009 +0200 (2009-10-01)
parents e9ddf09500d2
children b158266db011
rev   line source
pascal@130 1 #! /bin/sh
pascal@130 2 #
pascal@130 3 # Gtkdialog box for the mount command. Part of SliTaz tools.
pascal@130 4 #
pascal@274 5 VERSION=20081121
pascal@130 6
pascal@130 7 # Check if user is root.
pascal@130 8 check_root()
pascal@130 9 {
pascal@130 10 if test $(id -u) != 0 ; then
pascal@130 11 echo -e "
pascal@130 12 You must be root to run `basename $0`. Please type 'su' and
pascal@130 13 root password to become super-user.\n"
pascal@130 14 exit 0
pascal@130 15 fi
pascal@130 16 }
pascal@130 17
pascal@213 18 # This function is used after each screen to contine or abort install.
pascal@213 19 check_retval()
pascal@213 20 {
pascal@213 21 case $retval in
pascal@213 22 1)
pascal@214 23 rm -f /tmp/floppybox.grub.menu
pascal@213 24 echo -e "\nVoluntary exit.\n" && exit 0 ;;
pascal@213 25 255)
pascal@214 26 rm -f /tmp/floppybox.grub.menu
pascal@213 27 echo -e "ESC pressed.\n" && exit 0 ;;
pascal@213 28 esac
pascal@213 29 }
pascal@213 30
pascal@213 31 select_floppy()
pascal@213 32 {
pascal@264 33 DEVICE="$DIALOG --title \" Floppy device \" --backtitle \"Boot Floppy Creation\" --clear --extra-button --extra-label \"Format\" --colors --radiolist \"
pascal@264 34 Select boot device
pascal@264 35 \" 18 70 50"
pascal@264 36 on=on
pascal@264 37 for i in /sys/devices/platform/floppy.*/block:*; do
pascal@264 38 [ -d $i ] || continue
pascal@264 39 DEVICE="$DEVICE /dev/${i#*block:} 'Floppy in ${i#*block:}' $on"
pascal@264 40 on=off
pascal@264 41 done
pascal@274 42 DEVICE="$DEVICE floppy \"cdrom image file boot.iso\" $on"
pascal@274 43 DEVICE="$DEVICE cdrom \"floppy image file boot.fd\" off 2>&1 1>&3"
pascal@213 44 exec 3>&1
pascal@264 45 DEVICE=`eval $DEVICE`
pascal@213 46 retval=$?
pascal@213 47 exec 3>&-
pascal@213 48 check_retval
pascal@213 49 if [ "$retval" = "3" ]; then
pascal@264 50 case "$DEVICE" in
pascal@264 51 /dev/*) fdformat -n $DEVICE;;
pascal@264 52 esac
pascal@213 53 fi
pascal@213 54 }
pascal@213 55
pascal@274 56 mkmenu()
pascal@274 57 {
pascal@274 58 if [ "$1" = "grub4dos" ]; then
pascal@274 59 SAVEDEFAULT="save default"
pascal@274 60 cat > /tmp/floppybox.grub.menu <<EOT
pascal@274 61 # grub4dos menu
pascal@274 62 default /default
pascal@274 63 EOT
pascal@274 64 else
pascal@274 65 SAVEDEFAULT="savedefault"
pascal@274 66 cat > /tmp/floppybox.grub.menu <<EOT
pascal@274 67 # grub menu
pascal@274 68 default saved
pascal@274 69 EOT
pascal@274 70 fi
pascal@274 71 cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 72 timeout 8
pascal@274 73 color yellow/brown light-green/black
pascal@274 74
pascal@274 75 EOT
pascal@274 76 entry=0
pascal@274 77 [ -f /boot/gpxe ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 78 title gPXE (Boot from the Web, PXE/iSCSI/AoE support)
pascal@274 79 kernel /boot/gpxe $(dd if=/boot/gpxe bs=1 skip=519 count=255 2>/dev/null | strings)
pascal@274 80
pascal@274 81 EOT
pascal@274 82 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
pascal@274 83 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 84 title Smart Boot Manager (text - boot floppy, hard disk or CD/DVD)
pascal@274 85 kernel /boot/memdisk floppy c=80 h=2 s=18
pascal@274 86 initrd /boot/btmgr.gz
pascal@274 87
pascal@274 88 EOT
pascal@382 89 http://mirror.slitaz.org/boot/plpbt.bin
pascal@382 90 [ -f /usr/share/boot/plpbt.bin ] \
pascal@274 91 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 92 title Plop Boot Manager (graphic - boot floppy, hard disk, CD/DVD or USB)
pascal@382 93 kernel /boot/plpbt.bin
pascal@274 94
pascal@274 95 EOT
pascal@274 96 [ -f /usr/share/boot/etherboot ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 97 title Etherboot (LAN boot, PXE or NBI)
pascal@274 98 kernel /boot/etherboot
pascal@274 99
pascal@274 100 EOT
pascal@274 101 [ -f /usr/share/boot/memtest.lzma -a -f /usr/share/boot/memdisk.lzma ] \
pascal@274 102 && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 103 title Memtest86+ (Test system memory)
pascal@274 104 kernel /boot/memdisk floppy c=80 h=2 s=18
pascal@274 105 initrd /boot/memtest.gz
pascal@274 106
pascal@274 107 EOT
pascal@274 108 [ "$1" = "grub4dos" ] && entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 109 title Windows (scan ntldr)
pascal@274 110 fallback $(($entry -3 + 1))
pascal@274 111 find --set-root /ntldr
pascal@274 112 chainloader /ntldr
pascal@274 113 $SAVEDEFAULT --wait=2
pascal@274 114
pascal@274 115 title Windows (scan cmldr)
pascal@274 116 fallback $(($entry -3 + 2))
pascal@274 117 find --set-root /cmldr
pascal@274 118 chainloader /cmldr
pascal@274 119 $SAVEDEFAULT --wait=2
pascal@274 120
pascal@274 121 title Windows (scan io.sys)
pascal@274 122 fallback $(($entry -3 + 3))
pascal@274 123 find --set-root /io.sys
pascal@274 124 chainloader /io.sys
pascal@274 125 $SAVEDEFAULT --wait=2
pascal@274 126
pascal@274 127 EOT
pascal@274 128 entry=$(($entry + 3)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 129 title Windows (example on /dev/hda1)
pascal@274 130 rootnoverify (hd0,0)
pascal@274 131 chainloader +1
pascal@274 132 $SAVEDEFAULT
pascal@274 133
pascal@274 134 title Slitaz Frugal (example on /dev/hda1)
pascal@274 135 root (hd0,0)
pascal@274 136 kernel /boot/bzImage rw root=/dev/null vga=normal
pascal@274 137 initrd /boot/rootfs.gz
pascal@274 138 $SAVEDEFAULT
pascal@274 139
pascal@274 140 title Slitaz Installed (example on /dev/hda2)
pascal@274 141 root (hd0,1)
pascal@274 142 kernel /boot/bzImage ro root=/dev/hda2 vga=normal
pascal@274 143 $SAVEDEFAULT
pascal@274 144
pascal@274 145 EOT
pascal@274 146 [ "$1" = "grub4dos" ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 147 title Slitaz cdrom image (example on /dev/hda1, DEFRAGMENTED)
pascal@274 148 map (hd0,0)/boot/slitaz-cooking.iso (hd1)
pascal@274 149 map --hook
pascal@274 150 kernel (hd1)/boot/bzImage rw root=/dev/null vga=normal
pascal@274 151 initrd (hd1)/boot/rootfs.gz
pascal@274 152 $SAVEDEFAULT
pascal@274 153
pascal@274 154 EOT
pascal@274 155 false && [ -f /usr/share/boot/grub.exe.lzma ] && entry=$(($entry + 1)) && cat >> /tmp/floppybox.grub.menu <<EOT
pascal@274 156 title Grub4Dos
pascal@274 157 kernel /boot/grub/grub.exe --config-file="configfile (fd0)/boot/grub/menu4dos.lst"
pascal@274 158
pascal@274 159 EOT
pascal@274 160 }
pascal@274 161
pascal@264 162 install_grub()
pascal@264 163 {
pascal@274 164 LOOP=""
pascal@274 165 GRUB_DEV=${DEVICE#/dev/}
pascal@274 166 GRUB_DEV=${GRUB_DEV%% *}
pascal@264 167 case "$DEVICE" in
pascal@274 168 floppy*)
pascal@274 169 LOOP="-o loop"
pascal@274 170 GRUB_DEV=fd0
pascal@274 171 DEVICE=boot.fd
pascal@274 172 dd if=/dev/zero of=$DEVICE bs=18k count=80;;
pascal@274 173 esac
pascal@274 174 grep -qs "^# $2 menu" /tmp/floppybox.grub.menu || mkmenu $2
pascal@274 175 case "$DEVICE" in
pascal@274 176 /dev/*|boot.fd)
pascal@274 177 yes y | mke2fs $DEVICE
pascal@213 178 mkdir /media/floppy
pascal@274 179 mount $LOOP $DEVICE /media/floppy
pascal@274 180 if [ "$2" = "grub4dos" ]; then
pascal@274 181 mkdir -p /media/floppy/boot
pascal@274 182 unlzma -c /usr/share/boot/grldr.lzma > /media/floppy/grldr
pascal@274 183 cp $1/boot/* /media/floppy/boot 2> /dev/null
pascal@274 184 cp /tmp/floppybox.grub.menu /media/floppy/menu.lst
pascal@274 185 umount -d /media/floppy
pascal@274 186 bootlace --floppy --sectors-per-track=18 --heads=2 \
pascal@274 187 --chs --ext2 $DEVICE
pascal@274 188 else
pascal@274 189 mkdir -p /media/floppy/boot/grub
pascal@274 190 cp /usr/lib/grub/i386-pc/stage? /media/floppy/boot/grub
pascal@274 191 cp -a $1/boot /media/floppy
pascal@274 192 cp /tmp/floppybox.grub.menu /media/floppy/boot/grub/menu.lst
pascal@274 193 grub-set-default --root-directory=/media/floppy 0
pascal@274 194 echo "($GRUB_DEV) $(losetup | grep $DEVICE | cut -d: -f1)" > $1/device.map
pascal@274 195 [ -n "$LOOP" ] && LOOP="--device-map=$1/device.map"
pascal@274 196 grub $LOOP --batch <<EOT
pascal@274 197 root ($GRUB_DEV)
pascal@274 198 setup ($GRUB_DEV)
pascal@214 199 quit
pascal@214 200 EOT
pascal@274 201 umount -d /media/floppy
pascal@274 202 fi ;;
pascal@264 203 cdrom*)
pascal@266 204 mkdir -p $1/boot/grub 2> /dev/null
pascal@274 205 cp /tmp/floppybox.grub.menu $1/boot/grub/menu.lst
pascal@274 206 if [ "$2" = "grub4dos" ]; then
pascal@274 207 unlzma -c /usr/share/boot/grldr.lzma > $1/boot/grub/grldr
pascal@274 208 genisoimage -R -o boot.iso -b boot/grub/grldr \
pascal@274 209 -c boot/boot.cat -no-emul-boot -boot-load-seg 0x1000 \
pascal@274 210 -hide boot/boot.cat -input-charset iso8859-1 $1
pascal@274 211 else
pascal@274 212 cp /usr/lib/grub/i386-pc/stage2_eltorito $1/boot/grub
pascal@274 213 genisoimage -R -o boot.iso -b boot/grub/stage2_eltorito \
pascal@274 214 -c boot/boot.cat -no-emul-boot -boot-load-size 4 \
pascal@274 215 -hide boot/boot.cat -input-charset iso8859-1 \
pascal@274 216 -boot-info-table $1
pascal@274 217 fi ;;
pascal@264 218 esac
pascal@264 219 }
pascal@264 220
pascal@264 221 while true; do
pascal@264 222
pascal@264 223 if [ "$1" == "call" ]; then
pascal@264 224 case "$2" in
pascal@274 225 mkmenu) mkmenu $3;;
pascal@264 226 install)
pascal@264 227 DIR=/tmp/mkbootfloppy$$
pascal@264 228 mkdir -p $DIR
pascal@264 229 DEVICE=$4
pascal@264 230 file=$5
pascal@264 231 case "$3" in
pascal@274 232 grub*)
pascal@264 233 mkdir -p $DIR/boot/grub
pascal@274 234 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ] \
pascal@264 235 && cat /usr/share/boot/btmgr /dev/zero | \
pascal@264 236 dd bs=18k count=80 | gzip -9 > \
pascal@264 237 $DIR/boot/btmgr.gz \
pascal@264 238 && unlzma -c /usr/share/boot/memdisk.lzma > \
pascal@264 239 $DIR/boot/memdisk
pascal@382 240 [ -f /usr/share/boot/plpbt.bin ] \
pascal@382 241 && cp /usr/share/boot/plpbt.bin $DIR/boot
pascal@274 242 [ -f /usr/share/boot/etherboot ] \
pascal@264 243 && cp /usr/share/boot/etherboot $DIR/boot
pascal@264 244 [ -f /boot/gpxe ]\
pascal@264 245 && cp /boot/gpxe $DIR/boot
pascal@274 246 [ -f /usr/share/boot/memtest.lzma -a \
pascal@274 247 -f /usr/share/boot/memdisk.lzma ] \
pascal@274 248 && unlzma -c /usr/share/boot/memtest.lzma | \
pascal@274 249 cat - /dev/zero | dd bs=18k count=80 | \
pascal@274 250 gzip -9 > $DIR/boot/memtest.gz \
pascal@274 251 && unlzma -c /usr/share/boot/memdisk.lzma > \
pascal@274 252 $DIR/boot/memdisk
pascal@274 253 install_grub $DIR $3
pascal@264 254 ;;
pascal@264 255 *)
pascal@264 256 case "$file" in
pascal@264 257 *.lzma) action="unlzma -c";;
pascal@264 258 *.gz) action="zcat";;
pascal@264 259 *) action="cat";;
pascal@264 260 esac
pascal@264 261 case "$DEVICE" in
pascal@264 262 /dev/*) $action $file > $DEVICE;;
pascal@274 263 flopp*) $action $file | cat - /dev/zero | \
pascal@274 264 dd bs=18k count=80 > boot.fd;;
pascal@264 265 cdrom*)
pascal@264 266 mkdir -p $DIR/boot/grub
pascal@264 267 case "$3" in
pascal@382 268 btmgr|memtest)
pascal@264 269 $action $file | cat - /dev/zero | \
pascal@264 270 dd bs=18k count=80 | \
pascal@264 271 gzip -9 > $DIR/boot/$3.gz
pascal@264 272 unlzma -c /usr/share/boot/memdisk.lzma \
pascal@264 273 > $DIR/boot/memdisk
pascal@274 274 cat > /tmp/floppybox.grub.menu << EOT
pascal@274 275 # grub menu
pascal@264 276 timeout 0
pascal@264 277 title $3
pascal@264 278 kernel /boot/memdisk floppy c=80 h=2 s=18
pascal@264 279 initrd /boot/$3.gz
pascal@264 280 EOT
pascal@264 281 ;;
pascal@264 282 *) $action $file > $DIR/boot/$3
pascal@274 283 cat > /tmp/floppybox.grub.menu << EOT
pascal@274 284 # grub menu
pascal@264 285 timeout 0
pascal@264 286 title $3
pascal@264 287 kernel /boot/$3
pascal@264 288 EOT
pascal@264 289 ;;
pascal@264 290 esac
pascal@274 291 install_grub $DIR grub
pascal@264 292 ;;
pascal@264 293 esac
pascal@264 294 ;;
pascal@264 295 esac
pascal@264 296 rm -rf $DIR
pascal@264 297 ;;
pascal@220 298 get-plop)
pascal@382 299 mkdir -p /tmp/get-plop$$
pascal@382 300 PLOP_URL=http://mirror.slitaz.org/boot/plpbt.bin
pascal@382 301 wget -O - $PLOP_URL > /tmp/get-plop$$/plpbt.bin
pascal@382 302 VERSION="$(strings /tmp/get-plop$$/plpbt.bin \
pascal@382 303 | grep 'Boot Manager v' | sed 's/.* v\([0-9\.]*\) .*/\1/')"
pascal@382 304 mkdir -p $(dirname /tmp/get-plop$$/plop-$VERSION/fs/$3)
pascal@382 305 mv /tmp/get-plop$$/plpbt.bin \
pascal@382 306 /tmp/get-plop$$/plop-$VERSION/fs/$3
pascal@285 307 if [ -s /tmp/get-plop$$/plop-$VERSION/fs/$3 ]; then
pascal@285 308 cat > /tmp/get-plop$$/plop-$VERSION/receipt <<EOT
pascal@220 309 PACKAGE="plop"
pascal@285 310 VERSION="$VERSION"
pascal@220 311 CATEGORY="non-free"
pascal@220 312 SHORT_DESC="Plop boot manager."
pascal@220 313 WEB_SITE="http://www.plop.at/en/bootmanager.html"
pascal@220 314 EOT
pascal@285 315 ( cd /tmp/get-plop$$ ; tazpkg pack plop-$VERSION )
pascal@285 316 tazpkg install /tmp/get-plop$$/plop-$VERSION.tazpkg
pascal@264 317 fi
pascal@220 318 rm -rf /tmp/get-plop$$
pascal@220 319 ;;
pascal@214 320 *) echo "Invalid command $0 $@" 1>&2
pascal@214 321 exit 1;;
pascal@214 322 esac
pascal@214 323 exit 0
pascal@214 324 fi
pascal@214 325
pascal@213 326 if [ -z "$XAUTHORITY" ]; then
pascal@213 327
pascal@213 328 : ${DIALOG=dialog}
pascal@213 329
pascal@213 330 DEVICE=/dev/fd0
pascal@213 331 while true; do
pascal@213 332 exec 3>&1
pascal@213 333 ID_SOURCE=`$DIALOG --title " Choose a boot floppy " \
pascal@213 334 --backtitle "Boot Floppy Creation on $DEVICE" --clear \
pascal@213 335 --extra-button --extra-label "Change floppy" \
pascal@213 336 --yes-label "Install" \
pascal@213 337 --no-label "Quit" \
pascal@213 338 --colors --radiolist "
paul@317 339 Create a floppy or a cdrom to boot a LiveCD in a PXE network...
pascal@264 340 May need a floppy disk in drive. Erase the whole floppy disk.
pascal@213 341 " 18 70 50\
pascal@220 342 SmartBtmgr "Boot any partition or ATAPI CD-ROM." on \
pascal@382 343 Plop "Boot USB harddisk floppy or CD/DVD." off \
pascal@220 344 Etherboot "Replacement for proprietary PXE ROMs." off \
pascal@223 345 gPXE "Boot from http://boot.slitaz.org/" off \
pascal@220 346 Memtest86+ "Memory failures detection tool." off \
paul@333 347 Grub4DOS "Enhanced grub version supporting NTFS." off \
pascal@220 348 Grub "Boot loader with command shell." off 2>&1 1>&3`
pascal@213 349 retval=$?
pascal@213 350 exec 3>&-
pascal@213 351 check_retval
pascal@213 352 if [ "$retval" = "3" ]; then
pascal@213 353 select_floppy
pascal@213 354 continue;
pascal@213 355 fi
pascal@213 356 while read key file pkg; do
pascal@213 357 [ "$key" = "$ID_SOURCE" ] || continue
pascal@213 358 if [ ! -f "$file" ]; then
pascal@213 359 $DIALOG --title " Install package " --colors \
pascal@213 360 --backtitle "Boot Floppy Creation" --clear \
pascal@213 361 --yes-label "Install" \
pascal@213 362 --no-label "Quit" \
pascal@213 363 --yesno "The package $pkg is not yet installed. Install it ?" 18 70
pascal@213 364 retval=$?
pascal@220 365 if [ "$pkg" = "plop" ]; then
pascal@220 366 bootfloppybox call get-plop $file
pascal@220 367 else
pascal@264 368 tazpkg get-install $pkg
pascal@220 369 fi
pascal@213 370 fi
pascal@264 371 bootfloppybox call install "$pkg" "$DEVICE" "$file"
pascal@213 372 exit 0
pascal@213 373 done <<EOT
pascal@213 374 SmartBtmgr /usr/share/boot/btmgr btmgr
pascal@382 375 Plop /usr/share/boot/plpbt.bin plop
pascal@213 376 Etherboot /usr/share/boot/etherboot etherboot
pascal@222 377 gPXE /boot/gpxe gpxe
pascal@213 378 Memtest86+ /usr/share/boot/memtest.lzma memtest
pascal@274 379 Grub4DOS /usr/share/boot/grldr.lzma grub4dos
pascal@213 380 Grub /usr/sbin/grub grub
pascal@213 381 EOT
pascal@213 382 done
pascal@213 383 fi
pascal@264 384 #
pascal@264 385 # Describe gPXE arguments.
pascal@264 386 #
pascal@264 387 export HELP='
pascal@264 388 <window title="gPXE forced url" icon-name="gtk-floppy">
pascal@264 389 <vbox>
pascal@264 390 <text use-markup="true">
pascal@264 391 <label>"
pascal@264 392 <b>Web boot parameters</b>"
pascal@264 393 </label>
pascal@264 394 </text>
pascal@264 395 <frame>
pascal@264 396 <text wrap="true" width-chars="58" use-markup="true">
pascal@264 397 <label>
paul@333 398 "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.
pascal@264 399
paul@317 400 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>.
pascal@264 401
paul@333 402 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>
pascal@264 403
paul@317 404 The <i>nodhcp</i> keyword avoids dhcp timeouts and the <i>url=</i> keyword is optional when the url is the only one argument.
pascal@337 405
paul@350 406 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.
pascal@264 407 "
pascal@264 408 </label>
pascal@264 409 </text>
pascal@264 410 </frame>
pascal@264 411 </vbox>
pascal@264 412 </window>
pascal@264 413 '
pascal@264 414 #
pascal@330 415 # Read/write floppy images
pascal@330 416 #
pascal@330 417 export FLOPPY_IMAGE='
pascal@330 418 <window title="Floppy image manager" icon-name="gtk-floppy">
pascal@330 419 <vbox>
pascal@330 420 <frame Floppy disk drive>
pascal@330 421 <hbox>
pascal@330 422 <text use-markup="true">
pascal@330 423 <label>"<b>Device : </b>"</label>
pascal@330 424 </text>
pascal@330 425 <combobox>
pascal@330 426 <variable>DEVICE</variable>'
pascal@330 427 for i in /sys/devices/platform/floppy.*/block:*; do
pascal@330 428 [ -d $i ] || continue
pascal@330 429 FLOPPY_IMAGE="$FLOPPY_IMAGE
pascal@330 430 <item>/dev/${i#*block:}</item>"
pascal@330 431 done
pascal@330 432 FLOPPY_IMAGE="$FLOPPY_IMAGE
pascal@330 433 </combobox>
pascal@330 434 <button>
pascal@330 435 <label>Format floppy</label>
pascal@330 436 <input file icon=\"media-floppy\"></input>
pascal@330 437 <action>fdformat -n $DEVICE</action>
pascal@330 438 </button>
pascal@330 439 </hbox>
pascal@330 440 </frame>
pascal@330 441 <frame Floppy image file>
pascal@330 442 <hbox>
pascal@330 443 <text use-markup=\"true\">
pascal@330 444 <label>\"<b>File : </b>\"</label>
pascal@330 445 </text>
pascal@330 446 <entry accept=\"filename\">
pascal@330 447 <label>Select a floppy image</label>
pascal@330 448 <variable>IMAGE</variable>
pascal@330 449 </entry>
pascal@330 450 <button>
pascal@330 451 <input file stock=\"gtk-open\"></input>
pascal@330 452 <action type=\"fileselect\">IMAGE</action>
pascal@330 453 </button>
pascal@330 454 </hbox>
pascal@330 455 </frame>
pascal@330 456 <hbox>
pascal@330 457 <button>
pascal@330 458 <input file icon=\"go-jump\"></input>
pascal@330 459 <label>Write image to floppy</label>
pascal@330 460 <action>dd if=\$IMAGE of=\$DEVICE</action>
pascal@330 461 </button>
pascal@330 462 <button>
pascal@330 463 <input file icon=\"undo\"></input>
pascal@330 464 <label>Get floppy image</label>
pascal@330 465 <action>dd if=\$DEVICE of=\$IMAGE</action>
pascal@330 466 </button>
pascal@330 467 <button>
pascal@330 468 <input file icon=\"gtk-close\"></input>
pascal@330 469 <action type=\"closewindow\">FLOPPY_IMAGE</action>
pascal@330 470 </button>
pascal@330 471 </hbox>
pascal@330 472 </vbox>
pascal@330 473 </window>
pascal@330 474 "
pascal@330 475 #
pascal@130 476 # Write bootfloppy image to floppy device.
pascal@130 477 #
pascal@130 478 BOOT_DIALOG='
pascal@139 479 <window title="bootfloppybox" icon-name="gtk-floppy">
pascal@130 480 <vbox>
pascal@130 481
pascal@130 482 <text use-markup="true">
pascal@130 483 <label>
pascal@130 484 "
pascal@130 485 <b>SliTaz - Bootfloppybox</b>"
pascal@130 486 </label>
pascal@130 487 </text>
pascal@134 488 <text wrap="false" width-chars="44" use-markup="true">
pascal@130 489 <label>
pascal@130 490 "
paul@333 491 Create a floppy or a cdrom to boot a LiveCD in a PXE network or the WEB...
pascal@264 492 May need a floppy disk in drive. Erase the whole floppy disk.
pascal@130 493 "
pascal@130 494 </label>
pascal@130 495 </text>
pascal@130 496
pascal@130 497 <frame Floppy disk drive>
pascal@130 498 <hbox>
pascal@130 499 <text use-markup="true">
pascal@132 500 <label>"<b>Device : </b>"</label>
pascal@130 501 </text>
pascal@264 502 <combobox>
pascal@264 503 <variable>DEVICE</variable>'
pascal@264 504 for i in /sys/devices/platform/floppy.*/block:*; do
pascal@264 505 [ -d $i ] || continue
pascal@264 506 BOOT_DIALOG="$BOOT_DIALOG
pascal@264 507 <item>/dev/${i#*block:}</item>"
pascal@264 508 done
paul@333 509 tmp=' <item>floppy image (boot.fd)</item>
paul@333 510 <item>cdrom image (boot.iso)</item>
pascal@264 511 </combobox>
pascal@132 512 <button>
pascal@132 513 <label>Format floppy</label>
pascal@330 514 <input file icon="media-floppy"></input>
pascal@264 515 <action>case "$DEVICE" in /dev/*) fdformat -n $DEVICE;; esac</action>
pascal@132 516 </button>
pascal@130 517 </hbox>
pascal@130 518 </frame>
pascal@274 519 <notebook labels="LiveCD|USB|PXE Network|WEB Network|Memory Test|Windows|Expert">
pascal@130 520 '
pascal@264 521 BOOT_DIALOG="$BOOT_DIALOG$tmp"
pascal@130 522 while read name file pkg desc; do
pascal@130 523 tmp="<frame $name>
pascal@130 524 <hbox>
pascal@130 525 <text wrap=\"true\" width-chars=\"44\" use-markup=\"true\">
pascal@130 526 <label>
pascal@130 527 \"
pascal@130 528 $(echo -e $desc)
pascal@130 529 \"
pascal@130 530 </label>
pascal@130 531 </text>
pascal@130 532 </hbox>
pascal@264 533 <hbox>
pascal@130 534 "
pascal@130 535 if [ -f $file ]; then
pascal@274 536 if [ "$pkg" = "grub" -o "$pkg" = "grub4dos" ]; then
pascal@135 537 tmp="$tmp
pascal@135 538 <button>
pascal@200 539 <label>Grub menu</label>
pascal@200 540 <input file icon=\"accessories-text-editor\"></input>
pascal@274 541 <action>bootfloppybox call mkmenu $pkg</action>
pascal@214 542 <action type=\"lauch\">leafpad /tmp/floppybox.grub.menu</action>
pascal@200 543 </button>
pascal@135 544 "
pascal@267 545 elif [ "$pkg" = "etherboot" ]; then
pascal@267 546 tmp="$tmp
pascal@267 547 <button>
pascal@267 548 <input file icon=\"browser\"></input>
pascal@267 549 <label>Wiki</label>
pascal@267 550 <action>firefox http://wiki.slitaz.org/doku.php?id=quickstart:pxe &</action>
pascal@267 551 </button>
pascal@267 552 "
pascal@233 553 elif [ "$pkg" = "gpxe" ]; then
pascal@233 554 tmp="$tmp
pascal@233 555 <text wrap=\"true\" use-markup=\"true\">
pascal@233 556 <label> \"<b>Boot URL:</b>\" </label>
pascal@233 557 </text>
pascal@233 558 <entry>
pascal@233 559 <default>$(dd if=$file bs=1 skip=519 count=255 2>/dev/null | strings)</default>
pascal@233 560 <variable>URL</variable>
pascal@233 561 </entry>
pascal@264 562 </hbox>
pascal@264 563 <hbox>
pascal@267 564 <button>
pascal@267 565 <input file icon=\"browser\"></input>
pascal@267 566 <label>Wiki</label>
pascal@267 567 <action>firefox http://wiki.slitaz.org/doku.php?id=quickstart:pxe &</action>
pascal@267 568 </button>
pascal@264 569 <button help>
pascal@264 570 <action type=\"launch\">HELP</action>
pascal@264 571 </button>
pascal@233 572 <button>
pascal@233 573 <label>Update</label>
pascal@233 574 <input file icon=\"reload\"></input>
pascal@233 575 <action>echo -n \"\$URL\" | cat - /dev/zero | dd conv=notrunc bs=1 count=255 seek=519 of=$file 2>/dev/null</action>
pascal@233 576 </button>
pascal@264 577 "
pascal@264 578 fi
pascal@267 579 receipt=/var/lib/tazpkg/installed/$pkg/receipt
pascal@267 580 if [ -f $receipt ]; then
pascal@267 581 . $receipt
pascal@267 582 tmp="$tmp
pascal@267 583 <button>
pascal@267 584 <input file icon=\"browser\"></input>
pascal@267 585 <label>Web</label>
pascal@267 586 <action>firefox $WEB_SITE &</action>
pascal@267 587 </button>
pascal@267 588 "
pascal@267 589 fi
pascal@264 590 tmp="$tmp
pascal@233 591 <button>
pascal@233 592 <label>Write floppy</label>
pascal@233 593 <input file icon=\"forward\"></input>
pascal@264 594 <action>bootfloppybox call install \"$pkg\" \"\$DEVICE\" \"$file\"</action>
pascal@233 595 </button>
pascal@233 596 </hbox>
pascal@233 597 </frame>
pascal@233 598 "
pascal@130 599 else
pascal@264 600 tmp2="tazpkg get-install $pkg --forced"
pascal@220 601 [ "$pkg" = "plop" ] && tmp2="bootfloppybox call get-plop $file"
pascal@130 602 tmp="$tmp
pascal@157 603 <text wrap=\"true\" width-chars=\"34\" use-markup=\"true\">
pascal@130 604 <label>
pascal@130 605 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
pascal@130 606 </label>
pascal@130 607 </text>
pascal@157 608 <button>
pascal@157 609 <input file icon=\"go-jump\"></input>
pascal@157 610 <label>Install</label>
pascal@264 611 <action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
pascal@264 612 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"$tmp2 ; sleep 2\"</action>
pascal@221 613 <action type=\"exit\">restart</action>
pascal@157 614 </button>
pascal@130 615 </hbox>
pascal@130 616 </frame>
pascal@130 617 "
pascal@130 618 fi
pascal@130 619 BOOT_DIALOG="$BOOT_DIALOG$tmp"
pascal@130 620 done <<EOT
pascal@130 621 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot any partition or ATAPI CD-ROM.
pascal@382 622 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.
pascal@130 623 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement for proprietary PXE or NBI ROMs.
pascal@233 624 gPXE /boot/gpxe gpxe PXE / iSCSI / AoE network bootloader.
pascal@130 625 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
paul@333 626 Grub4DOS /usr/share/boot/grldr.lzma grub4dos Enhanced grub version supporting NTFS.
paul@333 627 Grub /usr/sbin/grub grub General purpose boot loader with command shell.
pascal@130 628 EOT
pascal@130 629 tmp='
pascal@134 630 </notebook>
pascal@130 631 <hbox>
pascal@130 632 <button>
pascal@330 633 <input file icon="media-cdrom"></input>
pascal@330 634 <label>Burn cdrom image</label>
pascal@330 635 <action>burnbox</action>
pascal@330 636 </button>
pascal@330 637 <button>
pascal@330 638 <input file icon="media-floppy"></input>
pascal@330 639 <label>Manage floppy image</label>
pascal@330 640 <action type="launch">FLOPPY_IMAGE</action>
pascal@330 641 </button>
pascal@330 642 <button>
pascal@130 643 <input file icon="exit"></input>
pascal@130 644 <label>Exit</label>
pascal@130 645 <action type="exit">Exit</action>
pascal@130 646 </button>
pascal@130 647 </hbox>
pascal@130 648
pascal@130 649 </vbox>
pascal@130 650 </window>
pascal@130 651 '
pascal@130 652 BOOT_DIALOG="$BOOT_DIALOG$tmp"
pascal@130 653 export BOOT_DIALOG
pascal@130 654
pascal@130 655 # Only root can create floppy.
pascal@130 656 check_root
pascal@221 657 gtkdialog --program=BOOT_DIALOG | grep -q 'EXIT="restart"' && continue
pascal@214 658 rm -f /tmp/floppybox.grub.menu
pascal@130 659 exit 0
pascal@221 660 done