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