tazpanel annotate live.cgi @ rev 290
live.cgi: small last minute fix
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon Apr 09 23:58:56 2012 +0200 (2012-04-09) |
parents | 42a96c3bc97e |
children | 72e9955ebdff |
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 |
pankso@25 | 25 TITLE="- 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); \ |
pascal@78 | 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 # |
pankso@29 | 83 gettext "TODO" ;; |
pankso@288 | 84 *\ liveusb\ *) |
pankso@24 | 85 xhtml_header |
pankso@24 | 86 cat << EOT |
pankso@24 | 87 <div id="wrapper"> |
pankso@288 | 88 <h2>$(gettext "SliTaz LiveUSB")</h2> |
pankso@288 | 89 <p>$(gettext "Create Live USB SliTaz systems")<p> |
pankso@24 | 90 </div> |
pankso@24 | 91 |
pankso@30 | 92 <p> |
pankso@288 | 93 $(gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a |
pankso@30 | 94 LiveCD into the cdrom drive, select the correct device and press |
pankso@288 | 95 Generate.") |
pankso@30 | 96 </p> |
pankso@30 | 97 <form method="get" action="$SCRIPT_NAME"> |
pankso@288 | 98 <input type="hidden" name="liveusb" /> |
pankso@288 | 99 $(gettext "USB Media to use:") |
pankso@288 | 100 <select name="gen"> |
pankso@30 | 101 EOT |
paul@205 | 102 # List disk if there is a plugged USB device |
pankso@30 | 103 if [ -d /proc/scsi/usb-storage ]; then |
pankso@30 | 104 for i in `blkid | cut -d ":" -f 1`; do |
pankso@30 | 105 echo "<option value='$i'>$i</option>" |
pankso@30 | 106 done |
pankso@30 | 107 else |
pankso@30 | 108 echo "<option value="">"`gettext "Not found"`"</option>" |
pankso@30 | 109 fi |
pankso@30 | 110 cat << EOT |
pankso@30 | 111 </select> |
paul@52 | 112 <input type="submit" value="`gettext "Generate"`" /> |
pankso@30 | 113 </form> |
pankso@288 | 114 EOT |
pankso@288 | 115 if [ "$(GET gen)" ]; then |
pankso@288 | 116 echo "<h3>tazusb gen-liveusb $(GET gen)</h3>" |
pankso@288 | 117 echo '<pre>' |
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"> |
pankso@288 | 129 <h2>`gettext "SliTaz Live Systems"`</h2> |
pankso@288 | 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"> |
pankso@288 | 135 <img src="$IMAGES/harddisk.png" />$(gettext "Create LiveUSB")</a> |
pankso@288 | 136 </div> |
pankso@30 | 137 |
pankso@290 | 138 <!--<a name="livecd"></a> |
pascal@77 | 139 <h3>`gettext "Write a Live CD"`</h3> |
pascal@77 | 140 <p> |
pascal@77 | 141 `gettext "The command writeiso will generate an ISO image of the |
pascal@77 | 142 current filesystem as is, including all files in the /home directory. |
pascal@77 | 143 It is an easy way to remaster a SliTaz Live system, you just have |
pascal@77 | 144 to: boot, modify, writeiso."` |
pascal@77 | 145 </p> |
pascal@77 | 146 <form method="get" action="$SCRIPT_NAME"> |
pascal@77 | 147 `gettext "Compression type:"` |
pascal@81 | 148 <select name="write_iso"> |
pascal@77 | 149 <option value="gzip">gzip</option> |
pascal@77 | 150 <option value="lzma">lzma</option> |
pascal@77 | 151 <option value="none">none</option> |
pascal@77 | 152 </select> |
pascal@77 | 153 <input type="submit" value="`gettext "Write ISO"`" /> |
pankso@290 | 154 </form> --> |
pascal@77 | 155 |
pascal@77 | 156 <h3>`gettext "Live CD tools"`</h3> |
pascal@77 | 157 <a name="loram"></a> |
pascal@77 | 158 <h4>`gettext "Convert ISO to loram"`</h4> |
pascal@77 | 159 <p> |
pascal@77 | 160 `gettext "This command will convert an ISO image of a SliTaz Live CD |
pascal@77 | 161 to a new ISO image requiring less RAM to run."` |
pascal@77 | 162 </p> |
pascal@77 | 163 <form method="get" action="$SCRIPT_NAME#loram"> |
pascal@77 | 164 <table> |
pascal@77 | 165 <tr> |
pascal@77 | 166 <td>`gettext "ISO to convert"` |
pascal@77 | 167 <input type="text" name="input" value="/root/" /></td> |
pascal@77 | 168 </tr> |
pascal@77 | 169 <tr> |
pascal@77 | 170 <td><input type="radio" name="type" value="ram" checked />`gettext "The filesystem is always in RAM"`.</td> |
pascal@77 | 171 </tr> |
pascal@77 | 172 <tr> |
pascal@77 | 173 <td><input type="radio" name="type" value="smallcdrom" />`gettext "The filesystem may be on a small CDROM"`.</td> |
pascal@77 | 174 </tr> |
pascal@77 | 175 <tr> |
pascal@77 | 176 <td><input type="radio" name="type" value="cdrom" />`gettext "The filesystem may be on a large CDROM"`.</td> |
pascal@77 | 177 </tr> |
pascal@77 | 178 <tr> |
pascal@77 | 179 <td>`gettext "ISO to create"` |
pascal@77 | 180 <input type="text" name="loramoutput" value="/root/loram.iso" /></td> |
pascal@77 | 181 </tr> |
pascal@77 | 182 </table> |
pascal@77 | 183 <input type="submit" value="`gettext "Convert ISO to loram"`" /> |
pascal@77 | 184 </form> |
pascal@77 | 185 |
pascal@78 | 186 <a name="meta"></a> |
paul@82 | 187 <h4>`gettext "Build a meta ISO"`</h4> |
pascal@78 | 188 <p> |
pascal@78 | 189 `gettext "Combines several ISO flavors like nested Russian dolls. |
pascal@78 | 190 The amount of RAM available at startup will be used to select the |
pascal@78 | 191 utmost one."` |
pascal@78 | 192 </p> |
pascal@78 | 193 <form method="get" action="$SCRIPT_NAME#meta"> |
pascal@78 | 194 <table> |
pascal@78 | 195 EOT |
pascal@78 | 196 i="" |
pascal@78 | 197 while [ -n "$(GET addmeta)" ]; do |
pascal@78 | 198 [ -n "$(GET input$i)" ] || break |
pascal@78 | 199 j=$(($i + 1)) |
pascal@78 | 200 cat << EOT |
pascal@78 | 201 <tr> |
pascal@78 | 202 <td>`gettext "ISO number"` $j: $(GET input$i) |
pascal@78 | 203 <input type="hidden" name="input$j" value="$(GET input$i)" /></td> |
paul@127 | 204 <td>`gettext "Minimum RAM"`: $(GET ram$i) |
pascal@78 | 205 <input type="hidden" name="ram$j" value="$(GET ram$i)" /></td> |
pascal@78 | 206 </tr> |
pascal@78 | 207 EOT |
pascal@78 | 208 i=$j |
pascal@78 | 209 done |
pascal@78 | 210 metaoutput="$(GET metaoutput)" |
pascal@78 | 211 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso" |
pascal@78 | 212 |
pascal@78 | 213 cat << EOT |
pascal@78 | 214 <tr> |
pascal@78 | 215 <td>`gettext "ISO to add"` |
pascal@78 | 216 <input type="text" name="input" value="/root/" /></td> |
paul@127 | 217 <td>`gettext "Minimum RAM"` |
pascal@78 | 218 <input type="text" name="ram" value="128M" /> |
pascal@78 | 219 <input type="submit" name="addmeta" value="`gettext "Add to the list"`" /></td> |
pascal@78 | 220 </tr> |
pascal@78 | 221 <tr> |
pascal@78 | 222 <td>`gettext "ISO to create"` |
pascal@78 | 223 <input type="text" name="metaoutput" value="$metaoutput" /></td> |
pascal@78 | 224 </tr> |
pascal@78 | 225 </table> |
pascal@78 | 226 <input type="submit" name="meta" value="`gettext "Build a meta ISO"`" /> |
pascal@78 | 227 </form> |
pascal@78 | 228 |
pankso@24 | 229 EOT |
pankso@24 | 230 ;; |
pankso@24 | 231 esac |
pankso@24 | 232 |
pankso@24 | 233 xhtml_footer |
pankso@24 | 234 exit 0 |