tazpanel view floppy.cgi @ rev 588

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