tazpanel annotate live.cgi @ rev 81
Use httpd_helper parser (GET)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Apr 13 16:41:02 2011 +0200 (2011-04-13) |
parents | 73c42017a5a2 |
children | a797e9424727 |
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@49 | 5 # Copyright (C) 2011 SliTaz GNU/Linux - GNU gpl v3 |
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@24 | 25 # Include gettext helper script. |
pankso@24 | 26 . /usr/bin/gettext.sh |
pankso@24 | 27 |
pankso@24 | 28 # Export package name for gettext. |
pankso@39 | 29 TEXTDOMAIN='tazpanel' |
pankso@24 | 30 export TEXTDOMAIN |
pankso@24 | 31 |
pankso@25 | 32 TITLE="- Live" |
pankso@25 | 33 |
pascal@78 | 34 # Build arguments to create a meta iso using 'tazlito merge' command |
pascal@78 | 35 merge_args() |
pascal@78 | 36 { |
pascal@78 | 37 tmp=$1 |
pascal@78 | 38 first=true |
pascal@78 | 39 i=1 |
pascal@78 | 40 while [ -n "$(GET input$i)" ]; do |
pascal@78 | 41 echo "$(stat -c "%s" $(GET input$i)) $(GET input$i) $(GET ram$i)" |
pascal@78 | 42 $((i++)) |
pascal@78 | 43 done | sort -nr | while read size file ram; do |
pascal@78 | 44 if $first; then |
pascal@78 | 45 cp $file $(GET metaoutput) |
pascal@78 | 46 echo -n "$ram $(GET metaoutput) " |
pascal@78 | 47 first=false |
pascal@78 | 48 continue |
pascal@78 | 49 fi |
pascal@78 | 50 dir=$tmp/$(basename $file) |
pascal@78 | 51 mkdir $dir |
pascal@78 | 52 mount -o loop,ro $file $dir |
pascal@78 | 53 echo -n "$ram $dir/boot/rootfs.gz " |
pascal@78 | 54 done |
pascal@78 | 55 } |
pascal@78 | 56 |
pankso@24 | 57 # |
pankso@29 | 58 # Commands executed in Xterm first |
pankso@29 | 59 # |
pankso@29 | 60 |
pascal@77 | 61 case " $(GET) " in |
pascal@81 | 62 *\ write_iso\ *) |
pankso@49 | 63 $TERMINAL $TERM_OPTS \ |
pankso@30 | 64 -T "write-iso" \ |
pascal@81 | 65 -e "tazlito writeiso $(GET write_iso)" & ;; |
pascal@81 | 66 *\ gen_liveusb\ *) |
pankso@49 | 67 $TERMINAL $TERM_OPTS \ |
pankso@30 | 68 -T "Tazusb gen-liveusb" \ |
pascal@81 | 69 -e "tazusb gen-liveusb $(GET gen_liveusb); \ |
pankso@30 | 70 gettext \"ENTER to quit\"; read i" & ;; |
pascal@77 | 71 *\ loramoutput\ *) |
pascal@77 | 72 $TERMINAL $TERM_OPTS \ |
pascal@77 | 73 -T "build loram iso" \ |
pascal@77 | 74 -e "tazlito build-loram $(GET input) $(GET loramoutput) $(GET type)" & ;; |
pascal@78 | 75 *\ meta\ *) |
pascal@78 | 76 tmp=/tmp/$(basename $0).$$ |
pascal@78 | 77 cleanup="sh $0 call merge_cleanup $(GET output) $tmp" |
pascal@78 | 78 $TERMINAL $TERM_OPTS \ |
pascal@78 | 79 -T "build meta iso" \ |
pascal@78 | 80 -e "tazlito merge $(merge_args $tmp); \ |
pascal@78 | 81 gettext \"ENTER to quit\"; read i; \ |
pascal@78 | 82 $cleanup" & ;; |
pankso@29 | 83 esac |
pankso@29 | 84 |
pankso@29 | 85 # |
pankso@24 | 86 # Commands |
pankso@24 | 87 # |
pankso@24 | 88 |
pascal@81 | 89 case " $(GET) " in |
pascal@81 | 90 *\ create\ *) |
pankso@29 | 91 # |
paul@52 | 92 # Create a flavor file and ISO in options with all settings |
pankso@49 | 93 # Step by step interface and store files in cache. |
pankso@29 | 94 # |
pankso@29 | 95 gettext "TODO" ;; |
pankso@24 | 96 *) |
pankso@24 | 97 # |
pankso@24 | 98 # Default xHTML content |
pankso@24 | 99 # |
pankso@24 | 100 xhtml_header |
pankso@24 | 101 cat << EOT |
pankso@24 | 102 <div id="wrapper"> |
pankso@25 | 103 <h2>`gettext "SliTaz Live Systems"`</h2> |
pankso@24 | 104 <p>`gettext "Create and manage Live CD or USB SliTaz systems"`<p> |
pankso@24 | 105 </div> |
pankso@24 | 106 |
pascal@77 | 107 <a name="liveusb"></a> |
pankso@30 | 108 <h3>`gettext "Live USB"`</h3> |
pankso@30 | 109 <p> |
pankso@30 | 110 `gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a |
pankso@30 | 111 LiveCD into the cdrom drive, select the correct device and press |
pankso@30 | 112 Generate."` |
pankso@30 | 113 </p> |
pankso@30 | 114 <form method="get" action="$SCRIPT_NAME"> |
pankso@30 | 115 `gettext "USB Media to use:"` |
pascal@81 | 116 <select name="gen_liveusb"> |
pankso@30 | 117 EOT |
pankso@30 | 118 # List disk if plugged USB device |
pankso@30 | 119 if [ -d /proc/scsi/usb-storage ]; then |
pankso@30 | 120 for i in `blkid | cut -d ":" -f 1`; do |
pankso@30 | 121 echo "<option value='$i'>$i</option>" |
pankso@30 | 122 done |
pankso@30 | 123 else |
pankso@30 | 124 echo "<option value="">"`gettext "Not found"`"</option>" |
pankso@30 | 125 fi |
pankso@30 | 126 cat << EOT |
pankso@30 | 127 </select> |
paul@52 | 128 <input type="submit" value="`gettext "Generate"`" /> |
pankso@30 | 129 </form> |
pankso@30 | 130 |
pascal@77 | 131 <a name="livecd"></a> |
pascal@77 | 132 <h3>`gettext "Write a Live CD"`</h3> |
pascal@77 | 133 <p> |
pascal@77 | 134 `gettext "The command writeiso will generate an ISO image of the |
pascal@77 | 135 current filesystem as is, including all files in the /home directory. |
pascal@77 | 136 It is an easy way to remaster a SliTaz Live system, you just have |
pascal@77 | 137 to: boot, modify, writeiso."` |
pascal@77 | 138 </p> |
pascal@77 | 139 <form method="get" action="$SCRIPT_NAME"> |
pascal@77 | 140 `gettext "Compression type:"` |
pascal@81 | 141 <select name="write_iso"> |
pascal@77 | 142 <option value="gzip">gzip</option> |
pascal@77 | 143 <option value="lzma">lzma</option> |
pascal@77 | 144 <option value="none">none</option> |
pascal@77 | 145 </select> |
pascal@77 | 146 <input type="submit" value="`gettext "Write ISO"`" /> |
pascal@77 | 147 </form> |
pascal@77 | 148 |
pascal@77 | 149 <h3>`gettext "Live CD tools"`</h3> |
pascal@77 | 150 <a name="loram"></a> |
pascal@77 | 151 <h4>`gettext "Convert ISO to loram"`</h4> |
pascal@77 | 152 <p> |
pascal@77 | 153 `gettext "This command will convert an ISO image of a SliTaz Live CD |
pascal@77 | 154 to a new ISO image requiring less RAM to run."` |
pascal@77 | 155 </p> |
pascal@77 | 156 <form method="get" action="$SCRIPT_NAME#loram"> |
pascal@77 | 157 <table> |
pascal@77 | 158 <tr> |
pascal@77 | 159 <td>`gettext "ISO to convert"` |
pascal@77 | 160 <input type="text" name="input" value="/root/" /></td> |
pascal@77 | 161 </tr> |
pascal@77 | 162 <tr> |
pascal@77 | 163 <td><input type="radio" name="type" value="ram" checked />`gettext "The filesystem is always in RAM"`.</td> |
pascal@77 | 164 </tr> |
pascal@77 | 165 <tr> |
pascal@77 | 166 <td><input type="radio" name="type" value="smallcdrom" />`gettext "The filesystem may be on a small CDROM"`.</td> |
pascal@77 | 167 </tr> |
pascal@77 | 168 <tr> |
pascal@77 | 169 <td><input type="radio" name="type" value="cdrom" />`gettext "The filesystem may be on a large CDROM"`.</td> |
pascal@77 | 170 </tr> |
pascal@77 | 171 <tr> |
pascal@77 | 172 <td>`gettext "ISO to create"` |
pascal@77 | 173 <input type="text" name="loramoutput" value="/root/loram.iso" /></td> |
pascal@77 | 174 </tr> |
pascal@77 | 175 </table> |
pascal@77 | 176 <input type="submit" value="`gettext "Convert ISO to loram"`" /> |
pascal@77 | 177 </form> |
pascal@77 | 178 |
pascal@78 | 179 <a name="meta"></a> |
pascal@78 | 180 <h4>`gettext "Buld a meta ISO"`</h4> |
pascal@78 | 181 <p> |
pascal@78 | 182 `gettext "Combines several ISO flavors like nested Russian dolls. |
pascal@78 | 183 The amount of RAM available at startup will be used to select the |
pascal@78 | 184 utmost one."` |
pascal@78 | 185 </p> |
pascal@78 | 186 <form method="get" action="$SCRIPT_NAME#meta"> |
pascal@78 | 187 <table> |
pascal@78 | 188 EOT |
pascal@78 | 189 i="" |
pascal@78 | 190 while [ -n "$(GET addmeta)" ]; do |
pascal@78 | 191 [ -n "$(GET input$i)" ] || break |
pascal@78 | 192 j=$(($i + 1)) |
pascal@78 | 193 cat << EOT |
pascal@78 | 194 <tr> |
pascal@78 | 195 <td>`gettext "ISO number"` $j: $(GET input$i) |
pascal@78 | 196 <input type="hidden" name="input$j" value="$(GET input$i)" /></td> |
pascal@78 | 197 <td>`gettext "minimum RAM"`: $(GET ram$i) |
pascal@78 | 198 <input type="hidden" name="ram$j" value="$(GET ram$i)" /></td> |
pascal@78 | 199 </tr> |
pascal@78 | 200 EOT |
pascal@78 | 201 i=$j |
pascal@78 | 202 done |
pascal@78 | 203 metaoutput="$(GET metaoutput)" |
pascal@78 | 204 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso" |
pascal@78 | 205 |
pascal@78 | 206 cat << EOT |
pascal@78 | 207 <tr> |
pascal@78 | 208 <td>`gettext "ISO to add"` |
pascal@78 | 209 <input type="text" name="input" value="/root/" /></td> |
pascal@78 | 210 <td>`gettext "minimum RAM"` |
pascal@78 | 211 <input type="text" name="ram" value="128M" /> |
pascal@78 | 212 <input type="submit" name="addmeta" value="`gettext "Add to the list"`" /></td> |
pascal@78 | 213 </tr> |
pascal@78 | 214 <tr> |
pascal@78 | 215 <td>`gettext "ISO to create"` |
pascal@78 | 216 <input type="text" name="metaoutput" value="$metaoutput" /></td> |
pascal@78 | 217 </tr> |
pascal@78 | 218 </table> |
pascal@78 | 219 <input type="submit" name="meta" value="`gettext "Build a meta ISO"`" /> |
pascal@78 | 220 </form> |
pascal@78 | 221 |
pankso@24 | 222 EOT |
pankso@24 | 223 ;; |
pankso@24 | 224 esac |
pankso@24 | 225 |
pankso@24 | 226 xhtml_footer |
pankso@24 | 227 exit 0 |