slitaz-tools view tinyutils/bootfloppybox @ rev 223

bootfloppybox: update gPXE info. No more fallback but default (forced_url)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jun 30 08:45:36 2008 +0000 (2008-06-30)
parents 235d972c2110
children c1d9f377135b
line source
1 #! /bin/sh
2 #
3 # Gtkdialog box for the mount command. Part of SliTaz tools.
4 #
5 VERSION=20080625
6 PLOP_URL=http://download.plop.at/plop/bootmngr/plpbt50rc12flp.zip
8 # Check if user is root.
9 check_root()
10 {
11 if test $(id -u) != 0 ; then
12 echo -e "
13 You must be root to run `basename $0`. Please type 'su' and
14 root password to become super-user.\n"
15 exit 0
16 fi
17 }
19 # This function is used after each screen to contine or abort install.
20 check_retval()
21 {
22 case $retval in
23 1)
24 rm -f /tmp/floppybox.grub.menu
25 echo -e "\nVoluntary exit.\n" && exit 0 ;;
26 255)
27 rm -f /tmp/floppybox.grub.menu
28 echo -e "ESC pressed.\n" && exit 0 ;;
29 esac
30 }
32 select_floppy()
33 {
34 exec 3>&1
35 DEVICE=`$DIALOG --title " Floppy device " \
36 --backtitle "Boot Floppy Creation" --clear \
37 --extra-button --extra-label "Format" \
38 --colors --inputbox "
39 Enter floppy device (default /dev/fd0)
40 " 18 70 2>&1 1>&3`
41 retval=$?
42 exec 3>&-
43 check_retval
44 case "$DEVICE" in
45 /dev/fd*);;
46 *) DEVICE=/dev/fd0;;
47 esac
48 if [ "$retval" = "3" ]; then
49 fdformat -n $DEVICE
50 fi
51 }
53 while true; do
55 if [ "$1" == "call" ]; then
56 case "$2" in
57 setup-grub)
58 DEVICE=$3
59 mke2fs $DEVICE
60 mkdir /media/floppy
61 mount $DEVICE /media/floppy
62 mkdir -p /media/floppy/boot/grub
63 cp /usr/lib/grub/i386-pc/stage? /media/floppy/boot/grub
64 cp /tmp/floppybox.grub.menu /media/floppy/boot/grub/menu.lst
65 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ]\
66 && cat /usr/share/boot/btmgr /dev/zero | \
67 dd bs=18k count=80 | gzip -9 > \
68 /media/floppy/boot/btmgr.gz \
69 && unlzma -c /usr/share/boot/memdisk.lzma > \
70 /media/floppy/boot/memdisk
71 [ -f /usr/share/boot/plop.gz -a \
72 -f /usr/share/boot/memdisk.lzma ]\
73 && zcat /usr/share/boot/plop.gz | cat - /dev/zero | \
74 dd bs=18k count=80 | gzip -9 > \
75 /media/floppy/boot/plop.gz \
76 && unlzma -c /usr/share/boot/memdisk.lzma > \
77 /media/floppy/boot/memdisk
78 [ -f /usr/share/boot/etherboot ]\
79 && cp /usr/share/boot/etherboot /media/floppy/boot
80 [ -f /boot/gpxe ]\
81 && cp /boot/gpxe /media/floppy/boot
82 [ -f /usr/share/boot/memtest.lzma ]\
83 && unlzma -c /usr/share/boot/memtest.lzma > \
84 /media/floppy/boot/memtest
85 [ -f /usr/share/boot/grub.exe.lzma ]\
86 && unlzma -c /usr/share/boot/grub.exe.lzma > \
87 /media/floppy/boot/grub.exe
88 grub-set-default --root-directory=/media/floppy 0
89 umount $DEVICE
90 grub --batch <<EOT
91 root (${DEVICE#/dev/})
92 setup (${DEVICE#/dev/})
93 quit
94 EOT
95 ;;
96 get-plop)
97 wget -O - $PLOP_URL | unzip -p /dev/stdin | \
98 dd bs=18k count=6 | gzip -9 > $3
99 [ -s $3 ] || exit 1
100 mkdir /tmp/get-plop$$
101 cd /tmp/get-plop$$
102 echo $3 > files.list
103 cpio -o -H newc < files.list | gzip -9 > fs.cpio.gz
104 cat > receipt <<EOT
105 PACKAGE="plop"
106 VERSION="1.0"
107 CATEGORY="non-free"
108 SHORT_DESC="Plop boot manager."
109 WEB_SITE="http://www.plop.at/en/bootmanager.html"
110 EOT
111 cpio -o -H newc > plop-1.0.tazpkg <<EOT
112 receipt
113 files.list
114 fs.cpio.gz
115 EOT
116 tazpkg install plop-1.0.tazpkg
117 cd ..
118 rm -rf /tmp/get-plop$$
119 ;;
120 *) echo "Invalid command $0 $@" 1>&2
121 exit 1;;
122 esac
123 exit 0
124 fi
126 cat > /tmp/floppybox.grub.menu <<EOT
127 default saved
128 timeout 10
130 title Windows (example on /dev/hda1)
131 rootnoverify (hd0,0)
132 chainloader +1
133 save default
135 title Slitaz Live (example on /dev/hda1)
136 root (hd0,0)
137 kernel /boot/bzImage rw root=/dev/null vga=normal
138 initrd /boot/rootfs.gz
139 save default
141 title Slitaz Installed (example on /dev/hda2)
142 root (hd0,1)
143 kernel /boot/bzImage ro root=/dev/hda2 vga=normal
144 save default
146 EOT
147 [ -f /usr/share/boot/btmgr -a -f /usr/share/boot/memdisk.lzma ]\
148 && cat >> /tmp/floppybox.grub.menu <<EOT
149 title Smart Boot Manager (boot floppy, hard disk or CD/DVD)
150 kernel /boot/memdisk floppy c=80 h=2 s=18
151 initrd /boot/btmgr.gz
153 EOT
154 [ -f /usr/share/boot/plop.gz -a -f /usr/share/boot/memdisk.lzma ]\
155 && cat >> /tmp/floppybox.grub.menu <<EOT
156 title Plop Boot Manager (boot floppy, hard disk, CD/DVD or USB)
157 kernel /boot/memdisk floppy c=80 h=2 s=18
158 initrd /boot/plop.gz
160 EOT
161 [ -f /usr/share/boot/etherboot ] && cat >> /tmp/floppybox.grub.menu <<EOT
162 title Etherboot (LAN boot, PXE or NBI)
163 kernel /boot/etherboot
165 EOT
166 [ -f /boot/gpxe ] && cat >> /tmp/floppybox.grub.menu <<EOT
167 title gPXE (default boot form http://boot.slitaz.org/, PXE/iSCSI/AoE support)
168 kernel /boot/gpxe
170 EOT
171 [ -f /usr/share/boot/memtest.lzma ] && cat >> /tmp/floppybox.grub.menu <<EOT
172 title Memtest86+
173 kernel /boot/memtest
175 EOT
176 [ -f /usr/share/boot/grub.exe.lzma ] && cat >> /tmp/floppybox.grub.menu <<EOT
177 title Grub4Dos
178 kernel /boot/grub/grub.exe --config-file="configfile (fd0)/boot/grub/menu4dos.lst"
180 EOT
182 if [ -z "$XAUTHORITY" ]; then
184 : ${DIALOG=dialog}
186 DEVICE=/dev/fd0
187 while true; do
188 exec 3>&1
189 ID_SOURCE=`$DIALOG --title " Choose a boot floppy " \
190 --backtitle "Boot Floppy Creation on $DEVICE" --clear \
191 --extra-button --extra-label "Change floppy" \
192 --yes-label "Install" \
193 --no-label "Quit" \
194 --colors --radiolist "
195 Create a floppy to boot a LiveCD, in a PXE network...
196 Need a floppy disk in drive. Erase the whole floppy disk.
197 " 18 70 50\
198 SmartBtmgr "Boot any partition or ATAPI CD-ROM." on \
199 Plop "Boot harddisk floppy CD/DVD or USB." off \
200 Etherboot "Replacement for proprietary PXE ROMs." off \
201 gPXE "Boot from http://boot.slitaz.org/" off \
202 Memtest86+ "Memory failures detection tool." off \
203 Grub "Boot loader with command shell." off 2>&1 1>&3`
204 retval=$?
205 exec 3>&-
206 check_retval
207 if [ "$retval" = "3" ]; then
208 select_floppy
209 continue;
210 fi
211 while read key file pkg; do
212 [ "$key" = "$ID_SOURCE" ] || continue
213 if [ ! -f "$file" ]; then
214 $DIALOG --title " Install package " --colors \
215 --backtitle "Boot Floppy Creation" --clear \
216 --yes-label "Install" \
217 --no-label "Quit" \
218 --yesno "The package $pkg is not yet installed. Install it ?" 18 70
219 retval=$?
220 if [ "$pkg" = "plop" ]; then
221 bootfloppybox call get-plop $file
222 else
223 tazpkg get-install $pkg
224 fi
225 fi
226 if [ "$pkg" = "grub" ]; then
227 bootfloppybox call setup-grub $DEVICE
228 else
229 case "$file" in
230 *.lzma) action="unlzma -c";;
231 *.gz) action="zcat";;
232 *) action="cat";;
233 esac
234 $action $file > $DEVICE
235 fi
236 exit 0
237 done <<EOT
238 SmartBtmgr /usr/share/boot/btmgr btmgr
239 Plop /usr/share/boot/plop.gz plop
240 Etherboot /usr/share/boot/etherboot etherboot
241 gPXE /boot/gpxe gpxe
242 Memtest86+ /usr/share/boot/memtest.lzma memtest
243 Grub /usr/sbin/grub grub
244 EOT
245 done
246 fi
247 # Write bootfloppy image to floppy device.
248 #
249 BOOT_DIALOG='
250 <window title="bootfloppybox" icon-name="gtk-floppy">
251 <vbox>
253 <text use-markup="true">
254 <label>
255 "
256 <b>SliTaz - Bootfloppybox</b>"
257 </label>
258 </text>
259 <text wrap="false" width-chars="44" use-markup="true">
260 <label>
261 "
262 Create a floppy to boot a LiveCD, in a PXE network or WEB...
263 Need a floppy disk in drive. Erase the whole floppy disk.
264 "
265 </label>
266 </text>
268 <frame Floppy disk drive>
269 <hbox>
270 <text use-markup="true">
271 <label>"<b>Device : </b>"</label>
272 </text>
273 <entry>
274 <default>/dev/fd0</default>
275 <variable>DEVICE</variable>
276 </entry>
277 <button>
278 <label>Format floppy</label>
279 <input file icon="forward"></input>
280 <action>fdformat -n $DEVICE</action>
281 </button>
282 </hbox>
283 </frame>
284 <notebook labels="LiveCD|USB|PXE Network|WEB Network|Memory Test|Expert">
285 '
286 while read name file pkg desc; do
287 tmp="<frame $name>
288 <hbox>
289 <text wrap=\"true\" width-chars=\"44\" use-markup=\"true\">
290 <label>
291 \"
292 $(echo -e $desc)
293 \"
294 </label>
295 </text>
296 </hbox>
297 "
298 if [ -f $file ]; then
299 case "$file" in
300 *.lzma) action="unlzma -c";;
301 *.gz) action="zcat";;
302 *) action="cat";;
303 esac
304 if [ "$pkg" = "grub" ]; then
305 tmp="$tmp
306 <hbox>
307 <button>
308 <label>Grub menu</label>
309 <input file icon=\"accessories-text-editor\"></input>
310 <action type=\"lauch\">leafpad /tmp/floppybox.grub.menu</action>
311 </button>
312 <button>
313 <label>Write floppy</label>
314 <input file icon=\"forward\"></input>
315 <action>bootfloppybox call setup-grub \$DEVICE</action>
316 </button>
317 </hbox>
318 </frame>
319 "
320 else
321 tmp="$tmp
322 <hbox>
323 <button>
324 <label>Write floppy</label>
325 <input file icon=\"forward\"></input>
326 <action>$action $file > \$DEVICE</action>
327 </button>
328 </hbox>
329 </frame>
330 "
331 fi
332 else
333 tmp2="[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
334 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title \"$pkg install\" -e \"tazpkg get-install $pkg ; echo -e \\\"----\\n\\nENTER to continue...\\\" && read close\""
335 [ "$pkg" = "plop" ] && tmp2="bootfloppybox call get-plop $file"
336 tmp="$tmp
337 <hbox>
338 <text wrap=\"true\" width-chars=\"34\" use-markup=\"true\">
339 <label>
340 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
341 </label>
342 </text>
343 <button>
344 <input file icon=\"go-jump\"></input>
345 <label>Install</label>
346 <action>$tmp2</action>
347 <action type=\"exit\">restart</action>
348 </button>
349 </hbox>
350 </frame>
351 "
352 fi
353 BOOT_DIALOG="$BOOT_DIALOG$tmp"
354 done <<EOT
355 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot any partition or ATAPI CD-ROM.
356 Plop /usr/share/boot/plop.gz plop This non free Boot Manager can boot floppy, hardisk, USB or CD/DVD. Hit Ctrl-ESC for text mode.
357 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement for proprietary PXE or NBI ROMs.
358 gPXE /boot/gpxe gpxe This PXE / iSCSI / AoE network bootloader boots from http://boot.slitaz.org/ by default.
359 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
360 Grub /usr/sbin/grub grub General purpose boot loader with command shell
361 EOT
362 tmp='
363 </notebook>
364 <hbox>
365 <button>
366 <input file icon="exit"></input>
367 <label>Exit</label>
368 <action type="exit">Exit</action>
369 </button>
370 </hbox>
372 </vbox>
373 </window>
374 '
375 BOOT_DIALOG="$BOOT_DIALOG$tmp"
376 export BOOT_DIALOG
378 # Only root can create floppy.
379 check_root
380 gtkdialog --program=BOOT_DIALOG | grep -q 'EXIT="restart"' && continue
381 rm -f /tmp/floppybox.grub.menu
382 exit 0
383 done