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