tazlito annotate live.cgi @ rev 392
tazlito: mergefs(): try to process filenames with spaces
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Nov 16 02:45:04 2015 +0200 (2015-11-16) |
parents | 847a1a024cd0 |
children | d7aa98b45a0f |
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 |
pascal@382 | 24 #------ |
pascal@382 | 25 # menu |
pascal@382 | 26 #------ |
pascal@382 | 27 |
pascal@382 | 28 case "$1" in |
pascal@382 | 29 menu) |
pascal@382 | 30 TEXTDOMAIN_original=$TEXTDOMAIN |
pascal@382 | 31 export TEXTDOMAIN='tazlito' |
pascal@382 | 32 cat <<EOT |
pascal@382 | 33 <li><a data-icon="cd" href="live.cgi" data-root>$(gettext 'Live')</a> |
pascal@382 | 34 <menu> |
pascal@382 | 35 <li><a data-icon="" href="live.cgi?liveusb" data-root>$(gettext 'Create a live USB key')</a></li> |
pascal@382 | 36 <li><a data-icon="" href="live.cgi#liveiso" data-root>$(gettext 'Create a live CD-ROM')</a></li> |
pascal@382 | 37 <li><a data-icon="" href="live.cgi#hybrid" data-root>$(gettext 'Create a hybrid ISO')</a></li> |
pascal@382 | 38 <li><a data-icon="" href="live.cgi#loram" data-root>$(gettext 'Convert ISO to loram')</a></li> |
pascal@382 | 39 <li><a data-icon="" href="live.cgi#meta" data-root>$(gettext 'Build a meta ISO')</a></li> |
pascal@382 | 40 </menu> |
pascal@382 | 41 </li> |
pascal@382 | 42 EOT |
pascal@382 | 43 export TEXTDOMAIN=$TEXTDOMAIN_original |
pascal@382 | 44 exit |
pascal@382 | 45 esac |
pascal@382 | 46 |
pascal@382 | 47 |
pascal@320 | 48 TITLE=$(gettext 'TazPanel - Live') |
pascal@384 | 49 header |
pascal@320 | 50 |
pascal@320 | 51 # Build arguments to create a meta iso using 'tazlito merge' command |
pascal@320 | 52 merge_args() |
pascal@320 | 53 { |
pascal@320 | 54 tmp=$1 |
pascal@320 | 55 first=true |
pascal@320 | 56 i=1 |
pascal@320 | 57 while [ -n "$(GET input$i)" ]; do |
pascal@320 | 58 echo "$(stat -c "%s" $(GET input$i)) $(GET input$i) $(GET ram$i)" |
pascal@320 | 59 $((i++)) |
pascal@320 | 60 done | sort -nr | while read size file ram; do |
pascal@320 | 61 if $first; then |
pascal@320 | 62 cp $file $(GET metaoutput) |
pascal@320 | 63 echo -n "$ram $(GET metaoutput) " |
pascal@320 | 64 first=false |
pascal@320 | 65 continue |
pascal@320 | 66 fi |
pascal@320 | 67 dir=$tmp/$(basename $file) |
pascal@320 | 68 mkdir $dir |
pascal@320 | 69 mount -o loop,ro $file $dir |
pascal@320 | 70 echo -n "$ram $dir/boot/rootfs.gz " |
pascal@320 | 71 done |
pascal@320 | 72 } |
pascal@320 | 73 |
pascal@320 | 74 # |
pascal@320 | 75 # Commands executed in Xterm first |
pascal@320 | 76 # |
pascal@320 | 77 |
pascal@320 | 78 case " $(GET) " in |
pascal@320 | 79 *\ loramoutput\ *) |
pascal@320 | 80 $TERMINAL $TERM_OPTS \ |
pascal@320 | 81 -T "build loram iso" \ |
pascal@320 | 82 -e "tazlito build-loram $(GET input) $(GET loramoutput) $(GET type)" & ;; |
pascal@320 | 83 *\ meta\ *) |
pascal@320 | 84 tmp=/tmp/$(basename $0).$$ |
pascal@320 | 85 cleanup="sh $0 call merge_cleanup $(GET output) $tmp" |
pascal@320 | 86 $TERMINAL $TERM_OPTS \ |
pascal@320 | 87 -T "build meta iso" \ |
pascal@320 | 88 -e "tazlito merge $(merge_args $tmp); \ |
pascal@320 | 89 gettext 'ENTER to quit'; read i; \ |
pascal@320 | 90 $cleanup" & ;; |
pascal@320 | 91 *\ hybrid\ *) |
pascal@320 | 92 $TERMINAL $TERM_OPTS \ |
pascal@320 | 93 -T "build hybrid iso" \ |
pascal@320 | 94 -e "iso2exe $(GET input)" & ;; |
pascal@320 | 95 esac |
pascal@320 | 96 |
pascal@320 | 97 # |
pascal@320 | 98 # Commands |
pascal@320 | 99 # |
pascal@320 | 100 |
pascal@320 | 101 case " $(GET) " in |
pascal@320 | 102 *\ create\ *) |
pascal@320 | 103 # |
pascal@320 | 104 # Create a flavor file and ISO in options with all settings |
pascal@320 | 105 # Step by step interface and store files in cache. |
pascal@320 | 106 # |
pascal@320 | 107 gettext 'TODO' ;; |
pascal@320 | 108 *\ liveusb\ *) |
pascal@320 | 109 xhtml_header |
pascal@320 | 110 cat << EOT |
pascal@320 | 111 <div id="wrapper"> |
pascal@320 | 112 <h2>$(gettext 'SliTaz LiveUSB')</h2> |
pascal@320 | 113 <p>$(gettext 'Create Live USB SliTaz systems')<p> |
pascal@320 | 114 </div> |
pascal@320 | 115 |
pascal@320 | 116 <p>$(gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a LiveCD \ |
pascal@320 | 117 into the cdrom drive, select the correct device and press Generate.")</p> |
pascal@320 | 118 |
pascal@320 | 119 <form method="get" action="$SCRIPT_NAME"> |
pascal@320 | 120 <input type="hidden" name="liveusb" /> |
pascal@320 | 121 $(gettext 'USB Media to use:') |
pascal@320 | 122 <select name="gen"> |
pascal@320 | 123 EOT |
pascal@320 | 124 # List disk if there is a plugged USB device |
pascal@320 | 125 if [ -d /proc/scsi/usb-storage ]; then |
pascal@320 | 126 for i in `blkid | cut -d ":" -f 1`; do |
pascal@320 | 127 echo "<option value='$i'>$i</option>" |
pascal@320 | 128 done |
pascal@320 | 129 else |
pascal@320 | 130 echo "<option value="">$(gettext 'Not found')</option>" |
pascal@320 | 131 fi |
pascal@320 | 132 cat << EOT |
pascal@320 | 133 </select> |
pascal@320 | 134 <input type="submit" value="$(gettext 'Generate')" /> |
pascal@320 | 135 </form> |
pascal@320 | 136 EOT |
pascal@320 | 137 if [ "$(GET gen)" ]; then |
pascal@320 | 138 cat << EOT |
pascal@320 | 139 <h3>tazusb gen-liveusb $(GET gen)</h3> |
pascal@320 | 140 <pre> |
pascal@320 | 141 EOT |
pascal@320 | 142 # No pipe here so output is displayed in realtime |
pascal@320 | 143 yes | tazusb gen-liveusb $(GET gen) |
pascal@320 | 144 echo '</pre>' |
pascal@320 | 145 fi ;; |
psychomaniak@383 | 146 *\ write_iso\ *) |
psychomaniak@383 | 147 xhtml_header |
psychomaniak@383 | 148 |
psychomaniak@383 | 149 LaunchedByTazpanel="y" \ |
psychomaniak@383 | 150 tazlito writeiso $(GET write_iso) > /tmp/tazlitowriteiso 2>&1 & |
psychomaniak@383 | 151 |
psychomaniak@383 | 152 until [ -f /rootfs.gz ]; do |
psychomaniak@383 | 153 sleep 1 |
psychomaniak@383 | 154 done |
psychomaniak@383 | 155 cat << EOT |
psychomaniak@383 | 156 <fieldset> |
psychomaniak@383 | 157 $(head /tmp/tazlitowriteiso | sed "s|$|<p></p>|g" | sed '/.gvfs/d') |
psychomaniak@383 | 158 <li id="fssize"> </li> |
psychomaniak@383 | 159 EOT |
psychomaniak@383 | 160 until [ ! -f /rootfs.gz ]; do |
psychomaniak@383 | 161 sleep 1 |
psychomaniak@383 | 162 cat << EOT |
psychomaniak@383 | 163 <script type="text/javascript"> |
psychomaniak@383 | 164 document.getElementById('fssize').innerHTML = "<h4>$(boldify $(du -mh /rootfs.gz | cut -f1))</h4>"; |
psychomaniak@383 | 165 </script> |
psychomaniak@383 | 166 EOT |
psychomaniak@383 | 167 done |
psychomaniak@383 | 168 if [ -f /rootfs.gz ]; then |
psychomaniak@383 | 169 until [ ! -f /rootfs.gz ]; do |
psychomaniak@383 | 170 sleep 1 |
psychomaniak@383 | 171 done |
psychomaniak@383 | 172 fi |
psychomaniak@383 | 173 cat <<EOT |
psychomaniak@383 | 174 <script type="text/javascript"> |
psychomaniak@383 | 175 document.getElementById('fssize').innerHTML = "$(boldify $(du -mh /home/slitaz/distro/rootcd/boot/rootfs.gz | cut -f1))"; |
psychomaniak@383 | 176 </script> |
psychomaniak@383 | 177 /home/slitaz/distro/rootcd/boot/rootfs.gz |
psychomaniak@383 | 178 </fieldset> |
psychomaniak@383 | 179 EOT |
psychomaniak@388 | 180 ls -l /home/slitaz/distro/rootcd/boot/rootfs.gz |
psychomaniak@383 | 181 until [ -f /tmp/.write-iso* ]; do |
psychomaniak@383 | 182 sleep 1 |
psychomaniak@383 | 183 done |
psychomaniak@383 | 184 echo "<fieldset>" |
psychomaniak@383 | 185 if [ -f /tmp/.write-iso ]; then |
psychomaniak@383 | 186 newline |
psychomaniak@383 | 187 tail /tmp/tazlitowriteiso | grep ISO |
psychomaniak@383 | 188 while [ -f /tmp/.write-iso ]; do sleep 1 ; done |
psychomaniak@383 | 189 elif [ -f /tmp/.write-iso-error ]; then |
psychomaniak@383 | 190 tail -n8 /tmp/tazlitowriteiso | grep -vE 'ENTER|----' |
psychomaniak@383 | 191 fi |
psychomaniak@383 | 192 tail -n5 /tmp/tazlitowriteiso | sed "s|$|<p></p>|g" |
psychomaniak@388 | 193 ls -l /home/slitaz/distro |
psychomaniak@383 | 194 echo "</fieldset>" |
psychomaniak@383 | 195 echo "Use ' <code>tazlito emu-iso</code> ' to check it" ;; |
pascal@320 | 196 *) |
pascal@320 | 197 # |
pascal@320 | 198 # Default xHTML content |
pascal@320 | 199 # |
pascal@320 | 200 xhtml_header |
pascal@320 | 201 cat << EOT |
psychomaniak@383 | 202 <header id="liveiso"> <header> |
pascal@320 | 203 <div id="wrapper"> |
pascal@320 | 204 <h2>$(gettext 'SliTaz Live Systems')</h2> |
pascal@320 | 205 <p>$(gettext 'Create and manage Live CD or USB SliTaz systems')<p> |
pascal@320 | 206 </div> |
pascal@320 | 207 |
pascal@320 | 208 <div id="actions"> |
pascal@320 | 209 <a class="button" href="$SCRIPT_NAME?liveusb"> |
pascal@320 | 210 <img src="$IMAGES/harddisk.png" />$(gettext 'Create LiveUSB')</a> |
pascal@320 | 211 </div> |
pascal@320 | 212 |
psychomaniak@383 | 213 <fieldset > |
psychomaniak@383 | 214 <h3 id="loram">$(gettext 'Write a Live CD')</h3> |
pascal@320 | 215 |
psychomaniak@383 | 216 <!-- id="livecd" --> |
pascal@320 | 217 |
psychomaniak@383 | 218 <div> |
pascal@320 | 219 <p>$(gettext "The command writeiso will generate an ISO image of the current \ |
pascal@320 | 220 filesystem as is, including all files in the /home directory. It is an easy \ |
pascal@320 | 221 way to remaster a SliTaz Live system, you just have to: boot, modify, \ |
pascal@320 | 222 writeiso.")</p> |
pascal@320 | 223 |
pascal@320 | 224 <form method="get" action="$SCRIPT_NAME"> |
pascal@320 | 225 $(gettext 'Compression type:') |
pascal@320 | 226 <select name="write_iso"> |
psychomaniak@388 | 227 <!-- |
pascal@320 | 228 <option value="gzip">gzip</option> |
psychomaniak@388 | 229 --> |
pascal@320 | 230 <option value="lzma">lzma</option> |
pascal@320 | 231 <option value="none">$(gettext 'none')</option> |
pascal@320 | 232 </select> |
pascal@320 | 233 <input type="submit" value="$(gettext 'Write ISO')" /> |
psychomaniak@383 | 234 </form> |
psychomaniak@383 | 235 $([ ! -d /media/cdrom/boot/isolinux -a ! -f /boot/*slitaz* ] && \ |
psychomaniak@383 | 236 echo '<p> Cannot find Slitaz ISO/cd mounted in /media/cdrom (You will get only rootfs.gz)</p>') |
psychomaniak@383 | 237 </div> |
psychomaniak@383 | 238 </fieldset> |
pascal@320 | 239 |
psychomaniak@383 | 240 <p></p> |
psychomaniak@383 | 241 <fieldset> |
pascal@320 | 242 |
pascal@320 | 243 <h3>$(gettext 'Live CD tools')</h3> |
pascal@320 | 244 |
psychomaniak@383 | 245 <fieldset> |
psychomaniak@383 | 246 <h4>$(gettext 'Convert ISO to loram')</h4> |
psychomaniak@383 | 247 |
psychomaniak@383 | 248 <!-- id="loram" --> |
pascal@320 | 249 |
pascal@320 | 250 <p>$(gettext "This command will convert an ISO image of a SliTaz Live CD to a \ |
pascal@320 | 251 new ISO image requiring less RAM to run.")</p> |
pascal@320 | 252 |
pascal@320 | 253 <form method="get" action="$SCRIPT_NAME#loram"> |
pascal@320 | 254 <table> |
pascal@320 | 255 <tr> |
pascal@320 | 256 <td>$(gettext 'ISO to convert') |
pascal@320 | 257 <input type="text" accept=".iso" name="input" value="/root/" /></td> |
pascal@320 | 258 </tr> |
pascal@320 | 259 <tr> |
pascal@320 | 260 <td><input type="radio" name="type" value="ram" id="type1" checked /> |
pascal@320 | 261 <label for="type1">$(gettext 'The filesystem is always in RAM')</label> |
pascal@320 | 262 </td> |
pascal@320 | 263 </tr> |
pascal@320 | 264 <tr> |
pascal@320 | 265 <td><input type="radio" name="type" value="smallcdrom" id="type2" /> |
pascal@320 | 266 <label for="type2">$(gettext 'The filesystem may be on a small CDROM')</label> |
pascal@320 | 267 </td> |
pascal@320 | 268 </tr> |
pascal@320 | 269 <tr> |
pascal@320 | 270 <td><input type="radio" name="type" value="cdrom" id="type3" /> |
pascal@320 | 271 <label for="type3">$(gettext 'The filesystem may be on a large CDROM')</label> |
pascal@320 | 272 </td> |
pascal@320 | 273 </tr> |
pascal@320 | 274 <tr> |
pascal@320 | 275 <td>$(gettext 'ISO to create') |
pascal@320 | 276 <input type="text" accept=".iso" name="loramoutput" value="/root/loram.iso" /> |
pascal@320 | 277 </td> |
pascal@320 | 278 </tr> |
pascal@320 | 279 </table> |
pascal@320 | 280 <input type="submit" value="$(gettext 'Convert ISO to loram')" /> |
pascal@320 | 281 </form> |
psychomaniak@383 | 282 </fieldset> |
pascal@320 | 283 |
psychomaniak@383 | 284 <fieldset> |
pascal@320 | 285 <h4 id="hybrid">$(gettext 'Build a hybrid ISO')</h4> |
pascal@320 | 286 |
paul@339 | 287 <p>$(gettext "Add a master boot sector and an EXE header to the ISO image. \ |
pascal@320 | 288 ")</p> |
pascal@320 | 289 |
pascal@320 | 290 <form method="get" action="$SCRIPT_NAME#hybrid"> |
pascal@320 | 291 <table> |
pascal@320 | 292 <tr> |
pascal@320 | 293 <td> |
pascal@320 | 294 $(gettext 'ISO to convert') |
pascal@320 | 295 <input type="text" name="input" value="/root/" /> |
pascal@320 | 296 </td> |
pascal@320 | 297 </tr> |
pascal@320 | 298 </table> |
pascal@320 | 299 <input type="submit" name="hybrid" value="$(gettext 'Build a hybrid ISO')" /> |
pascal@320 | 300 </form> |
psychomaniak@383 | 301 </fieldset> |
pascal@320 | 302 |
psychomaniak@383 | 303 <fieldset> |
pascal@320 | 304 <h4 id="meta">$(gettext 'Build a meta ISO')</h4> |
pascal@320 | 305 |
pascal@320 | 306 <p>$(gettext "Combines several ISO flavors like nested Russian dolls. The \ |
pascal@320 | 307 amount of RAM available at startup will be used to select the utmost one.")</p> |
pascal@320 | 308 |
pascal@320 | 309 <form method="get" action="$SCRIPT_NAME#meta"> |
pascal@320 | 310 <table> |
pascal@320 | 311 EOT |
pascal@320 | 312 i="" |
pascal@320 | 313 while [ -n "$(GET addmeta)" ]; do |
pascal@320 | 314 [ -n "$(GET input$i)" ] || break |
pascal@320 | 315 j=$(($i + 1)) |
pascal@320 | 316 cat << EOT |
pascal@320 | 317 <tr> |
pascal@320 | 318 <td>$(gettext 'ISO number') $j: $(GET input$i) |
pascal@320 | 319 <input type="hidden" name="input$j" value="$(GET input$i)" /> |
pascal@320 | 320 </td> |
pascal@320 | 321 <td>$(gettext 'Minimum RAM'): $(GET ram$i) |
pascal@320 | 322 <input type="hidden" name="ram$j" value="$(GET ram$i)" /> |
pascal@320 | 323 </td> |
pascal@320 | 324 </tr> |
pascal@320 | 325 EOT |
pascal@320 | 326 i=$j |
pascal@320 | 327 done |
pascal@320 | 328 metaoutput="$(GET metaoutput)" |
pascal@320 | 329 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso" |
pascal@320 | 330 |
pascal@320 | 331 cat << EOT |
pascal@320 | 332 <tr> |
pascal@320 | 333 <td>$(gettext 'ISO to add') |
pascal@320 | 334 <input type="text" name="input" value="/root/" /> |
pascal@320 | 335 </td> |
pascal@320 | 336 <td>$(gettext 'Minimum RAM') |
pascal@320 | 337 <input type="text" name="ram" value="128M" /> |
pascal@320 | 338 <input type="submit" name="addmeta" value="$(gettext 'Add to the list')" /> |
pascal@320 | 339 </td> |
pascal@320 | 340 </tr> |
pascal@320 | 341 <tr> |
pascal@320 | 342 <td>$(gettext 'ISO to create') |
pascal@320 | 343 <input type="text" name="metaoutput" value="$metaoutput" /> |
pascal@320 | 344 </td> |
pascal@320 | 345 </tr> |
pascal@320 | 346 </table> |
pascal@320 | 347 <input type="submit" name="meta" value="$(gettext 'Build a meta ISO')" /> |
pascal@320 | 348 </form> |
psychomaniak@383 | 349 </fieldset> |
psychomaniak@383 | 350 </fieldset> |
pascal@320 | 351 |
pascal@320 | 352 EOT |
pascal@320 | 353 ;; |
pascal@320 | 354 esac |
pascal@320 | 355 |
pascal@320 | 356 xhtml_footer |
pascal@320 | 357 exit 0 |