slitaz-tools view tinyutils/bootfloppybox @ rev 135

bootfloppybox: add grub
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 09 19:50:17 2008 +0000 (2008-04-09)
parents 7c2e8f71cfda
children 490925fcedbe
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>umount \$DEVICE</action>
86 <action>echo -e \"root (\${DEVICE#/dev/})\\nsetup (\${DEVICE#/dev/})\\nquit\" | grub --batch </action>
87 </button>
88 </hbox>
89 </frame>
90 "
91 else
92 tmp="$tmp
93 <hbox>
94 <button>
95 <label>Write floppy</label>
96 <input file icon=\"forward\"></input>
97 <action>$action $file > \$DEVICE</action>
98 </button>
99 </hbox>
100 </frame>
101 "
102 fi
103 else
104 tmp="$tmp
105 <hbox>
106 <text wrap=\"true\" width-chars=\"44\" use-markup=\"true\">
107 <label>
108 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
109 </label>
110 </text>
111 </hbox>
112 </frame>
113 "
114 fi
115 BOOT_DIALOG="$BOOT_DIALOG$tmp"
116 done <<EOT
117 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot any partition or ATAPI CD-ROM.
118 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement for proprietary PXE or NBI ROMs.
119 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
120 Grub /usr/sbin/grub grub General purpose boot loader with command shell
121 EOT
122 tmp='
123 </notebook>
124 <hbox>
125 <button>
126 <input file icon="exit"></input>
127 <label>Exit</label>
128 <action type="exit">Exit</action>
129 </button>
130 </hbox>
132 </vbox>
133 </window>
134 '
135 BOOT_DIALOG="$BOOT_DIALOG$tmp"
136 export BOOT_DIALOG
138 # Only root can create floppy.
139 check_root
140 gtkdialog --program=BOOT_DIALOG
142 exit 0