slitaz-tools view tinyutils/bootfloppybox @ rev 158

Modified tazx for Openbox as default WM
author Christophe Lincoln <pankso@slitaz.org>
date Tue Apr 22 22:58:03 2008 +0200 (2008-04-22)
parents 5a8b1bbb13f1
children c5bcea9f5099
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="gtk-floppy">
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=\"34\" use-markup=\"true\">
109 <label>
110 \"<i>The package <b>$pkg</b> is not yet installed</i>\"
111 </label>
112 </text>
113 <button>
114 <input file icon=\"go-jump\"></input>
115 <label>Install</label>
116 <action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
117 <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\"</action>
118 <action type=\"exit\">Exit</action>
119 </button>
120 </hbox>
121 </frame>
122 "
123 fi
124 BOOT_DIALOG="$BOOT_DIALOG$tmp"
125 done <<EOT
126 SmartBtmgr /usr/share/boot/btmgr btmgr This OS independent Smart Boot Manager can boot any partition or ATAPI CD-ROM.
127 Etherboot /usr/share/boot/etherboot etherboot This network bootloader provides a replacement for proprietary PXE or NBI ROMs.
128 Memtest86+ /usr/share/boot/memtest.lzma memtest Memory failures detection tool.
129 Grub /usr/sbin/grub grub General purpose boot loader with command shell
130 EOT
131 tmp='
132 </notebook>
133 <hbox>
134 <button>
135 <input file icon="exit"></input>
136 <label>Exit</label>
137 <action type="exit">Exit</action>
138 </button>
139 </hbox>
141 </vbox>
142 </window>
143 '
144 BOOT_DIALOG="$BOOT_DIALOG$tmp"
145 export BOOT_DIALOG
147 # Only root can create floppy.
148 check_root
149 gtkdialog --program=BOOT_DIALOG
151 exit 0