tazpanel view floppy.cgi @ rev 531

index.cgi: add renice support (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Aug 28 14:03:48 2015 +0200 (2015-08-28)
parents
children 551a881b8292
line source
1 #!/bin/sh
2 #
3 # Floppy set CGI interface
4 #
5 # Copyright (C) 2015 SliTaz GNU/Linux - BSD License
6 #
8 # Common functions from libtazpanel
9 . lib/libtazpanel
10 get_config
13 case "$1" in
14 menu)
15 TEXTDOMAIN_original=$TEXTDOMAIN
16 export TEXTDOMAIN='floppy'
18 #which bootloader > /dev/null &&
19 cat <<EOT
20 <li><a data-icon="slitaz" href="floppy.cgi">$(_ 'Boot floppy')</a></li>
21 EOT
22 export TEXTDOMAIN=$TEXTDOMAIN_original
23 exit
24 esac
27 #
28 # Commands
29 #
31 error=
32 case " $(POST) " in
33 *\ doformat\ *)
34 fdformat $(POST fd)
35 which mkfs.$(POST fstype) > /dev/null 2>&1 &&
36 mkfs.$(POST fstype) $(POST fd)
37 ;;
38 *\ write\ *)
39 if [ "$(FILE fromimage tmpname)" ]; then
40 dd if=$(FILE fromimage tmpname) of=$(POST tofd)
41 rm -f $(FILE fromimage tmpname)
42 else
43 error="$(msg err 'Broken FILE support')"
44 fi ;;
45 *\ read\ *)
46 dd if=$(POST fromfd) of=$(POST toimage)
47 ;;
48 *\ build\ *)
49 cmd=""
50 toremove=""
51 while read key file ; do
52 [ "$(FILE $file size)" ] || continue
53 for i in $(seq 1 $(FILE $file count)); do
54 cmd="$cmd $key $(FILE $file tmpname $i)"
55 toremove="$toremove $(FILE $file tmpname $i)"
56 done
57 done <<EOT
58 bootloader kernel
59 --initrd initrd
60 --initrd initrd2
61 --info info
62 EOT
63 error="$(msg err 'Broken FILE support !')
64 <pre>$(httpinfo)</pre>"
65 if [ "$cmd" ]; then
66 for key in cmdline rdev video format mem ; do
67 [ "$(POST $key)" ] || continue
68 cmd="$cmd --$key '$(POST $key)'"
69 done
70 [ "$(POST edit)" ] || cmd="$cmd --dont-edit-cmdline"
71 TITLE="$(_ 'TazPanel - floppy')"
72 header
73 xhtml_header
74 cd $(POST workdir)
75 echo "<pre>"
76 eval $cmd 2>&1
77 echo "</pre>"
78 [ "$toremove" ] && rm -f $toremove && rmdir $(dirname $toremove)
79 xhtml_footer
80 exit 0
81 fi
82 ;;
83 esac
85 listfd()
86 {
87 echo "<select name=\"$1\">"
88 ls /dev/fd[0-9]* | sed 's|.*|<option>&</option>|'
89 echo "</select>"
90 }
92 TITLE="$(_ 'TazPanel - floppy')"
93 header
94 xhtml_header
95 echo "$error"
97 cat <<EOT
98 <form method="post" enctype="multipart/form-data">
99 EOT
100 [ -w /dev/fd0 ] && cat <<EOT
101 <section>
102 <header>
103 $(_ 'Floppy disk format')
104 </header>
105 <button type="submit" name="doformat" data-icon="start" >$(_ 'Format disk' )</button>
106 $(listfd fd) filesystem:
107 <select name "fstype">
108 <option>$(_ 'none')</option>
109 $(ls /sbin/mkfs.* | sed '/dev/d;s|.*/mkfs.\(.*\)|<option>\1</option>|')
110 </select>
111 </section>
113 <section>
114 <header>
115 $(_ 'Floppy disk transfert')
116 </header>
117 <table>
118 <tbody>
119 <tr>
120 <td>
121 <button type="submit" name="write" data-icon="start" >$(_ 'Write image' )</button>
122 $(listfd tofd) &lt;&lt;&lt; <input name="fromimage" type="file">
123 </td>
124 </tr>
125 <tr>
126 <td>
127 <button type="submit" name="read" data-icon="start" >$(_ 'Read image' )</button>
128 $(listfd fromfd) &gt;&gt;&gt; <input name="toimage" type="text" value="/tmp/floppy.img">
129 <td>
130 </tr>
131 </tbody>
132 </table>
133 </section>
134 EOT
135 cat <<EOT
136 <section>
137 <header>
138 $(_ 'Boot floppy set builder')
139 </header>
141 <table>
142 <tbody><tr>
143 <td>$(_ 'Linux kernel:')</td>
144 <td><input name="kernel" size="37" type="file"> <i>$(_ 'required')</i></td>
145 </tr>
146 <tr>
147 <td>$(_ 'Initramfs / Initrd:')</td>
148 <td><input name="initrd[]" size="37" type="file" multiple> <i>$(_ 'optional')</i></td>
149 </tr>
150 <tr>
151 <td>$(_ 'Extra initramfs:')</td>
152 <td><input name="initrd2[]" size="37" type="file" multiple> <i>$(_ 'optional')</i></td>
153 </tr>
154 <tr>
155 <td>$(_ 'Boot message:')</td>
156 <td><input name="info" size="37" type="file"> <i>$(_ 'optional')</i></td>
157 </tr>
158 <tr>
159 <td>$(_ 'Default cmdline:')</td>
160 <td id="cmdline"><input name="cmdline" size="36" type="text"> <input name="edit" checked="checked" type="checkbox">$(_ 'edit')
161 <i>$(_ 'optional')</i></td>
162 </tr>
163 <tr>
164 <td>$(_ 'Root device:')</td>
165 <td><input name="rdev" size="8" value="/dev/ram0" type="text">
166 &nbsp;&nbsp;$(_ 'Flags:') <select name="flags">
167 <option selected="selected" value="1">R/O</option>
168 <option value="0">R/W</option>
169 </select>
170 &nbsp;&nbsp;VESA: <select name="video">
171 <option value="-3">Ask</option>
172 <option value="-2">Extended</option>
173 <option value="-1" selected="selected">Standard</option>
174 <option value="0">0</option>
175 <option value="1">1</option>
176 <option value="2">2</option>
177 <option value="3">3</option>
178 <option value="4">4</option>
179 <option value="5">5</option>
180 <option value="6">6</option>
181 <option value="7">7</option>
182 <option value="8">8</option>
183 <option value="9">9</option>
184 <option value="10">10</option>
185 <option value="11">11</option>
186 <option value="12">12</option>
187 <option value="13">13</option>
188 <option value="14">14</option>
189 <option value="15">15</option>
190 <option value="3840">80x25</option>
191 <option value="3841">80x50</option>
192 <option value="3842">80x43</option>
193 <option value="3843">80x28</option>
194 <option value="3845">80x30</option>
195 <option value="3846">80x34</option>
196 <option value="3847">80x60</option>
197 <option value="778">132x43</option>
198 <option value="777">132x25</option>
199 <option value="824">320x200x8</option>
200 <option value="781">320x200x15</option>
201 <option value="782">320x200x16</option>
202 <option value="783">320x200x24</option>
203 <option value="800">320x200x32</option>
204 <option value="818">896x672x24</option>
205 <option value="915">320x240x15</option>
206 <option value="821">320x240x16</option>
207 <option value="917">320x240x24</option>
208 <option value="918">320x240x32</option>
209 <option value="819">896x672x32</option>
210 <option value="931">400x300x15</option>
211 <option value="822">400x300x16</option>
212 <option value="933">400x300x24</option>
213 <option value="934">400x300x32</option>
214 <option value="820">512x384x8</option>
215 <option value="947">512x384x15</option>
216 <option value="823">512x384x16</option>
217 <option value="949">512x384x24</option>
218 <option value="950">512x384x32</option>
219 <option value="962">640x350x8</option>
220 <option value="963">640x350x15</option>
221 <option value="964">640x350x16</option>
222 <option value="965">640x350x24</option>
223 <option value="966">640x350x32</option>
224 <option value="768">640x400x8</option>
225 <option value="899">640x400x15</option>
226 <option value="825">640x400x16</option>
227 <option value="901">640x400x24</option>
228 <option value="902">640x400x32</option>
229 <option value="769">640x480x8</option>
230 <option value="784">640x480x15</option>
231 <option value="785">640x480x16</option>
232 <option value="786">640x480x24</option>
233 <option value="826">640x480x32</option>
234 <option value="879">800x500x8</option>
235 <option value="880">800x500x15</option>
236 <option value="881">800x500x16</option>
237 <option value="882">800x500x24</option>
238 <option value="883">800x500x32</option>
239 <option value="771">800x600x8</option>
240 <option value="787">800x600x15</option>
241 <option value="788">800x600x16</option>
242 <option value="789">800x600x24</option>
243 <option value="827">800x600x32</option>
244 <option value="815">896x672x8</option>
245 <option value="816">1600x1200x8</option>
246 <option value="817">1600x1200x16</option>
247 <option value="874">1024x640x8</option>
248 <option value="875">1024x640x15</option>
249 <option value="876">1024x640x16</option>
250 <option value="877">1024x640x24</option>
251 <option value="878">1024x640x32</option>
252 <option value="773">1024x768x8</option>
253 <option value="790">1024x768x15</option>
254 <option value="791">1024x768x16</option>
255 <option value="792">1024x768x24</option>
256 <option value="828">1024x768x32</option>
257 <option value="869">1152x720x8</option>
258 <option value="870">1152x720x15</option>
259 <option value="871">1152x720x16</option>
260 <option value="872">1152x720x24</option>
261 <option value="873">1152x720x32</option>
262 <option value="775">1280x1024x8</option>
263 <option value="793">1280x1024x15</option>
264 <option value="794">1280x1024x16</option>
265 <option value="795">1280x1024x24</option>
266 <option value="829">1280x1024x32</option>
267 <option value="835">1400x1050x8</option>
268 <option value="837">1400x1050x16</option>
269 <option value="838">1400x1040x24</option>
270 <option value="864">1440x900x15</option>
271 <option value="866">1440x900x16</option>
272 <option value="867">1440x900x24</option>
273 <option value="868">1440x900x32</option>
274 <option value="893">1920x1200x8</option>
275 </select>
276 </td>
277 </tr>
278 <tr>
279 <td>$(_ 'Output directory:')</td>
280 <td id="workdir"><input name="workdir" size="36" type="text" value="/tmp"></td>
281 </tr>
282 <tr>
283 <td>$(_ 'Floppy size:')</td>
284 <td><select name="format">
285 <optgroup label="5&frac14; SD">
286 <option value="360">360 KB</option>
287 </optgroup>
288 <optgroup label="3&frac12; SD">
289 <option value="720">720 KB</option>
290 </optgroup>
291 <optgroup label="5&frac14; HD">
292 <option value="1200">1.20 MB</option>
293 </optgroup>
294 <optgroup label="3&frac12; HD">
295 <option value="1440" selected="selected">1.44 MB</option>
296 <option value="1600">1.60 MB</option>
297 <option value="1680">1.68 MB</option>
298 <option value="1722">1.72 MB</option>
299 <option value="1743">1.74 MB</option>
300 <option value="1760">1.76 MB</option>
301 <option value="1840">1.84 MB</option>
302 <option value="1920">1.92 MB</option>
303 <option value="1968">1.96 MB</option>
304 </optgroup>
305 <optgroup label="3&frac12; ED">
306 <option value="2880">2.88 MB</option>
307 <option value="3360">3.36 MB</option>
308 <option value="3444">3.44 MB</option>
309 <option value="3840">3.84 MB</option>
310 <option value="3936">3.92 MB</option>
311 </optgroup>
312 <option value="0">$(_ 'no limit')</option>
313 </select>&nbsp;
314 $(_ 'RAM used')&nbsp;<select name="mem">
315 <option selected="selected" value="16">16 MB</option>
316 <option value="15">15 MB</option>
317 <option value="14">14 MB</option>
318 <option value="13">13 MB</option>
319 <option value="12">12 MB</option>
320 <option value="11">11 MB</option>
321 <option value="10">10 MB</option>
322 <option value="9">9 MB</option>
323 <option value="8">8 MB</option>
324 <option value="7">7 MB</option>
325 <option value="6">6 MB</option>
326 <option value="5">5 MB</option>
327 <option value="4">4 MB</option>
328 </select>&nbsp;
329 <button type="submit" name="build" data-icon="start" >$(_ 'Build floppy set' )</button>
330 </td>
331 </tr>
332 </tbody></table>
333 <footer>
334 <p>
335 $(_ 'Note') 1: $(_ 'the extra initramfs may be useful to add your own configuration files.')
336 </p>
337 <p>
338 $(_ 'Note') 2: $(_ 'the keyboard is read for ESC or ENTER on every form feed (ASCII 12) in the boot message.')
339 </p>
340 </footer>
341 </section>
342 </form>
343 EOT
345 xhtml_footer
346 exit 0