tazpanel view live.cgi @ rev 205

Tiny edits
author Paul Issott <paul@slitaz.org>
date Sun Aug 14 10:49:10 2011 +0100 (2011-08-14)
parents 7855bd81abb7
children 42a96c3bc97e
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 *\ gen_liveusb\ *)
60 $TERMINAL $TERM_OPTS \
61 -T "Tazusb gen-liveusb" \
62 -e "tazusb gen-liveusb $(GET gen_liveusb); \
63 gettext \"ENTER to quit\"; read i" & ;;
64 *\ loramoutput\ *)
65 $TERMINAL $TERM_OPTS \
66 -T "build loram iso" \
67 -e "tazlito build-loram $(GET input) $(GET loramoutput) $(GET type)" & ;;
68 *\ meta\ *)
69 tmp=/tmp/$(basename $0).$$
70 cleanup="sh $0 call merge_cleanup $(GET output) $tmp"
71 $TERMINAL $TERM_OPTS \
72 -T "build meta iso" \
73 -e "tazlito merge $(merge_args $tmp); \
74 gettext \"ENTER to quit\"; read i; \
75 $cleanup" & ;;
76 esac
78 #
79 # Commands
80 #
82 case " $(GET) " in
83 *\ create\ *)
84 #
85 # Create a flavor file and ISO in options with all settings
86 # Step by step interface and store files in cache.
87 #
88 gettext "TODO" ;;
89 *)
90 #
91 # Default xHTML content
92 #
93 xhtml_header
94 cat << EOT
95 <div id="wrapper">
96 <h2>`gettext "SliTaz Live Systems"`</h2>
97 <p>`gettext "Create and manage Live CD or USB SliTaz systems"`<p>
98 </div>
100 <a name="liveusb"></a>
101 <h3>`gettext "Live USB"`</h3>
102 <p>
103 `gettext "Generate SliTaz LiveUSB media and boot in RAM! Insert a
104 LiveCD into the cdrom drive, select the correct device and press
105 Generate."`
106 </p>
107 <form method="get" action="$SCRIPT_NAME">
108 `gettext "USB Media to use:"`
109 <select name="gen_liveusb">
110 EOT
111 # List disk if there is a plugged USB device
112 if [ -d /proc/scsi/usb-storage ]; then
113 for i in `blkid | cut -d ":" -f 1`; do
114 echo "<option value='$i'>$i</option>"
115 done
116 else
117 echo "<option value="">"`gettext "Not found"`"</option>"
118 fi
119 cat << EOT
120 </select>
121 <input type="submit" value="`gettext "Generate"`" />
122 </form>
124 <a name="livecd"></a>
125 <h3>`gettext "Write a Live CD"`</h3>
126 <p>
127 `gettext "The command writeiso will generate an ISO image of the
128 current filesystem as is, including all files in the /home directory.
129 It is an easy way to remaster a SliTaz Live system, you just have
130 to: boot, modify, writeiso."`
131 </p>
132 <form method="get" action="$SCRIPT_NAME">
133 `gettext "Compression type:"`
134 <select name="write_iso">
135 <option value="gzip">gzip</option>
136 <option value="lzma">lzma</option>
137 <option value="none">none</option>
138 </select>
139 <input type="submit" value="`gettext "Write ISO"`" />
140 </form>
142 <h3>`gettext "Live CD tools"`</h3>
143 <a name="loram"></a>
144 <h4>`gettext "Convert ISO to loram"`</h4>
145 <p>
146 `gettext "This command will convert an ISO image of a SliTaz Live CD
147 to a new ISO image requiring less RAM to run."`
148 </p>
149 <form method="get" action="$SCRIPT_NAME#loram">
150 <table>
151 <tr>
152 <td>`gettext "ISO to convert"`
153 <input type="text" name="input" value="/root/" /></td>
154 </tr>
155 <tr>
156 <td><input type="radio" name="type" value="ram" checked />`gettext "The filesystem is always in RAM"`.</td>
157 </tr>
158 <tr>
159 <td><input type="radio" name="type" value="smallcdrom" />`gettext "The filesystem may be on a small CDROM"`.</td>
160 </tr>
161 <tr>
162 <td><input type="radio" name="type" value="cdrom" />`gettext "The filesystem may be on a large CDROM"`.</td>
163 </tr>
164 <tr>
165 <td>`gettext "ISO to create"`
166 <input type="text" name="loramoutput" value="/root/loram.iso" /></td>
167 </tr>
168 </table>
169 <input type="submit" value="`gettext "Convert ISO to loram"`" />
170 </form>
172 <a name="meta"></a>
173 <h4>`gettext "Build a meta ISO"`</h4>
174 <p>
175 `gettext "Combines several ISO flavors like nested Russian dolls.
176 The amount of RAM available at startup will be used to select the
177 utmost one."`
178 </p>
179 <form method="get" action="$SCRIPT_NAME#meta">
180 <table>
181 EOT
182 i=""
183 while [ -n "$(GET addmeta)" ]; do
184 [ -n "$(GET input$i)" ] || break
185 j=$(($i + 1))
186 cat << EOT
187 <tr>
188 <td>`gettext "ISO number"` $j: $(GET input$i)
189 <input type="hidden" name="input$j" value="$(GET input$i)" /></td>
190 <td>`gettext "Minimum RAM"`: $(GET ram$i)
191 <input type="hidden" name="ram$j" value="$(GET ram$i)" /></td>
192 </tr>
193 EOT
194 i=$j
195 done
196 metaoutput="$(GET metaoutput)"
197 [ -n "$metaoutput" ] || metaoutput="/root/meta.iso"
199 cat << EOT
200 <tr>
201 <td>`gettext "ISO to add"`
202 <input type="text" name="input" value="/root/" /></td>
203 <td>`gettext "Minimum RAM"`
204 <input type="text" name="ram" value="128M" />
205 <input type="submit" name="addmeta" value="`gettext "Add to the list"`" /></td>
206 </tr>
207 <tr>
208 <td>`gettext "ISO to create"`
209 <input type="text" name="metaoutput" value="$metaoutput" /></td>
210 </tr>
211 </table>
212 <input type="submit" name="meta" value="`gettext "Build a meta ISO"`" />
213 </form>
215 EOT
216 ;;
217 esac
219 xhtml_footer
220 exit 0