slitaz-tools view tinyutils/bootfloppybox @ rev 136

bootfloppybox: add memtest and etherboot with grub
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 09 20:08:43 2008 +0000 (2008-04-09)
parents 6d24af2d7ed2
children 5a8b1bbb13f1
line source
1 #! /bin/sh
2 #
3 # Gtkdialog box for the mount command. Part of SliTaz tools.
4 #
5 VERSION=20080409
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 # Write bootfloppy image to floppy device.
19 #
20 BOOT_DIALOG='
21 <window title="bootfloppybox" icon-name="media-flash">
22 <vbox>
24 <text use-markup="true">
25 <label>
26 "
27 <b>SliTaz - Bootfloppybox</b>"
28 </label>
29 </text>
30 <text wrap="false" width-chars="44" use-markup="true">
31 <label>
32 "
33 Create a floppy to boot a LiveCD, in a PXE network...
34 Need a floppy disk in drive. Erase the whole floppy disk.
35 "
36 </label>
37 </text>
39 <frame Floppy disk drive>
40 <hbox>
41 <text use-markup="true">
42 <label>"<b>Device : </b>"</label>
43 </text>
44 <entry>
45 <default>/dev/fd0</default>
46 <variable>DEVICE</variable>
47 </entry>
48 <button>
49 <label>Format floppy</label>
50 <input file icon="forward"></input>
51 <action>fdformat -n $DEVICE</action>
52 </button>
53 </hbox>
54 </frame>
55 <notebook labels="LiveCD|PXE Network|Memory Test|Expert">
56 '
57 while read name file pkg desc; do
58 tmp="<frame $name>
59 <hbox>
60 <text wrap=\"true\" width-chars=\"44\" use-markup=\"true\">
61 <label>
62 \"
63 $(echo -e $desc)
64 \"
65 </label>
66 </text>
67 </hbox>
68 "
69 if [ -f $file ]; then
70 case "$file" in
71 *.lzma) action="unlzma -c";;
72 *.gz) action="zcat";;
73 *) action="cat";;
74 esac
75 if [ "$pkg" = "grub" ]; then
76 tmp="$tmp
77 <hbox>
78 <button>
79 <label>Write floppy</label>
80 <input file icon=\"forward\"></input>
81 <action>mke2fs \$DEVICE</action>
82 <action>mkdir /media/floppy ; mount \$DEVICE /media/floppy</action>
83 <action>mkdir -p /media/floppy/boot/grub</action>
84 <action>cp /usr/lib/grub/i386-pc/stage? /media/floppy/boot/grub</action>
85 <action>[ -f /usr/share/boot/etherboot ] && cp /usr/share/boot/etherboot /media/floppy/boot</action>
86 <action>[ -f /usr/share/boot/memtest.lzma ] && unlzma -c /usr/share/boot/memtest.lzma > /media/floppy/boot/memtest</action>
87 <action>umount \$DEVICE</action>
88 <action>echo -e \"root (\${DEVICE#/dev/})\\nsetup (\${DEVICE#/dev/})\\nquit\" | grub --batch </action>
89 </button>
90 </hbox>
91 </frame>
92 "
93 else
94 tmp="$tmp
95 <hbox>
96 <button>
97 <label>Write floppy</label>
98 <input file icon=\"forward\"></input>
99 <action>$action $file > \$DEVICE</action>
100 </button>
101 </hbox>
102 </frame>
103 "
104 fi
105 else
106 tmp="$tmp
107 <hbox>
108 <text wrap=\"true\" width-chars=\"44\" use-markup=\"true\">
109 <label>
110 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
111 </label>
112 </text>
113 </hbox>
114 </frame>
115 "
116 fi
117 BOOT_DIALOG="$BOOT_DIALOG$tmp"
118 done <<EOT
119 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot any partition or ATAPI CD-ROM.
120 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement for proprietary PXE or NBI ROMs.
121 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
122 Grub /usr/sbin/grub grub General purpose boot loader with command shell
123 EOT
124 tmp='
125 </notebook>
126 <hbox>
127 <button>
128 <input file icon="exit"></input>
129 <label>Exit</label>
130 <action type="exit">Exit</action>
131 </button>
132 </hbox>
134 </vbox>
135 </window>
136 '
137 BOOT_DIALOG="$BOOT_DIALOG$tmp"
138 export BOOT_DIALOG
140 # Only root can create floppy.
141 check_root
142 gtkdialog --program=BOOT_DIALOG
144 exit 0