tazpanel annotate live.cgi @ rev 325
check i18n: make {pot,msgfmt,clean}
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sun Jul 01 22:48:07 2012 +0000 (2012-07-01) |
parents | 72e9955ebdff |
children | 91ba0f11bea6 |
rev | line source |
---|---|
pankso@24 | 1 #!/bin/sh |
pankso@24 | 2 # |
pankso@24 | 3 # CGI interface for SliTaz Live systems using Tazlito and TazUSB. |
pankso@24 | 4 # |
pankso@112 | 5 # Copyright (C) 2011 SliTaz GNU/Linux - BSD License |
pankso@49 | 6 # |
pascal@77 | 7 |
pascal@78 | 8 if [ "$1" == "call" ]; then |
pascal@78 | 9 case "$2" in |
pascal@78 | 10 merge_cleanup) |
pascal@78 | 11 mv -f $3.merged $3 |
pascal@78 | 12 for i in $4/*; do |
pascal@78 | 13 umount -d $i |
pascal@78 | 14 done |
pascal@78 | 15 rm -rf $4 |
pascal@78 | 16 exit ;; |
pascal@78 | 17 esac |
pascal@78 | 18 fi |
pascal@77 | 19 |
pankso@24 | 20 # Common functions from libtazpanel |
pankso@24 | 21 . lib/libtazpanel |
pankso@24 | 22 get_config |
pascal@81 | 23 header |
pankso@24 | 24 |
al@292 | 25 TITLE=$(gettext 'TazPanel - Live') |
pankso@25 | 26 |
pascal@78 | 27 # Build arguments to create a meta iso using 'tazlito merge' command |
pascal@78 | 28 merge_args() |
pascal@78 | 29 { |
pascal@78 | 30 tmp=$1 |
pascal@78 | 31 first=true |
pascal@78 | 32 i=1 |
pascal@78 | 33 while [ -n "$(GET input$i)" ]; do |
pascal@78 | 34 echo "$(stat -c "%s" $(GET input$i)) $(GET input$i) $(GET ram$i)" |
pascal@78 | 35 $((i++)) |
pascal@78 | 36 done | sort -nr | while read size file ram; do |
pascal@78 | 37 if $first; then |
pascal@78 | 38 cp $file $(GET metaoutput) |
pascal@78 | 39 echo -n "$ram $(GET metaoutput) " |
pascal@78 | 40 first=false |
pascal@78 | 41 continue |
pascal@78 | 42 fi |
pascal@78 | 43 dir=$tmp/$(basename $file) |
pascal@78 | 44 mkdir $dir |
pascal@78 | 45 mount -o loop,ro $file $dir |
pascal@78 | 46 echo -n "$ram $dir/boot/rootfs.gz " |
pascal@78 | 47 done |
pascal@78 | 48 } |
pascal@78 | 49 |
pankso@24 | 50 # |
pankso@29 | 51 # Commands executed in Xterm first |
pankso@29 | 52 # |
pankso@29 | 53 |
pascal@77 | 54 case " $(GET) " in |
pascal@81 | 55 *\ write_iso\ *) |
pankso@49 | 56 $TERMINAL $TERM_OPTS \ |
pankso@30 | 57 -T "write-iso" \ |
pascal@81 | 58 -e "tazlito writeiso $(GET write_iso)" & ;; |
pascal@77 | 59 *\ loramoutput\ *) |
pascal@77 | 60 $TERMINAL $TERM_OPTS \ |
pascal@77 | 61 -T "build loram iso" \ |
pascal@77 | 62 -e "tazlito build-loram $(GET input) $(GET loramoutput) $(GET type)" & ;; |
pascal@78 | 63 *\ meta\ *) |
pascal@78 | 64 tmp=/tmp/$(basename $0).$$ |
pascal@78 | 65 cleanup="sh $0 call merge_cleanup $(GET output) $tmp" |
pascal@78 | 66 $TERMINAL $TERM_OPTS \ |
pascal@78 | 67 -T "build meta iso" \ |
pascal@78 | 68 -e "tazlito merge $(merge_args $tmp); \ |
al@303 | 69 gettext 'ENTER to quit'; read i; \ |
pascal@78 | 70 $cleanup" & ;; |
pankso@29 | 71 esac |
pankso@29 | 72 |
pankso@29 | 73 # |
pankso@24 | 74 # Commands |
pankso@24 | 75 # |
pankso@24 | 76 |
pascal@81 | 77 case " $(GET) " in |
pascal@81 | 78 *\ create\ *) |
pankso@29 | 79 # |
paul@52 | 80 # Create a flavor file and ISO in options with all settings |
pankso@49 | 81 # Step by step interface and store files in cache. |
pankso@29 | 82 # |
al@303 | 83 gettext 'TODO' ;; |
pankso@288 | 84 *\ liveusb\ *) |
pankso@24 | 85 xhtml_header |
pankso@24 | 86 cat << EOT |
pankso@24 | 87 <div id="wrapper"> |
al@303 | 88 <h2>$(gettext 'SliTaz LiveUSB')</h2> |
al@303 | 89 <p>$(gettext 'Create Live USB SliTaz systems')<p> |
pankso@24 | 90 </div> |
pankso@24 | 91 |
al@303 | 92 <p>$(gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a LiveCD \ |
al@303 | 93 into the cdrom drive, select the correct device and press Generate.")</p> |
al@303 | 94 |
pankso@30 | 95 <form method="get" action="$SCRIPT_NAME"> |
pankso@288 | 96 <input type="hidden" name="liveusb" /> |
al@303 | 97 $(gettext 'USB Media to use:') |
pankso@288 | 98 <select name="gen"> |
pankso@30 | 99 EOT |
paul@205 | 100 # List disk if there is a plugged USB device |
pankso@30 | 101 if [ -d /proc/scsi/usb-storage ]; then |
pankso@30 | 102 for i in `blkid | cut -d ":" -f 1`; do |
pankso@30 | 103 echo "<option value='$i'>$i</option>" |
pankso@30 | 104 done |
pankso@30 | 105 else |
al@303 | 106 echo "<option value="">$(gettext 'Not found')</option>" |
pankso@30 | 107 fi |
pankso@30 | 108 cat << EOT |
pankso@30 | 109 </select> |
al@303 | 110 <input type="submit" value="$(gettext 'Generate')" /> |
pankso@30 | 111 </form> |
pankso@288 | 112 EOT |
pankso@288 | 113 if [ "$(GET gen)" ]; then |
al@303 | 114 cat << EOT |
al@303 | 115 <h3>tazusb gen-liveusb $(GET gen)</h3> |
al@303 | 116 <pre> |
al@303 | 117 EOT |
pankso@288 | 118 # No pipe here so output is displayed in realtime |
pankso@290 | 119 yes | tazusb gen-liveusb $(GET gen) |
pankso@288 | 120 echo '</pre>' |
pankso@288 | 121 fi ;; |
pankso@288 | 122 *) |
pankso@288 | 123 # |
pankso@288 | 124 # Default xHTML content |
pankso@288 | 125 # |
pankso@288 | 126 xhtml_header |
pankso@288 | 127 cat << EOT |
pankso@288 | 128 <div id="wrapper"> |
al@303 | 129 <h2>$(gettext 'SliTaz Live Systems')</h2> |
al@303 | 130 <p>$(gettext 'Create and manage Live CD or USB SliTaz systems')<p> |
pankso@288 | 131 </div> |
pankso@288 | 132 |
pankso@288 | 133 <div id="actions"> |
pankso@288 | 134 <a class="button" href="$SCRIPT_NAME?liveusb"> |
al@303 | 135 <img src="$IMAGES/harddisk.png" />$(gettext 'Create LiveUSB')</a> |
pankso@288 | 136 </div> |
pankso@30 | 137 |
al@303 | 138 |
al@303 | 139 <!-- |
al@303 | 140 <h3 id="livecd">$(gettext 'Write a Live CD')</h3> |
al@303 | 141 |
al@303 | 142 <p>$(gettext "The command writeiso will generate an ISO image of the current \ |
al@303 | 143 filesystem as is, including all files in the /home directory. It is an easy \ |
al@303 | 144 way to remaster a SliTaz Live system, you just have to: boot, modify, \ |
al@303 | 145 writeiso.")</p> |
al@303 | 146 |
pascal@77 | 147 <form method="get" action="$SCRIPT_NAME"> |
al@303 | 148 $(gettext 'Compression type:') |
pascal@81 | 149 <select name="write_iso"> |
pascal@77 | 150 <option value="gzip">gzip</option> |
pascal@77 | 151 <option value="lzma">lzma</option> |
al@303 | 152 <option value="none">$(gettext 'none')</option> |
pascal@77 | 153 </select> |
al@303 | 154 <input type="submit" value="$(gettext 'Write ISO')" /> |
pankso@290 | 155 </form> --> |
pascal@77 | 156 |
al@303 | 157 |
al@303 | 158 <h3>$(gettext 'Live CD tools')</h3> |
al@303 | 159 |
al@303 | 160 <h4 id="loram">$(gettext 'Convert ISO to loram')</h4> |
al@303 | 161 |
al@303 | 162 <p>$(gettext "This command will convert an ISO image of a SliTaz Live CD to a \ |
al@303 | 163 new ISO image requiring less RAM to run.")</p> |
al@303 | 164 |
pascal@77 | 165 <form method="get" action="$SCRIPT_NAME#loram"> |
pascal@77 | 166 <table> |
al@303 | 167 <tr> |
al@303 | 168 <td>$(gettext 'ISO to convert') |
al@303 | 169 <input type="text" accept=".iso" name="input" value="/root/" /></td> |
al@303 | 170 </tr> |
al@303 | 171 <tr> |
al@303 | 172 <td><input type="radio" name="type" value="ram" id="type1" checked /> |
al@303 | 173 <label for="type1">$(gettext 'The filesystem is always in RAM')</label> |
al@303 | 174 </td> |
al@303 | 175 </tr> |
al@303 | 176 <tr> |
al@303 | 177 <td><input type="radio" name="type" value="smallcdrom" id="type2" /> |
al@303 | 178 <label for="type2">$(gettext 'The filesystem may be on a small CDROM')</label> |
al@303 | 179 </td> |
al@303 | 180 </tr> |
al@303 | 181 <tr> |
al@303 | 182 <td><input type="radio" name="type" value="cdrom" id="type3" /> |
al@303 | 183 <label for="type3">$(gettext 'The filesystem may be on a large CDROM')</label> |
al@303 | 184 </td> |
al@303 | 185 </tr> |
al@303 | 186 <tr> |
al@303 | 187 <td>$(gettext 'ISO to create') |
al@303 | 188 <input type="text" accept=".iso" name="loramoutput" value="/root/loram.iso" /> |
al@303 | 189 </td> |
al@303 | 190 </tr> |
pascal@77 | 191 </table> |
al@303 | 192 <input type="submit" value="$(gettext 'Convert ISO to loram')" /> |
pascal@77 | 193 </form> |
pascal@77 | 194 |
al@303 | 195 |
al@303 | 196 <h4 id="meta">$(gettext 'Build a meta ISO')</h4> |
al@303 | 197 |
al@303 | 198 <p>$(gettext "Combines several ISO flavors like nested Russian dolls. The \ |
al@303 | 199 amount of RAM available at startup will be used to select the utmost one.")</p> |
al@303 | 200 |
pascal@78 | 201 <form method="get" action="$SCRIPT_NAME#meta"> |
pascal@78 | 202 <table> |
pascal@78 | 203 EOT |
pascal@78 | 204 i="" |
pascal@78 | 205 while [ -n "$(GET addmeta)" ]; do |
pascal@78 | 206 [ -n "$(GET input$i)" ] || break |
pascal@78 | 207 j=$(($i + 1)) |
pascal@78 | 208 cat << EOT |
al@303 | 209 <tr> |
al@303 | 210 <td>$(gettext 'ISO number') $j: $(GET input$i) |
al@303 | 211 <input type="hidden" name="input$j" value="$(GET input$i)" /> |
al@303 | 212 </td> |
al@303 | 213 <td>$(gettext 'Minimum RAM'): $(GET ram$i) |
al@303 | 214 <input type="hidden" name="ram$j" value="$(GET ram$i)" /> |
al@303 | 215 </td> |
al@303 | 216 </tr> |
pascal@78 | 217 EOT |
pascal@78 | 218 i=$j |
pascal@78 | 219 done |
pascal@78 | 220 metaoutput="$(GET metaoutput)" |
pascal@78 | 221 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso" |
al@292 | 222 |
pascal@78 | 223 cat << EOT |
al@303 | 224 <tr> |
al@303 | 225 <td>$(gettext 'ISO to add') |
al@303 | 226 <input type="text" name="input" value="/root/" /> |
al@303 | 227 </td> |
al@303 | 228 <td>$(gettext 'Minimum RAM') |
al@303 | 229 <input type="text" name="ram" value="128M" /> |
al@303 | 230 <input type="submit" name="addmeta" value="$(gettext 'Add to the list')" /> |
al@303 | 231 </td> |
al@303 | 232 </tr> |
al@303 | 233 <tr> |
al@303 | 234 <td>$(gettext 'ISO to create') |
al@303 | 235 <input type="text" name="metaoutput" value="$metaoutput" /> |
al@303 | 236 </td> |
al@303 | 237 </tr> |
pascal@78 | 238 </table> |
al@303 | 239 <input type="submit" name="meta" value="$(gettext 'Build a meta ISO')" /> |
pascal@78 | 240 </form> |
pascal@78 | 241 |
pankso@24 | 242 EOT |
pankso@24 | 243 ;; |
pankso@24 | 244 esac |
pankso@24 | 245 |
pankso@24 | 246 xhtml_footer |
pankso@24 | 247 exit 0 |