tazlito diff live.cgi @ rev 326

typo with find
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jan 05 22:48:24 2014 +0100 (2014-01-05)
parents
children 980becc97bff
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/live.cgi	Sun Jan 05 22:48:24 2014 +0100
     1.3 @@ -0,0 +1,268 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# CGI interface for SliTaz Live systems using Tazlito and TazUSB.
     1.7 +#
     1.8 +# Copyright (C) 2011 SliTaz GNU/Linux - BSD License
     1.9 +#
    1.10 +
    1.11 +if [ "$1" == "call" ]; then
    1.12 +	case "$2" in
    1.13 +	merge_cleanup)
    1.14 +		mv -f $3.merged $3
    1.15 +		for i in $4/*; do
    1.16 +			umount -d $i
    1.17 +		done
    1.18 +		rm -rf $4
    1.19 +		exit ;;
    1.20 +	esac
    1.21 +fi
    1.22 +
    1.23 +# Common functions from libtazpanel
    1.24 +. lib/libtazpanel
    1.25 +get_config
    1.26 +header
    1.27 +
    1.28 +TITLE=$(gettext 'TazPanel - Live')
    1.29 +
    1.30 +# Build arguments to create a meta iso using 'tazlito merge' command
    1.31 +merge_args()
    1.32 +{
    1.33 +	tmp=$1
    1.34 +	first=true
    1.35 +	i=1
    1.36 +	while [ -n "$(GET input$i)" ]; do
    1.37 +		echo "$(stat -c "%s" $(GET input$i)) $(GET input$i) $(GET ram$i)"
    1.38 +		$((i++))
    1.39 +	done | sort -nr | while read size file ram; do
    1.40 +		if $first; then
    1.41 +			cp $file $(GET metaoutput)
    1.42 +			echo -n "$ram $(GET metaoutput) "
    1.43 +			first=false
    1.44 +			continue
    1.45 +		fi
    1.46 +		dir=$tmp/$(basename $file)
    1.47 +		mkdir $dir
    1.48 +		mount -o loop,ro $file $dir
    1.49 +		echo -n "$ram $dir/boot/rootfs.gz "
    1.50 +	done
    1.51 +}
    1.52 +
    1.53 +#
    1.54 +# Commands executed in Xterm first
    1.55 +#
    1.56 +
    1.57 +case " $(GET) " in
    1.58 +	*\ write_iso\ *)
    1.59 +		$TERMINAL $TERM_OPTS \
    1.60 +			-T "write-iso" \
    1.61 +			-e "tazlito writeiso $(GET write_iso)" & ;;
    1.62 +	*\ loramoutput\ *)
    1.63 +		$TERMINAL $TERM_OPTS \
    1.64 +			-T "build loram iso" \
    1.65 +			-e "tazlito build-loram $(GET input) $(GET loramoutput) $(GET type)" & ;;
    1.66 +	*\ meta\ *)
    1.67 +		tmp=/tmp/$(basename $0).$$
    1.68 +		cleanup="sh $0 call merge_cleanup $(GET output) $tmp"
    1.69 +		$TERMINAL $TERM_OPTS \
    1.70 +			-T "build meta iso" \
    1.71 +			-e "tazlito merge $(merge_args $tmp); \
    1.72 +				gettext 'ENTER to quit'; read i; \
    1.73 +				$cleanup" & ;;
    1.74 +	*\ hybrid\ *)
    1.75 +		$TERMINAL $TERM_OPTS \
    1.76 +			-T "build hybrid iso" \
    1.77 +			-e "iso2exe $(GET input)" & ;;
    1.78 +esac
    1.79 +
    1.80 +#
    1.81 +# Commands
    1.82 +#
    1.83 +
    1.84 +case " $(GET) " in
    1.85 +	*\ create\ *)
    1.86 +		#
    1.87 +		# Create a flavor file and ISO in options with all settings
    1.88 +		# Step by step interface and store files in cache.
    1.89 +		#
    1.90 +		gettext 'TODO' ;;
    1.91 +	*\ liveusb\ *)
    1.92 +		xhtml_header
    1.93 +		cat << EOT
    1.94 +<div id="wrapper">
    1.95 +	<h2>$(gettext 'SliTaz LiveUSB')</h2>
    1.96 +	<p>$(gettext 'Create Live USB SliTaz systems')<p>
    1.97 +</div>
    1.98 +
    1.99 +<p>$(gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a LiveCD \
   1.100 +into the cdrom drive, select the correct device and press Generate.")</p>
   1.101 +
   1.102 +<form method="get" action="$SCRIPT_NAME">
   1.103 +	<input type="hidden" name="liveusb" />
   1.104 +	$(gettext 'USB Media to use:')
   1.105 +	<select name="gen">
   1.106 +EOT
   1.107 +		# List disk if there is a plugged USB device
   1.108 +		if [ -d /proc/scsi/usb-storage ]; then
   1.109 +			for i in `blkid | cut -d ":" -f 1`; do
   1.110 +				echo "<option value='$i'>$i</option>"
   1.111 +			done
   1.112 +		else
   1.113 +			echo "<option value="">$(gettext 'Not found')</option>"
   1.114 +		fi
   1.115 +		cat << EOT
   1.116 +	</select>
   1.117 +	<input type="submit" value="$(gettext 'Generate')" />
   1.118 +</form>
   1.119 +EOT
   1.120 +		if [ "$(GET gen)" ]; then
   1.121 +			cat << EOT
   1.122 +<h3>tazusb gen-liveusb $(GET gen)</h3>
   1.123 +<pre>
   1.124 +EOT
   1.125 +			# No pipe here so output is displayed in realtime
   1.126 +			yes | tazusb gen-liveusb $(GET gen)
   1.127 +			echo '</pre>'
   1.128 +		fi ;;
   1.129 +	*)
   1.130 +		#
   1.131 +		# Default xHTML content
   1.132 +		#
   1.133 +		xhtml_header
   1.134 +		cat << EOT
   1.135 +<div id="wrapper">
   1.136 +	<h2>$(gettext 'SliTaz Live Systems')</h2>
   1.137 +	<p>$(gettext 'Create and manage Live CD or USB SliTaz systems')<p>
   1.138 +</div>
   1.139 +
   1.140 +<div id="actions">
   1.141 +	<a class="button" href="$SCRIPT_NAME?liveusb">
   1.142 +		<img src="$IMAGES/harddisk.png" />$(gettext 'Create LiveUSB')</a>
   1.143 +</div>
   1.144 +
   1.145 +
   1.146 +<!--
   1.147 +<h3 id="livecd">$(gettext 'Write a Live CD')</h3>
   1.148 +
   1.149 +<p>$(gettext "The command writeiso will generate an ISO image of the current \
   1.150 +filesystem as is, including all files in the /home directory. It is an easy \
   1.151 +way to remaster a SliTaz Live system, you just have to: boot, modify, \
   1.152 +writeiso.")</p>
   1.153 +
   1.154 +<form method="get" action="$SCRIPT_NAME">
   1.155 +	$(gettext 'Compression type:')
   1.156 +	<select name="write_iso">
   1.157 +		<option value="gzip">gzip</option>
   1.158 +		<option value="lzma">lzma</option>
   1.159 +		<option value="none">$(gettext 'none')</option>
   1.160 +	</select>
   1.161 +	<input type="submit" value="$(gettext 'Write ISO')" />
   1.162 +</form> -->
   1.163 +
   1.164 +
   1.165 +<h3>$(gettext 'Live CD tools')</h3>
   1.166 +
   1.167 +<h4 id="loram">$(gettext 'Convert ISO to loram')</h4>
   1.168 +
   1.169 +<p>$(gettext "This command will convert an ISO image of a SliTaz Live CD to a \
   1.170 +new ISO image requiring less RAM to run.")</p>
   1.171 +
   1.172 +<form method="get" action="$SCRIPT_NAME#loram">
   1.173 +	<table>
   1.174 +		<tr>
   1.175 +			<td>$(gettext 'ISO to convert')
   1.176 +				<input type="text" accept=".iso" name="input" value="/root/" /></td>
   1.177 +		</tr>
   1.178 +		<tr>
   1.179 +			<td><input type="radio" name="type" value="ram" id="type1" checked />
   1.180 +				<label for="type1">$(gettext 'The filesystem is always in RAM')</label>
   1.181 +			</td>
   1.182 +		</tr>
   1.183 +		<tr>
   1.184 +			<td><input type="radio" name="type" value="smallcdrom" id="type2" />
   1.185 +				<label for="type2">$(gettext 'The filesystem may be on a small CDROM')</label>
   1.186 +			</td>
   1.187 +		</tr>
   1.188 +		<tr>
   1.189 +			<td><input type="radio" name="type" value="cdrom" id="type3" />
   1.190 +				<label for="type3">$(gettext 'The filesystem may be on a large CDROM')</label>
   1.191 +			</td>
   1.192 +		</tr>
   1.193 +		<tr>
   1.194 +			<td>$(gettext 'ISO to create')
   1.195 +				<input type="text" accept=".iso" name="loramoutput" value="/root/loram.iso" />
   1.196 +			</td>
   1.197 +		</tr>
   1.198 +	</table>
   1.199 +	<input type="submit" value="$(gettext 'Convert ISO to loram')" />
   1.200 +</form>
   1.201 +
   1.202 +
   1.203 +<h4 id="hybrid">$(gettext 'Build a hybrid ISO')</h4>
   1.204 +
   1.205 +<p>$(gettext "Add a master boot sector and a EXE header to the ISO image. \
   1.206 +")</p>
   1.207 +
   1.208 +<form method="get" action="$SCRIPT_NAME#hybrid">
   1.209 +	<table>
   1.210 +	<tr>
   1.211 +	<td>
   1.212 +	$(gettext 'ISO to convert')
   1.213 +	<input type="text" name="input" value="/root/" />
   1.214 +	</td>
   1.215 +	</tr>
   1.216 +	</table>
   1.217 +	<input type="submit" name="hybrid" value="$(gettext 'Build a hybrid ISO')" />
   1.218 +</form>
   1.219 +
   1.220 +<h4 id="meta">$(gettext 'Build a meta ISO')</h4>
   1.221 +
   1.222 +<p>$(gettext "Combines several ISO flavors like nested Russian dolls. The \
   1.223 +amount of RAM available at startup will be used to select the utmost one.")</p>
   1.224 +
   1.225 +<form method="get" action="$SCRIPT_NAME#meta">
   1.226 +	<table>
   1.227 +EOT
   1.228 +		i=""
   1.229 +		while [ -n "$(GET addmeta)" ]; do
   1.230 +			[ -n "$(GET input$i)" ] || break
   1.231 +			j=$(($i + 1))
   1.232 +			cat << EOT
   1.233 +		<tr>
   1.234 +			<td>$(gettext 'ISO number') $j: $(GET input$i)
   1.235 +				<input type="hidden" name="input$j" value="$(GET input$i)" />
   1.236 +			</td>
   1.237 +			<td>$(gettext 'Minimum RAM'): $(GET ram$i)
   1.238 +				<input type="hidden" name="ram$j" value="$(GET ram$i)" />
   1.239 +			</td>
   1.240 +		</tr>
   1.241 +EOT
   1.242 +			i=$j
   1.243 +		done
   1.244 +		metaoutput="$(GET metaoutput)"
   1.245 +		[ -n "$metaoutput" ] || metaoutput="/root/meta.iso"
   1.246 +
   1.247 +		cat << EOT
   1.248 +		<tr>
   1.249 +			<td>$(gettext 'ISO to add')
   1.250 +				<input type="text" name="input" value="/root/" />
   1.251 +			</td>
   1.252 +			<td>$(gettext 'Minimum RAM')
   1.253 +				<input type="text" name="ram" value="128M" />
   1.254 +				<input type="submit" name="addmeta" value="$(gettext 'Add to the list')" />
   1.255 +			</td>
   1.256 +		</tr>
   1.257 +		<tr>
   1.258 +			<td>$(gettext 'ISO to create')
   1.259 +				<input type="text" name="metaoutput" value="$metaoutput" />
   1.260 +			</td>
   1.261 +		</tr>
   1.262 +	</table>
   1.263 +	<input type="submit" name="meta" value="$(gettext 'Build a meta ISO')" />
   1.264 +</form>
   1.265 +
   1.266 +EOT
   1.267 +		;;
   1.268 +esac
   1.269 +
   1.270 +xhtml_footer
   1.271 +exit 0