tazpanel view live.cgi @ rev 338

settings.cgi: set tz
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jan 02 14:12:12 2013 +0100 (2013-01-02)
parents 72e9955ebdff
children 91ba0f11bea6
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 esac
73 #
74 # Commands
75 #
77 case " $(GET) " in
78 *\ create\ *)
79 #
80 # Create a flavor file and ISO in options with all settings
81 # Step by step interface and store files in cache.
82 #
83 gettext 'TODO' ;;
84 *\ liveusb\ *)
85 xhtml_header
86 cat << EOT
87 <div id="wrapper">
88 <h2>$(gettext 'SliTaz LiveUSB')</h2>
89 <p>$(gettext 'Create Live USB SliTaz systems')<p>
90 </div>
92 <p>$(gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a LiveCD \
93 into the cdrom drive, select the correct device and press Generate.")</p>
95 <form method="get" action="$SCRIPT_NAME">
96 <input type="hidden" name="liveusb" />
97 $(gettext 'USB Media to use:')
98 <select name="gen">
99 EOT
100 # List disk if there is a plugged USB device
101 if [ -d /proc/scsi/usb-storage ]; then
102 for i in `blkid | cut -d ":" -f 1`; do
103 echo "<option value='$i'>$i</option>"
104 done
105 else
106 echo "<option value="">$(gettext 'Not found')</option>"
107 fi
108 cat << EOT
109 </select>
110 <input type="submit" value="$(gettext 'Generate')" />
111 </form>
112 EOT
113 if [ "$(GET gen)" ]; then
114 cat << EOT
115 <h3>tazusb gen-liveusb $(GET gen)</h3>
116 <pre>
117 EOT
118 # No pipe here so output is displayed in realtime
119 yes | tazusb gen-liveusb $(GET gen)
120 echo '</pre>'
121 fi ;;
122 *)
123 #
124 # Default xHTML content
125 #
126 xhtml_header
127 cat << EOT
128 <div id="wrapper">
129 <h2>$(gettext 'SliTaz Live Systems')</h2>
130 <p>$(gettext 'Create and manage Live CD or USB SliTaz systems')<p>
131 </div>
133 <div id="actions">
134 <a class="button" href="$SCRIPT_NAME?liveusb">
135 <img src="$IMAGES/harddisk.png" />$(gettext 'Create LiveUSB')</a>
136 </div>
139 <!--
140 <h3 id="livecd">$(gettext 'Write a Live CD')</h3>
142 <p>$(gettext "The command writeiso will generate an ISO image of the current \
143 filesystem as is, including all files in the /home directory. It is an easy \
144 way to remaster a SliTaz Live system, you just have to: boot, modify, \
145 writeiso.")</p>
147 <form method="get" action="$SCRIPT_NAME">
148 $(gettext 'Compression type:')
149 <select name="write_iso">
150 <option value="gzip">gzip</option>
151 <option value="lzma">lzma</option>
152 <option value="none">$(gettext 'none')</option>
153 </select>
154 <input type="submit" value="$(gettext 'Write ISO')" />
155 </form> -->
158 <h3>$(gettext 'Live CD tools')</h3>
160 <h4 id="loram">$(gettext 'Convert ISO to loram')</h4>
162 <p>$(gettext "This command will convert an ISO image of a SliTaz Live CD to a \
163 new ISO image requiring less RAM to run.")</p>
165 <form method="get" action="$SCRIPT_NAME#loram">
166 <table>
167 <tr>
168 <td>$(gettext 'ISO to convert')
169 <input type="text" accept=".iso" name="input" value="/root/" /></td>
170 </tr>
171 <tr>
172 <td><input type="radio" name="type" value="ram" id="type1" checked />
173 <label for="type1">$(gettext 'The filesystem is always in RAM')</label>
174 </td>
175 </tr>
176 <tr>
177 <td><input type="radio" name="type" value="smallcdrom" id="type2" />
178 <label for="type2">$(gettext 'The filesystem may be on a small CDROM')</label>
179 </td>
180 </tr>
181 <tr>
182 <td><input type="radio" name="type" value="cdrom" id="type3" />
183 <label for="type3">$(gettext 'The filesystem may be on a large CDROM')</label>
184 </td>
185 </tr>
186 <tr>
187 <td>$(gettext 'ISO to create')
188 <input type="text" accept=".iso" name="loramoutput" value="/root/loram.iso" />
189 </td>
190 </tr>
191 </table>
192 <input type="submit" value="$(gettext 'Convert ISO to loram')" />
193 </form>
196 <h4 id="meta">$(gettext 'Build a meta ISO')</h4>
198 <p>$(gettext "Combines several ISO flavors like nested Russian dolls. The \
199 amount of RAM available at startup will be used to select the utmost one.")</p>
201 <form method="get" action="$SCRIPT_NAME#meta">
202 <table>
203 EOT
204 i=""
205 while [ -n "$(GET addmeta)" ]; do
206 [ -n "$(GET input$i)" ] || break
207 j=$(($i + 1))
208 cat << EOT
209 <tr>
210 <td>$(gettext 'ISO number') $j: $(GET input$i)
211 <input type="hidden" name="input$j" value="$(GET input$i)" />
212 </td>
213 <td>$(gettext 'Minimum RAM'): $(GET ram$i)
214 <input type="hidden" name="ram$j" value="$(GET ram$i)" />
215 </td>
216 </tr>
217 EOT
218 i=$j
219 done
220 metaoutput="$(GET metaoutput)"
221 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso"
223 cat << EOT
224 <tr>
225 <td>$(gettext 'ISO to add')
226 <input type="text" name="input" value="/root/" />
227 </td>
228 <td>$(gettext 'Minimum RAM')
229 <input type="text" name="ram" value="128M" />
230 <input type="submit" name="addmeta" value="$(gettext 'Add to the list')" />
231 </td>
232 </tr>
233 <tr>
234 <td>$(gettext 'ISO to create')
235 <input type="text" name="metaoutput" value="$metaoutput" />
236 </td>
237 </tr>
238 </table>
239 <input type="submit" name="meta" value="$(gettext 'Build a meta ISO')" />
240 </form>
242 EOT
243 ;;
244 esac
246 xhtml_footer
247 exit 0