tazpanel view live.cgi @ rev 86

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