tazpanel view live.cgi @ rev 288

live: make live usb into tazpanle, new input and button style
author Christophe Lincoln <pankso@slitaz.org>
date Mon Apr 02 11:22:06 2012 +0200 (2012-04-02)
parents e0d1571d49ba
children 0b4c862081de
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="- 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>
93 $(gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a
94 LiveCD into the cdrom drive, select the correct device and press
95 Generate.")
96 </p>
97 <form method="get" action="$SCRIPT_NAME">
98 <input type="hidden" name="liveusb" />
99 $(gettext "USB Media to use:")
100 <select name="gen">
101 EOT
102 # List disk if there is a plugged USB device
103 if [ -d /proc/scsi/usb-storage ]; then
104 for i in `blkid | cut -d ":" -f 1`; do
105 echo "<option value='$i'>$i</option>"
106 done
107 else
108 echo "<option value="">"`gettext "Not found"`"</option>"
109 fi
110 cat << EOT
111 </select>
112 <input type="submit" value="`gettext "Generate"`" />
113 </form>
114 EOT
115 if [ "$(GET gen)" ]; then
116 echo "<h3>tazusb gen-liveusb $(GET gen)</h3>"
117 echo '<pre>'
118 # No pipe here so output is displayed in realtime
119 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>
138 <a name="livecd"></a>
139 <h3>`gettext "Write a Live CD"`</h3>
140 <p>
141 `gettext "The command writeiso will generate an ISO image of the
142 current filesystem as is, including all files in the /home directory.
143 It is an easy way to remaster a SliTaz Live system, you just have
144 to: boot, modify, writeiso."`
145 </p>
146 <form method="get" action="$SCRIPT_NAME">
147 `gettext "Compression type:"`
148 <select name="write_iso">
149 <option value="gzip">gzip</option>
150 <option value="lzma">lzma</option>
151 <option value="none">none</option>
152 </select>
153 <input type="submit" value="`gettext "Write ISO"`" />
154 </form>
156 <h3>`gettext "Live CD tools"`</h3>
157 <a name="loram"></a>
158 <h4>`gettext "Convert ISO to loram"`</h4>
159 <p>
160 `gettext "This command will convert an ISO image of a SliTaz Live CD
161 to a new ISO image requiring less RAM to run."`
162 </p>
163 <form method="get" action="$SCRIPT_NAME#loram">
164 <table>
165 <tr>
166 <td>`gettext "ISO to convert"`
167 <input type="text" name="input" value="/root/" /></td>
168 </tr>
169 <tr>
170 <td><input type="radio" name="type" value="ram" checked />`gettext "The filesystem is always in RAM"`.</td>
171 </tr>
172 <tr>
173 <td><input type="radio" name="type" value="smallcdrom" />`gettext "The filesystem may be on a small CDROM"`.</td>
174 </tr>
175 <tr>
176 <td><input type="radio" name="type" value="cdrom" />`gettext "The filesystem may be on a large CDROM"`.</td>
177 </tr>
178 <tr>
179 <td>`gettext "ISO to create"`
180 <input type="text" name="loramoutput" value="/root/loram.iso" /></td>
181 </tr>
182 </table>
183 <input type="submit" value="`gettext "Convert ISO to loram"`" />
184 </form>
186 <a name="meta"></a>
187 <h4>`gettext "Build a meta ISO"`</h4>
188 <p>
189 `gettext "Combines several ISO flavors like nested Russian dolls.
190 The amount of RAM available at startup will be used to select the
191 utmost one."`
192 </p>
193 <form method="get" action="$SCRIPT_NAME#meta">
194 <table>
195 EOT
196 i=""
197 while [ -n "$(GET addmeta)" ]; do
198 [ -n "$(GET input$i)" ] || break
199 j=$(($i + 1))
200 cat << EOT
201 <tr>
202 <td>`gettext "ISO number"` $j: $(GET input$i)
203 <input type="hidden" name="input$j" value="$(GET input$i)" /></td>
204 <td>`gettext "Minimum RAM"`: $(GET ram$i)
205 <input type="hidden" name="ram$j" value="$(GET ram$i)" /></td>
206 </tr>
207 EOT
208 i=$j
209 done
210 metaoutput="$(GET metaoutput)"
211 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso"
213 cat << EOT
214 <tr>
215 <td>`gettext "ISO to add"`
216 <input type="text" name="input" value="/root/" /></td>
217 <td>`gettext "Minimum RAM"`
218 <input type="text" name="ram" value="128M" />
219 <input type="submit" name="addmeta" value="`gettext "Add to the list"`" /></td>
220 </tr>
221 <tr>
222 <td>`gettext "ISO to create"`
223 <input type="text" name="metaoutput" value="$metaoutput" /></td>
224 </tr>
225 </table>
226 <input type="submit" name="meta" value="`gettext "Build a meta ISO"`" />
227 </form>
229 EOT
230 ;;
231 esac
233 xhtml_footer
234 exit 0