tazlito view live.cgi @ rev 383

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