tazpanel view live.cgi @ rev 78

live.cgi: add meta tool
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Apr 12 22:26:40 2011 +0200 (2011-04-12)
parents 5db1f3648ed8
children 25602bc63ca7
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 - GNU gpl v3
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 . /usr/bin/httpd_helper.sh
22 header
24 # Common functions from libtazpanel
25 . lib/libtazpanel
26 get_config
28 # Include gettext helper script.
29 . /usr/bin/gettext.sh
31 # Export package name for gettext.
32 TEXTDOMAIN='tazpanel'
33 export TEXTDOMAIN
35 TITLE="- Live"
37 # Build arguments to create a meta iso using 'tazlito merge' command
38 merge_args()
39 {
40 tmp=$1
41 first=true
42 i=1
43 while [ -n "$(GET input$i)" ]; do
44 echo "$(stat -c "%s" $(GET input$i)) $(GET input$i) $(GET ram$i)"
45 $((i++))
46 done | sort -nr | while read size file ram; do
47 if $first; then
48 cp $file $(GET metaoutput)
49 echo -n "$ram $(GET metaoutput) "
50 first=false
51 continue
52 fi
53 dir=$tmp/$(basename $file)
54 mkdir $dir
55 mount -o loop,ro $file $dir
56 echo -n "$ram $dir/boot/rootfs.gz "
57 done
58 }
60 #
61 # Commands executed in Xterm first
62 #
64 case " $(GET) " in
65 *\ write-iso\ *)
66 comp=${QUERY_STRING#write-iso=}
67 $TERMINAL $TERM_OPTS \
68 -T "write-iso" \
69 -e "tazlito writeiso $comp" & ;;
70 *\ gen-liveusb\ *)
71 dev=`httpd -d ${QUERY_STRING#gen-liveusb=}`
72 $TERMINAL $TERM_OPTS \
73 -T "Tazusb gen-liveusb" \
74 -e "tazusb gen-liveusb $dev; \
75 gettext \"ENTER to quit\"; read i" & ;;
76 *\ loramoutput\ *)
77 $TERMINAL $TERM_OPTS \
78 -T "build loram iso" \
79 -e "tazlito build-loram $(GET input) $(GET loramoutput) $(GET type)" & ;;
80 *\ meta\ *)
81 tmp=/tmp/$(basename $0).$$
82 cleanup="sh $0 call merge_cleanup $(GET output) $tmp"
83 $TERMINAL $TERM_OPTS \
84 -T "build meta iso" \
85 -e "tazlito merge $(merge_args $tmp); \
86 gettext \"ENTER to quit\"; read i; \
87 $cleanup" & ;;
88 esac
90 #
91 # Commands
92 #
94 case "$QUERY_STRING" in
95 create)
96 #
97 # Create a flavor file and ISO in options with all settings
98 # Step by step interface and store files in cache.
99 #
100 gettext "TODO" ;;
101 *)
102 #
103 # Default xHTML content
104 #
105 xhtml_header
106 cat << EOT
107 <div id="wrapper">
108 <h2>`gettext "SliTaz Live Systems"`</h2>
109 <p>`gettext "Create and manage Live CD or USB SliTaz systems"`<p>
110 </div>
112 <a name="liveusb"></a>
113 <h3>`gettext "Live USB"`</h3>
114 <p>
115 `gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a
116 LiveCD into the cdrom drive, select the correct device and press
117 Generate."`
118 </p>
119 <form method="get" action="$SCRIPT_NAME">
120 `gettext "USB Media to use:"`
121 <select name="gen-liveusb">
122 EOT
123 # List disk if plugged USB device
124 if [ -d /proc/scsi/usb-storage ]; then
125 for i in `blkid | cut -d ":" -f 1`; do
126 echo "<option value='$i'>$i</option>"
127 done
128 else
129 echo "<option value="">"`gettext "Not found"`"</option>"
130 fi
131 cat << EOT
132 </select>
133 <input type="submit" value="`gettext "Generate"`" />
134 </form>
136 <a name="livecd"></a>
137 <h3>`gettext "Write a Live CD"`</h3>
138 <p>
139 `gettext "The command writeiso will generate an ISO image of the
140 current filesystem as is, including all files in the /home directory.
141 It is an easy way to remaster a SliTaz Live system, you just have
142 to: boot, modify, writeiso."`
143 </p>
144 <form method="get" action="$SCRIPT_NAME">
145 `gettext "Compression type:"`
146 <select name="write-iso">
147 <option value="gzip">gzip</option>
148 <option value="lzma">lzma</option>
149 <option value="none">none</option>
150 </select>
151 <input type="submit" value="`gettext "Write ISO"`" />
152 </form>
154 <h3>`gettext "Live CD tools"`</h3>
155 <a name="loram"></a>
156 <h4>`gettext "Convert ISO to loram"`</h4>
157 <p>
158 `gettext "This command will convert an ISO image of a SliTaz Live CD
159 to a new ISO image requiring less RAM to run."`
160 </p>
161 <form method="get" action="$SCRIPT_NAME#loram">
162 <table>
163 <tr>
164 <td>`gettext "ISO to convert"`
165 <input type="text" name="input" value="/root/" /></td>
166 </tr>
167 <tr>
168 <td><input type="radio" name="type" value="ram" checked />`gettext "The filesystem is always in RAM"`.</td>
169 </tr>
170 <tr>
171 <td><input type="radio" name="type" value="smallcdrom" />`gettext "The filesystem may be on a small CDROM"`.</td>
172 </tr>
173 <tr>
174 <td><input type="radio" name="type" value="cdrom" />`gettext "The filesystem may be on a large CDROM"`.</td>
175 </tr>
176 <tr>
177 <td>`gettext "ISO to create"`
178 <input type="text" name="loramoutput" value="/root/loram.iso" /></td>
179 </tr>
180 </table>
181 <input type="submit" value="`gettext "Convert ISO to loram"`" />
182 </form>
184 <a name="meta"></a>
185 <h4>`gettext "Buld a meta ISO"`</h4>
186 <p>
187 `gettext "Combines several ISO flavors like nested Russian dolls.
188 The amount of RAM available at startup will be used to select the
189 utmost one."`
190 </p>
191 <form method="get" action="$SCRIPT_NAME#meta">
192 <table>
193 EOT
194 i=""
195 while [ -n "$(GET addmeta)" ]; do
196 [ -n "$(GET input$i)" ] || break
197 j=$(($i + 1))
198 cat << EOT
199 <tr>
200 <td>`gettext "ISO number"` $j: $(GET input$i)
201 <input type="hidden" name="input$j" value="$(GET input$i)" /></td>
202 <td>`gettext "minimum RAM"`: $(GET ram$i)
203 <input type="hidden" name="ram$j" value="$(GET ram$i)" /></td>
204 </tr>
205 EOT
206 i=$j
207 done
208 metaoutput="$(GET metaoutput)"
209 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso"
211 cat << EOT
212 <tr>
213 <td>`gettext "ISO to add"`
214 <input type="text" name="input" value="/root/" /></td>
215 <td>`gettext "minimum RAM"`
216 <input type="text" name="ram" value="128M" />
217 <input type="submit" name="addmeta" value="`gettext "Add to the list"`" /></td>
218 </tr>
219 <tr>
220 <td>`gettext "ISO to create"`
221 <input type="text" name="metaoutput" value="$metaoutput" /></td>
222 </tr>
223 </table>
224 <input type="submit" name="meta" value="`gettext "Build a meta ISO"`" />
225 </form>
227 EOT
228 ;;
229 esac
231 xhtml_footer
232 exit 0