tazlito view live.cgi @ rev 382

live.cgi: align submenu
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue May 05 09:11:31 2015 +0200 (2015-05-05)
parents 980becc97bff
children 3f451953e917
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 *\ write_iso\ *)
80 $TERMINAL $TERM_OPTS \
81 -T "write-iso" \
82 -e "tazlito writeiso $(GET write_iso)" & ;;
83 *\ loramoutput\ *)
84 $TERMINAL $TERM_OPTS \
85 -T "build loram iso" \
86 -e "tazlito build-loram $(GET input) $(GET loramoutput) $(GET type)" & ;;
87 *\ meta\ *)
88 tmp=/tmp/$(basename $0).$$
89 cleanup="sh $0 call merge_cleanup $(GET output) $tmp"
90 $TERMINAL $TERM_OPTS \
91 -T "build meta iso" \
92 -e "tazlito merge $(merge_args $tmp); \
93 gettext 'ENTER to quit'; read i; \
94 $cleanup" & ;;
95 *\ hybrid\ *)
96 $TERMINAL $TERM_OPTS \
97 -T "build hybrid iso" \
98 -e "iso2exe $(GET input)" & ;;
99 esac
101 #
102 # Commands
103 #
105 case " $(GET) " in
106 *\ create\ *)
107 #
108 # Create a flavor file and ISO in options with all settings
109 # Step by step interface and store files in cache.
110 #
111 gettext 'TODO' ;;
112 *\ liveusb\ *)
113 xhtml_header
114 cat << EOT
115 <div id="wrapper">
116 <h2>$(gettext 'SliTaz LiveUSB')</h2>
117 <p>$(gettext 'Create Live USB SliTaz systems')<p>
118 </div>
120 <p>$(gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a LiveCD \
121 into the cdrom drive, select the correct device and press Generate.")</p>
123 <form method="get" action="$SCRIPT_NAME">
124 <input type="hidden" name="liveusb" />
125 $(gettext 'USB Media to use:')
126 <select name="gen">
127 EOT
128 # List disk if there is a plugged USB device
129 if [ -d /proc/scsi/usb-storage ]; then
130 for i in `blkid | cut -d ":" -f 1`; do
131 echo "<option value='$i'>$i</option>"
132 done
133 else
134 echo "<option value="">$(gettext 'Not found')</option>"
135 fi
136 cat << EOT
137 </select>
138 <input type="submit" value="$(gettext 'Generate')" />
139 </form>
140 EOT
141 if [ "$(GET gen)" ]; then
142 cat << EOT
143 <h3>tazusb gen-liveusb $(GET gen)</h3>
144 <pre>
145 EOT
146 # No pipe here so output is displayed in realtime
147 yes | tazusb gen-liveusb $(GET gen)
148 echo '</pre>'
149 fi ;;
150 *)
151 #
152 # Default xHTML content
153 #
154 xhtml_header
155 cat << EOT
156 <div id="wrapper">
157 <h2>$(gettext 'SliTaz Live Systems')</h2>
158 <p>$(gettext 'Create and manage Live CD or USB SliTaz systems')<p>
159 </div>
161 <div id="actions">
162 <a class="button" href="$SCRIPT_NAME?liveusb">
163 <img src="$IMAGES/harddisk.png" />$(gettext 'Create LiveUSB')</a>
164 </div>
167 <!--
168 <h3 id="livecd">$(gettext 'Write a Live CD')</h3>
170 <p>$(gettext "The command writeiso will generate an ISO image of the current \
171 filesystem as is, including all files in the /home directory. It is an easy \
172 way to remaster a SliTaz Live system, you just have to: boot, modify, \
173 writeiso.")</p>
175 <form method="get" action="$SCRIPT_NAME">
176 $(gettext 'Compression type:')
177 <select name="write_iso">
178 <option value="gzip">gzip</option>
179 <option value="lzma">lzma</option>
180 <option value="none">$(gettext 'none')</option>
181 </select>
182 <input type="submit" value="$(gettext 'Write ISO')" />
183 </form> -->
186 <h3>$(gettext 'Live CD tools')</h3>
188 <h4 id="loram">$(gettext 'Convert ISO to loram')</h4>
190 <p>$(gettext "This command will convert an ISO image of a SliTaz Live CD to a \
191 new ISO image requiring less RAM to run.")</p>
193 <form method="get" action="$SCRIPT_NAME#loram">
194 <table>
195 <tr>
196 <td>$(gettext 'ISO to convert')
197 <input type="text" accept=".iso" name="input" value="/root/" /></td>
198 </tr>
199 <tr>
200 <td><input type="radio" name="type" value="ram" id="type1" checked />
201 <label for="type1">$(gettext 'The filesystem is always in RAM')</label>
202 </td>
203 </tr>
204 <tr>
205 <td><input type="radio" name="type" value="smallcdrom" id="type2" />
206 <label for="type2">$(gettext 'The filesystem may be on a small CDROM')</label>
207 </td>
208 </tr>
209 <tr>
210 <td><input type="radio" name="type" value="cdrom" id="type3" />
211 <label for="type3">$(gettext 'The filesystem may be on a large CDROM')</label>
212 </td>
213 </tr>
214 <tr>
215 <td>$(gettext 'ISO to create')
216 <input type="text" accept=".iso" name="loramoutput" value="/root/loram.iso" />
217 </td>
218 </tr>
219 </table>
220 <input type="submit" value="$(gettext 'Convert ISO to loram')" />
221 </form>
224 <h4 id="hybrid">$(gettext 'Build a hybrid ISO')</h4>
226 <p>$(gettext "Add a master boot sector and an EXE header to the ISO image. \
227 ")</p>
229 <form method="get" action="$SCRIPT_NAME#hybrid">
230 <table>
231 <tr>
232 <td>
233 $(gettext 'ISO to convert')
234 <input type="text" name="input" value="/root/" />
235 </td>
236 </tr>
237 </table>
238 <input type="submit" name="hybrid" value="$(gettext 'Build a hybrid ISO')" />
239 </form>
241 <h4 id="meta">$(gettext 'Build a meta ISO')</h4>
243 <p>$(gettext "Combines several ISO flavors like nested Russian dolls. The \
244 amount of RAM available at startup will be used to select the utmost one.")</p>
246 <form method="get" action="$SCRIPT_NAME#meta">
247 <table>
248 EOT
249 i=""
250 while [ -n "$(GET addmeta)" ]; do
251 [ -n "$(GET input$i)" ] || break
252 j=$(($i + 1))
253 cat << EOT
254 <tr>
255 <td>$(gettext 'ISO number') $j: $(GET input$i)
256 <input type="hidden" name="input$j" value="$(GET input$i)" />
257 </td>
258 <td>$(gettext 'Minimum RAM'): $(GET ram$i)
259 <input type="hidden" name="ram$j" value="$(GET ram$i)" />
260 </td>
261 </tr>
262 EOT
263 i=$j
264 done
265 metaoutput="$(GET metaoutput)"
266 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso"
268 cat << EOT
269 <tr>
270 <td>$(gettext 'ISO to add')
271 <input type="text" name="input" value="/root/" />
272 </td>
273 <td>$(gettext 'Minimum RAM')
274 <input type="text" name="ram" value="128M" />
275 <input type="submit" name="addmeta" value="$(gettext 'Add to the list')" />
276 </td>
277 </tr>
278 <tr>
279 <td>$(gettext 'ISO to create')
280 <input type="text" name="metaoutput" value="$metaoutput" />
281 </td>
282 </tr>
283 </table>
284 <input type="submit" name="meta" value="$(gettext 'Build a meta ISO')" />
285 </form>
287 EOT
288 ;;
289 esac
291 xhtml_footer
292 exit 0