tazlito annotate live.cgi @ rev 350

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