rev |
line source |
pascal@208
|
1 #!/bin/sh
|
pascal@208
|
2 #
|
pascal@208
|
3 # Main CGI interface for Tazinst, the SliTaz installer.
|
pascal@208
|
4 #
|
pankso@254
|
5 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
|
pascal@208
|
6 #
|
pascal@208
|
7 # Authors : Dominique Corbex <domcox@slitaz.org>
|
pankso@254
|
8 # Christophe Lincoln <pankso@slitaz.org>
|
pascal@208
|
9 #
|
pascal@208
|
10
|
domcox@235
|
11 VERSION=0.22
|
pascal@208
|
12
|
pascal@208
|
13 # Common functions from libtazpanel
|
pascal@208
|
14 . lib/libtazpanel
|
pascal@208
|
15 header
|
pascal@208
|
16 get_config
|
pascal@208
|
17
|
pascal@208
|
18 # Include gettext helper script.
|
pascal@208
|
19 . /usr/bin/gettext.sh
|
pascal@208
|
20
|
pascal@208
|
21 # Export package name for gettext.
|
pascal@208
|
22 TEXTDOMAIN='installer'
|
pascal@208
|
23 export TEXTDOMAIN
|
pascal@208
|
24
|
pascal@208
|
25 TITLE="- Installer"
|
pascal@208
|
26
|
pascal@208
|
27 # Tazinst required version
|
pascal@208
|
28 TAZINST_REQUIRED_VERSION="3.3"
|
pascal@208
|
29
|
pascal@208
|
30 # Tazinst setup file
|
pascal@208
|
31 INSTFILE=/var/lib/tazinst.conf
|
pascal@208
|
32
|
pascal@208
|
33 read_setup()
|
pascal@208
|
34 {
|
pascal@208
|
35 [ -e "$INSTFILE" ] && . $INSTFILE || gettext "Tazinst setup file not found!"
|
pascal@208
|
36 }
|
pascal@208
|
37
|
pascal@208
|
38 write_setup()
|
pascal@208
|
39 {
|
pascal@208
|
40 if [ -e "$INSTFILE" ]; then
|
pascal@208
|
41 # Install type
|
pascal@208
|
42 INST_TYPE=$(GET INST_TYPE)
|
pascal@208
|
43 # Source File
|
pascal@208
|
44 case "$INST_TYPE" in
|
pascal@208
|
45 usb)
|
pascal@208
|
46 SRC_FILE=$(GET SRC_USB) ;;
|
pascal@208
|
47 iso)
|
pascal@208
|
48 SRC_FILE=$(GET SRC_ISO) ;;
|
pascal@208
|
49 web)
|
pascal@208
|
50 SRC_FILE=$(GET SRC_WEB) ;;
|
pascal@208
|
51 esac
|
pascal@208
|
52 SRC_FILE=$(echo "$SRC_FILE" | sed 's/\//\\\//'g)
|
pascal@208
|
53 [ -n $(GET URL) ] && SRC_WEB=$(GET URL)
|
pascal@208
|
54 # Main Partition
|
pascal@208
|
55 TGT_PARTITION=$(echo "$(GET TGT_PARTITION)" | sed 's/\//\\\//'g)
|
pascal@208
|
56 [ -n "$(GET MAIN_FMT)" ] && TGT_FS=$(GET MAIN_FS) || TGT_FS=""
|
pascal@208
|
57 # Home Partition
|
pascal@208
|
58 if [ -n "$(GET HOME_SPLIT)" ] ; then
|
pascal@208
|
59 TGT_HOME=$(echo "$(GET HOME_PART)" | sed 's/\//\\\//'g)
|
pascal@208
|
60 [ -n "$(GET HOME_FMT)" ] && TGT_HOME_FS=$(GET HOME_FS)
|
pascal@208
|
61 else
|
pascal@208
|
62 TGT_HOME=""
|
pascal@208
|
63 TGT_HOME_FS=""
|
pascal@208
|
64 fi
|
pascal@208
|
65 # Hostname
|
pascal@208
|
66 TGT_HOSTNAME=$(GET TGT_HOSTNAME)
|
pascal@208
|
67 # Root pwd
|
pascal@208
|
68 TGT_ROOT_PWD=$(GET TGT_ROOT_PWD)
|
pascal@208
|
69 # User Login
|
pascal@208
|
70 TGT_USER=$(GET TGT_USER)
|
pascal@208
|
71 # User Pwd
|
pascal@208
|
72 TGT_USER_PWD=$(GET TGT_USER_PWD)
|
pascal@208
|
73 # Grub
|
pascal@208
|
74 TGT_GRUB=$(GET TGT_GRUB)
|
pascal@208
|
75 [ "$TGT_GRUB" == "yes" ] || TGT_GRUB=no
|
pascal@208
|
76 # Win Dual-Boot
|
pascal@208
|
77 TGT_WINBOOT=$(GET TGT_WINBOOT)
|
pascal@208
|
78
|
pascal@208
|
79 # Save changes to INSTFILE
|
pascal@208
|
80 sed -i s/"^INST_TYPE=.*"/"INST_TYPE=\"$INST_TYPE\"/" $INSTFILE
|
pascal@208
|
81 sed -i s/"^SRC_FILE=.*"/"SRC_FILE=\"$SRC_FILE\"/" $INSTFILE
|
pascal@208
|
82 sed -i s/"^TGT_PARTITION=.*"/"TGT_PARTITION=\"$TGT_PARTITION\"/" $INSTFILE
|
pascal@208
|
83 sed -i s/"^TGT_FS=.*"/"TGT_FS=\"$TGT_FS\"/" $INSTFILE
|
pascal@208
|
84 sed -i s/"^TGT_HOME=.*"/"TGT_HOME=\"$TGT_HOME\"/" $INSTFILE
|
pascal@208
|
85 sed -i s/"^TGT_HOME_FS=.*"/"TGT_HOME_FS=\"$TGT_HOME_FS\"/" $INSTFILE
|
pascal@208
|
86 sed -i s/"^TGT_HOSTNAME=.*"/"TGT_HOSTNAME=\"$TGT_HOSTNAME\"/" $INSTFILE
|
pascal@208
|
87 sed -i s/"^TGT_ROOT_PWD=.*"/"TGT_ROOT_PWD=\"$TGT_ROOT_PWD\"/" $INSTFILE
|
pascal@208
|
88 sed -i s/"^TGT_USER=.*"/"TGT_USER=\"$TGT_USER\"/" $INSTFILE
|
pascal@208
|
89 sed -i s/"^TGT_USER_PWD=.*"/"TGT_USER_PWD=\"$TGT_USER_PWD\"/" $INSTFILE
|
pascal@208
|
90 sed -i s/"^TGT_GRUB=.*"/"TGT_GRUB=\"$TGT_GRUB\"/" $INSTFILE
|
pascal@208
|
91 sed -i s/"^TGT_WINBOOT=.*"/"TGT_WINBOOT=\"$TGT_WINBOOT\"/" $INSTFILE
|
pascal@208
|
92 fi
|
pascal@208
|
93 }
|
pascal@208
|
94
|
pascal@208
|
95 check_setup()
|
pascal@208
|
96 {
|
pascal@208
|
97 local ret
|
pascal@208
|
98 IFS=$'\n'
|
pascal@208
|
99 for line in $(tazinst check $INSTFILE; ret=$?)
|
pascal@208
|
100 do
|
pascal@208
|
101 line=$(echo $line | sed 's/\[1m//g')
|
pascal@208
|
102 line=$(echo $line | sed 's/\[0m//g')
|
pascal@208
|
103 line=$(echo $line | sed 's/\s/\ /g')
|
pascal@208
|
104 line=$(echo $line | sed 's/</\</g')
|
pascal@208
|
105 line=$(echo $line | sed 's/>/\>/g')
|
pascal@208
|
106 echo "<font color=\"red\">$line<br /></font>"
|
pascal@208
|
107 done
|
pascal@208
|
108 unset IFS
|
pascal@208
|
109 return $ret
|
pascal@208
|
110 }
|
pascal@208
|
111
|
pascal@208
|
112 select_action()
|
pascal@208
|
113 {
|
pascal@208
|
114 cat <<EOT
|
pascal@208
|
115 <div id="wrapper">
|
pascal@208
|
116 <h2>$(gettext "SliTaz Installer")</h2>
|
paul@209
|
117 <p>$(gettext "The SliTaz Installer installs or upgrades SliTaz to a hard disk
|
paul@209
|
118 drive from a device like a Live-CD or LiveUSB key, from a SliTaz ISO file, or
|
pascal@208
|
119 from the web by downloading an ISO file.")<p>
|
pascal@208
|
120 </div>
|
pascal@208
|
121 EOT
|
pascal@208
|
122 }
|
pascal@208
|
123
|
pascal@208
|
124 select_gparted()
|
pascal@208
|
125 {
|
pascal@208
|
126 cat <<EOT
|
pankso@254
|
127 <div class="box">
|
pankso@254
|
128 <h4>$(gettext "About")</h4>
|
pankso@254
|
129 <p>
|
pankso@254
|
130 $(gettext "Before installation, you may need to resize partitions
|
pankso@254
|
131 on your hard disk drive in order to make space for SliTaz GNU/Linux.
|
pankso@254
|
132 You can graphically manage your partions with Gparted")
|
pankso@254
|
133 </p>
|
pankso@254
|
134 </div>
|
pankso@254
|
135 <a class="button" href="$SCRIPT_NAME?page=gparted">Execute Gparted</a>
|
pascal@208
|
136 EOT
|
pascal@208
|
137 }
|
pascal@208
|
138
|
pascal@208
|
139 select_install()
|
pascal@208
|
140 {
|
pascal@208
|
141 cat <<EOT
|
pankso@254
|
142 <div class="box">
|
pankso@254
|
143 <h4>$(gettext "Install")</h4>
|
pankso@254
|
144 <p>
|
pankso@254
|
145 $(gettext "Install SliTaz on a partition of your hard disk drive. If
|
pascal@208
|
146 you decide to format your HDD, all data will be lost. If you do not
|
pascal@208
|
147 format, all data except for any existing /home directory will be removed,
|
pankso@254
|
148 the home directory will be kept as is.")
|
pankso@254
|
149 </p>
|
pankso@254
|
150 </div>
|
pankso@254
|
151 <p>
|
pankso@254
|
152 <a class="button" href="$SCRIPT_NAME?page=install">$(gettext "Install SliTaz")</a>
|
pascal@208
|
153 EOT
|
pascal@208
|
154 }
|
pascal@208
|
155
|
pascal@208
|
156 select_upgrade()
|
pascal@208
|
157 {
|
pascal@208
|
158 cat <<EOT
|
pankso@254
|
159 <div class="box">
|
pankso@254
|
160 <h4>$(gettext "Upgrade")</h4>
|
pankso@254
|
161 <p>
|
pankso@254
|
162 $(gettext "Upgrade an already installed SliTaz system on your hard disk
|
pascal@208
|
163 drive. Your /home /etc /var/www directories will be kept, all other directories
|
paul@209
|
164 will be removed. Any additional packages added to your old Slitaz system
|
pankso@254
|
165 will be updated as long you have an active internet connection.")
|
pankso@254
|
166 </p>
|
pankso@254
|
167 </div>
|
pankso@254
|
168 <p>
|
pankso@254
|
169 <a class="button" href="$SCRIPT_NAME?page=upgrade">$(gettext "Upgrade SliTaz")</a>
|
pankso@254
|
170 </p>
|
pascal@208
|
171 EOT
|
pascal@208
|
172 }
|
pascal@208
|
173
|
pascal@208
|
174 display_action()
|
pascal@208
|
175 {
|
pascal@208
|
176 case $1 in
|
pascal@208
|
177 install)
|
pascal@208
|
178 cat << EOT
|
pascal@208
|
179 <div id="wrapper">
|
pascal@208
|
180 <h3>$(gettext "Install SliTaz")</h3>
|
pascal@208
|
181 <p>$(gettext "You're going to install SliTaz on a partition of your hard disk drive. If
|
pascal@208
|
182 you decide to format your HDD, all data will be lost. If you do not
|
pascal@208
|
183 format, all data except for any existing /home directory will be removed,
|
pascal@208
|
184 the home directory will be kept as is.")<p>
|
pascal@208
|
185 </div>
|
pascal@208
|
186 <input type="hidden" name="INST_ACTION" value="$1">
|
pascal@208
|
187 EOT
|
pascal@208
|
188 ;;
|
pascal@208
|
189 upgrade)
|
pascal@208
|
190 cat << EOT
|
pascal@208
|
191 <div id="wrapper">
|
pascal@208
|
192 <h2>$(gettext "Upgrade SliTaz")</h2>
|
pascal@208
|
193 <p>$(gettext "You're going to upgrade an already installed SliTaz system on your hard disk
|
pascal@208
|
194 drive. Your /home /etc /var/www directories will be kept, all other directories
|
paul@209
|
195 will be removed. Any additional packages added to your old Slitaz system
|
pascal@208
|
196 will be updated as long you have an active internet connection.")<p>
|
pascal@208
|
197 </div>
|
pascal@208
|
198 <input type="hidden" name="INST_ACTION" value="$1">
|
pascal@208
|
199 EOT
|
pascal@208
|
200 ;;
|
pascal@208
|
201 esac
|
pascal@208
|
202 }
|
pascal@208
|
203
|
pascal@208
|
204 select_source()
|
pascal@208
|
205 {
|
pascal@208
|
206 cat <<EOT
|
pascal@208
|
207 <a name="source"></a>
|
pascal@208
|
208 <h4>$(gettext "Source")</h4>
|
pascal@208
|
209 <table>
|
pascal@208
|
210 <tr>
|
pascal@208
|
211 <td><input type="radio" name="INST_TYPE" value="cdrom" $([ "$INST_TYPE" == "cdrom" ] && echo "checked") id="cdrom" />
|
pascal@208
|
212 <label for="cdrom">$(gettext "LiveCD")</td></label>
|
pascal@208
|
213 </tr>
|
pascal@208
|
214 <tr>
|
pascal@208
|
215 <td><input type="radio" name="INST_TYPE" value="usb" $([ "$INST_TYPE" == "usb" ] && echo "checked") id="usb" />
|
pascal@208
|
216 <label for="usb">$(gettext "LiveUSB"):</label>
|
pascal@208
|
217 <select name="SRC_USB">
|
pascal@208
|
218 EOT
|
pascal@208
|
219 # List disks if plugged USB device
|
pascal@208
|
220 usb=0
|
pascal@208
|
221 if [ -d /proc/scsi/usb-storage ]; then
|
pascal@208
|
222 for DEV in /sys/block/sd* ; do
|
pascal@208
|
223 if readlink $DEV | grep -q usb; then
|
pascal@208
|
224 DEV=$(basename $DEV)
|
pascal@208
|
225 if [ -d /sys/block/${DEV}/${DEV}1 ]; then
|
pascal@208
|
226 for i in $(fdisk -l /dev/$DEV | awk '/^\/dev/ {printf "%s ", $1}') ; do
|
pascal@208
|
227 echo "<option value='$i' $([ "$i" == "$SRC_FILE" ] && echo "selected") >$i</option>"
|
pascal@208
|
228 usb=$usb+1
|
pascal@208
|
229 done
|
pascal@208
|
230 fi
|
pascal@208
|
231 fi
|
pascal@208
|
232 done
|
pascal@208
|
233 fi
|
pascal@208
|
234 if [ $usb -lt 1 ]; then
|
pascal@208
|
235 echo "<option value="">$(gettext "Not found")</option>"
|
pascal@208
|
236 fi
|
pascal@208
|
237 cat << EOT
|
pascal@208
|
238 </select>
|
pascal@208
|
239 </td>
|
pascal@208
|
240 </tr>
|
pascal@208
|
241 <tr>
|
pascal@208
|
242 <td><input type="radio" name="INST_TYPE" value="iso" $([ "$INST_TYPE" == "iso" ] && echo "checked") id="iso" />
|
pascal@208
|
243 <label for="iso">$(gettext "ISO file"):</label>
|
pascal@208
|
244 <input type="url" size="50" name="SRC_ISO" $([ "$INST_TYPE" == "iso" ] && echo -e "value=\"$SRC_FILE\"") placeholder="$(gettext "Full path to the ISO image file")" />
|
pascal@208
|
245 </td>
|
pascal@208
|
246 </tr>
|
pascal@208
|
247 <tr>
|
pascal@208
|
248 <td><input type="radio" name="INST_TYPE" value="web" $([ "$INST_TYPE" == "web" ] && echo "checked" id="web") />
|
pascal@208
|
249 <label for="web">$(gettext "Web"):
|
pascal@208
|
250 <a class="button" href="$SCRIPT_NAME?page=$(GET page)&SRC_WEB=stable">$(gettext "Stable")</a>
|
pascal@208
|
251 <a class="button" href="$SCRIPT_NAME?page=$(GET page)&SRC_WEB=cooking">$(gettext "Cooking")</a>
|
pascal@208
|
252 $(gettext "URL:")</label>
|
pascal@208
|
253 EOT
|
pascal@208
|
254 case $(GET SRC_WEB) in
|
pascal@208
|
255 stable|cooking)
|
pascal@208
|
256 get_SRC_WEB=$(tazinst showurl $(GET SRC_WEB)) ;;
|
pascal@208
|
257 *)
|
pascal@208
|
258 [ "$INST_TYPE" == "web" ] && get_SRC_WEB=$SRC_FILE ;;
|
pascal@208
|
259 esac
|
pascal@208
|
260 cat <<EOT
|
pascal@208
|
261 <input type="url" size="55" name="SRC_WEB" value="$get_SRC_WEB" placeholder="$(gettext "Full url to an ISO image file")" /></td>
|
pascal@208
|
262 </tr>
|
pascal@208
|
263 </table>
|
pascal@208
|
264 EOT
|
pascal@208
|
265 }
|
pascal@208
|
266
|
pascal@208
|
267 select_partition()
|
pascal@208
|
268 {
|
pascal@208
|
269 cat <<EOT
|
pascal@208
|
270 <a name="partition"></a>
|
pascal@208
|
271 <h4></span>$(gettext "Main Partition")</h4>
|
pascal@208
|
272 <table>
|
pascal@208
|
273 <tr><td>
|
pascal@208
|
274 $(gettext "Partition to use:")
|
pascal@208
|
275 <select name="TGT_PARTITION">
|
pascal@208
|
276 EOT
|
pascal@208
|
277 # List partitions
|
pascal@208
|
278 if fdisk -l | grep -q ^/dev/ ; then
|
pascal@208
|
279 for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
|
pascal@208
|
280 echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo "selected")>$i</option>"
|
pascal@208
|
281 done
|
pascal@208
|
282 else
|
pascal@208
|
283 echo "<option value="">$(gettext "Not found")</option>"
|
pascal@208
|
284 fi
|
pascal@208
|
285 cat << EOT
|
pascal@208
|
286 </select>
|
pascal@208
|
287 <br />
|
pascal@208
|
288 <input type="checkbox" name="MAIN_FMT" value="yes" $([ -n "$TGT_FS" ] && echo "checked") id="mainfs" />
|
pascal@208
|
289 <label for="mainfs">$(gettext "Format partition as"):</label>
|
pascal@208
|
290 <select name="MAIN_FS">
|
pascal@208
|
291 EOT
|
pascal@208
|
292 scan_mkfs
|
pascal@208
|
293 for i in $FS
|
pascal@208
|
294 do
|
pascal@208
|
295 echo "<option value='$i' $([ "$i" == "$TGT_FS" ] && echo "selected")>$i</option>"
|
pascal@208
|
296 done
|
pascal@208
|
297 cat <<EOT
|
pascal@208
|
298 </select>
|
pascal@208
|
299 </td></tr>
|
pascal@208
|
300 </table>
|
pascal@208
|
301 EOT
|
pascal@208
|
302 }
|
pascal@208
|
303
|
pascal@208
|
304 select_old_slitaz()
|
pascal@208
|
305 {
|
pascal@208
|
306 cat <<EOT
|
pascal@208
|
307 <a name="partition"></a>
|
pascal@208
|
308 <h4></span>$(gettext "Existing SliTaz Partition")</h4>
|
pascal@208
|
309 <table>
|
pascal@208
|
310 <tr><td>
|
pascal@208
|
311 $(gettext "Partition in use:")
|
pascal@208
|
312 <select name="TGT_PARTITION">
|
pascal@208
|
313 EOT
|
pascal@208
|
314 # List partitions
|
pascal@208
|
315 if fdisk -l | grep -q ^/dev/ ; then
|
pascal@208
|
316 for i in `blkid | cut -d ":" -f 1`; do
|
pascal@208
|
317 echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo "selected")>$i</option>"
|
pascal@208
|
318 done
|
pascal@208
|
319 else
|
pascal@208
|
320 echo "<option value="">$(gettext "Not found")</option>"
|
pascal@208
|
321 fi
|
pascal@208
|
322 cat <<EOT
|
pascal@208
|
323 </select>
|
pascal@208
|
324 </td></tr>
|
pascal@208
|
325 </table>
|
pascal@208
|
326 EOT
|
pascal@208
|
327 }
|
pascal@208
|
328
|
pascal@208
|
329 select_home()
|
pascal@208
|
330 {
|
pascal@208
|
331 cat <<EOT
|
pascal@208
|
332 <a name="home"></a>
|
pascal@208
|
333 <h4>$(gettext "Home partition")</h4>
|
pascal@208
|
334 <input type="checkbox" name="HOME_SPLIT" value="yes" $([ -n "$TGT_HOME" ] && echo "checked") id="homepart" />
|
pascal@208
|
335 <label for="homepart">$(gettext "Use a separate partition for /home:")</label>
|
pascal@208
|
336 <select name="HOME_PART">
|
pascal@208
|
337 EOT
|
pascal@208
|
338 # List disk if plugged USB device
|
pascal@208
|
339 if fdisk -l | grep -q ^/dev/ ; then
|
pascal@208
|
340 for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
|
pascal@208
|
341 echo "<option value='$i' $([ "$i" == "$TGT_HOME" ] && echo "selected")>$i</option>"
|
pascal@208
|
342 done
|
pascal@208
|
343 else
|
pascal@208
|
344 echo "<option value="">$(gettext "Not found")</option>"
|
pascal@208
|
345 fi
|
pascal@208
|
346 cat <<EOT
|
pascal@208
|
347 </select>
|
pascal@208
|
348
|
pascal@208
|
349 <input type="checkbox" name="HOME_FMT" value="yes" $([ -n "$TGT_HOME_FS" ] && echo "checked") id="homefs" />
|
pascal@208
|
350 <label for="homefs">$(gettext "Format partition as:")</label>
|
pascal@208
|
351 <select name="HOME_FS">"
|
pascal@208
|
352 EOT
|
pascal@208
|
353 for i in $FS
|
pascal@208
|
354 do
|
pascal@208
|
355 echo "<option value='$i' $([ "$i" == "$TGT_HOME_FS" ] && echo "selected")>$i</option>"
|
pascal@208
|
356 done
|
pascal@208
|
357 echo "</select>"
|
pascal@208
|
358 }
|
pascal@208
|
359
|
pascal@208
|
360 select_hostname()
|
pascal@208
|
361 {
|
pascal@208
|
362 cat << EOT
|
pascal@208
|
363 <a name="hostname"></a>
|
pascal@208
|
364 <h4>$(gettext "Host")</h4>
|
pascal@208
|
365 $(gettext "Hostname:")
|
pascal@208
|
366 <input type="text" name="TGT_HOSTNAME" value="$TGT_HOSTNAME" placeholder="$(gettext "Name of your system")" />
|
pascal@208
|
367 EOT
|
pascal@208
|
368 }
|
pascal@208
|
369
|
pascal@208
|
370 select_root()
|
pascal@208
|
371 {
|
pascal@208
|
372 cat << EOT
|
pascal@208
|
373 <a name="root"></a>
|
pascal@208
|
374 <h4>$(gettext "Root")</h4>
|
pascal@208
|
375 $(gettext "Root passwd:")
|
pascal@208
|
376 <input type="text" name="TGT_ROOT_PWD" value="$TGT_ROOT_PWD" placeholder="$(gettext "Password of root")" />
|
pascal@208
|
377 EOT
|
pascal@208
|
378 }
|
pascal@208
|
379
|
pascal@208
|
380 select_user()
|
pascal@208
|
381 {
|
pascal@208
|
382 cat << EOT
|
pascal@208
|
383 <a name="user"></a>
|
pascal@208
|
384 <h4>$(gettext "User")</h4>
|
pascal@208
|
385 $(gettext "User login:")
|
pascal@208
|
386 <input type="text" name="TGT_USER" value="$TGT_USER" placeholder="$(gettext "Name of the first user")" />
|
pascal@208
|
387 $(gettext "User passwd:")
|
pascal@208
|
388 <input type="text" name="TGT_USER_PWD" value="$TGT_USER_PWD" placeholder="$(gettext "Password of the first user")" />
|
pascal@208
|
389 EOT
|
pascal@208
|
390 }
|
pascal@208
|
391
|
pascal@208
|
392 select_grub()
|
pascal@208
|
393 {
|
pascal@208
|
394 cat << EOT
|
pascal@208
|
395 <a name="grub"></a>
|
pascal@208
|
396 <h4>$(gettext "Grub")</h4>
|
pascal@208
|
397 <input type="checkbox" name="TGT_GRUB" value="yes" $([ "$TGT_GRUB" == "yes" ] && echo "checked") id="grub" />
|
pascal@208
|
398 <label for="grub">$(gettext "Install Grub bootloader")<br /></label>
|
pascal@208
|
399 <input type="checkbox" name="TGT_WINBOOT" value="auto" $([ -n "$TGT_WINBOOT" ] && echo "checked") id="dualboot" />
|
pascal@208
|
400 <label for="dualboot">$(gettext "Enable Windows Dual-Boot")</label>
|
pascal@208
|
401 EOT
|
pascal@208
|
402 }
|
pascal@208
|
403
|
pascal@208
|
404 moveto_page()
|
pascal@208
|
405 {
|
pascal@208
|
406 case $1 in
|
pascal@208
|
407 *)
|
pascal@208
|
408 page=home
|
pascal@208
|
409 title1=$(gettext "Back to Installer Start Page") ;;
|
pascal@208
|
410 esac
|
pascal@208
|
411 case $2 in
|
pascal@208
|
412 write|run)
|
pascal@208
|
413 title2=$(gettext "Proceed to SliTaz installation") ;;
|
pascal@208
|
414 reboot)
|
pascal@208
|
415 title2=$(gettext "Installation complete. You can now restart (reboot)") ;;
|
pascal@208
|
416 failed)
|
pascal@208
|
417 title2=$(gettext "Installation failed. See log") ;;
|
pascal@208
|
418 *)
|
pascal@208
|
419 page=home
|
pascal@208
|
420 title2=$(gettext "Back to Installer Start Page") ;;
|
pascal@208
|
421 esac
|
pascal@208
|
422 cat <<EOT
|
pascal@208
|
423 <script type="text/javascript">
|
pascal@208
|
424 function SubmitForm() {
|
pascal@208
|
425 var r=confirm("$(gettext "Do you really want to continue?")");
|
pascal@208
|
426 if (r==true)
|
pascal@208
|
427 {
|
pascal@208
|
428 document.ConfigForm.submit();
|
pascal@208
|
429 }
|
pascal@208
|
430 }
|
pascal@208
|
431 </script>
|
pascal@208
|
432 <hr />
|
pascal@208
|
433 <input type="hidden" name="page" value="$2" />
|
pascal@208
|
434 <a class="button" value="$1" href="$SCRIPT_NAME?page=$1" >$title1</a>
|
pascal@208
|
435 <a class="button" value="$2" onclick="SubmitForm()">$title2</a>
|
pascal@208
|
436 EOT
|
pascal@208
|
437 }
|
pascal@208
|
438
|
pascal@208
|
439 page_redirection()
|
pascal@208
|
440 {
|
pascal@208
|
441 cat <<EOT
|
pascal@208
|
442 <html>
|
pascal@208
|
443 <head>
|
pascal@208
|
444 <title>$(gettext "A web page that points a browser to a different page after 2 seconds")</title>
|
pascal@208
|
445 <meta http-equiv="refresh" content="0; URL=$SCRIPT_NAME?page=$1">
|
pascal@208
|
446 <meta name="keywords" content="automatic redirection">
|
pascal@208
|
447 </head>
|
pascal@208
|
448 <body>
|
paul@209
|
449 $(gettext "If your browser doesn't automatically redirect within a few seconds,
|
paul@209
|
450 you may want to go there manually")
|
pascal@208
|
451 <a href="$SCRIPT_NAME?page=$1">$1</a>
|
pascal@208
|
452 </body>
|
pascal@208
|
453 </html>
|
pascal@208
|
454 EOT
|
pascal@208
|
455 }
|
pascal@208
|
456
|
pascal@208
|
457 check_ressources()
|
pascal@208
|
458 {
|
pascal@208
|
459 local code
|
pascal@208
|
460 code=0
|
pascal@208
|
461 # Check tazinst
|
pascal@208
|
462 if ! tazinst usage | grep -q Usage: ; then
|
pascal@208
|
463 cat <<EOT
|
pascal@208
|
464 <h3>$(gettext "Tazinst Error")</h3>
|
pascal@208
|
465 <p><strong>tazinst</strong>, $(gettext "the lightweight SliTaz HDD installer
|
paul@209
|
466 is missing. Any installation can not be done without tazinst.")</p>
|
pascal@208
|
467 <p>$(gettext "Check tazinst' permissions, or reinstall the slitaz-tools package:")</p>
|
pascal@208
|
468 <code># tazpkg get-install slitaz-tools --forced</code>
|
pascal@208
|
469 EOT
|
pascal@208
|
470 code=1
|
pascal@208
|
471 else
|
pascal@208
|
472 # Check tazinst required version
|
pascal@208
|
473 v=$(tazinst version | tr -d '[:alpha:]')
|
pascal@208
|
474 r=$TAZINST_REQUIRED_VERSION
|
pascal@208
|
475 if ! (echo "$v" | awk -v r=$r '{v=$v+0}{ if (v < r) exit 1}') ; then
|
pascal@208
|
476 cat <<EOT
|
pascal@208
|
477 <h3>$(gettext "Tazinst Error")</h3>
|
pascal@208
|
478 <p><strong>tazinst</strong> ($v) $(gettext "is not at the required version ($r),
|
pascal@208
|
479 use tazinst in a xterm or reinstall the slitaz-tools package:")</p>
|
pascal@208
|
480 <code># tazpkg get-install slitaz-tools --forced</code>
|
pascal@208
|
481 EOT
|
pascal@208
|
482 code=1
|
pascal@208
|
483 fi
|
pascal@208
|
484 # Check setup file
|
pascal@208
|
485 if [ ! -e "$INSTFILE" ]; then
|
pascal@208
|
486 gettext "Creating setup file $INSTFILE."
|
pascal@208
|
487 tazinst new $INSTFILE
|
pascal@208
|
488 fi
|
pascal@208
|
489 if [ ! -e "$INSTFILE" ]; then
|
pascal@208
|
490 cat <<EOT
|
pascal@208
|
491 <h3>$(gettext "Setup File Error")</h3>
|
paul@209
|
492 <p>$(gettext "The setup file <strong>$INSTFILE</strong> doesn't exist.")</p>
|
pascal@208
|
493 EOT
|
pascal@208
|
494 code=1
|
pascal@208
|
495 else
|
pascal@208
|
496 if [ ! -r $INSTFILE ]; then
|
pascal@208
|
497 cat <<EOT
|
pascal@208
|
498 <h3>$(gettext "Setup File Error")</h3>
|
pascal@208
|
499 <p>$(gettext "The setup file <strong>$INSTFILE</strong> is not readable.
|
pascal@208
|
500 Check permissions and ownership.")</p>
|
pascal@208
|
501 EOT
|
pascal@208
|
502 code=1
|
pascal@208
|
503 fi
|
pascal@208
|
504 fi
|
pascal@208
|
505 fi
|
pascal@208
|
506 return $code
|
pascal@208
|
507 }
|
pascal@208
|
508
|
pascal@208
|
509 run_tazinst()
|
pascal@208
|
510 {
|
pascal@208
|
511 echo "<h4>$(gettext "Proceeding: ()")</h4>"
|
pascal@208
|
512 gettext "Please wait until processing is complete"
|
pascal@208
|
513 table_start
|
pascal@208
|
514 tazinst $(GET INST_ACTION) $INSTFILE | \
|
pascal@208
|
515 awk '{print "<tr><td><tt>" $0 "</tt></td></tr>"}'
|
pascal@208
|
516 table_end
|
pascal@208
|
517 return $(grep -c "cancelled on error" $INSTFILE)
|
pascal@208
|
518 }
|
pascal@208
|
519
|
pascal@208
|
520 tazinst_log()
|
pascal@208
|
521 {
|
pascal@208
|
522 echo "<pre>"
|
pascal@208
|
523 tazinst log
|
pascal@208
|
524 echo "</pre>"
|
pascal@208
|
525 }
|
pascal@208
|
526
|
pascal@208
|
527 scan_mkfs()
|
pascal@208
|
528 {
|
pascal@208
|
529 for path in /bin /sbin /usr/bin /usr/sbin
|
pascal@208
|
530 do
|
pascal@208
|
531 [ -e $path/mkfs.btrfs ] && FS=btrfs
|
pascal@208
|
532 [ -e $path/mkfs.cramfs ] && FS="$FS cramfs"
|
pascal@208
|
533 [ -e $path/mkfs.ext2 ] && FS="$FS ext2"
|
pascal@208
|
534 [ -e $path/mkfs.ext3 ] && FS="$FS ext3"
|
pascal@208
|
535 [ -e $path/mkfs.ext4 ] && FS="$FS ext4"
|
pascal@208
|
536 [ -e $path/mkfs.jfs ] && FS="$FS jfs"
|
pascal@208
|
537 [ -e $path/mkfs.minix ] && FS="$FS minix"
|
pascal@208
|
538 [ -e $path/mkfs.reiserfs ] && FS="$FS reiserfs"
|
pascal@208
|
539 [ -e $path/mkfs.xfs ] && FS="$FS xfs"
|
pascal@208
|
540 done
|
pascal@208
|
541 }
|
pascal@208
|
542
|
pascal@208
|
543 form_start()
|
pascal@208
|
544 {
|
pascal@208
|
545 cat <<EOT
|
pascal@208
|
546 <form name="ConfigForm" method="get" action="$SCRIPT_NAME">
|
pascal@208
|
547 EOT
|
pascal@208
|
548 }
|
pascal@208
|
549
|
pascal@208
|
550 form_end()
|
pascal@208
|
551 {
|
pascal@208
|
552 echo "</form>"
|
pascal@208
|
553 }
|
pascal@208
|
554
|
pascal@208
|
555 #
|
pascal@208
|
556 # Main
|
pascal@208
|
557 #
|
pascal@208
|
558
|
pascal@208
|
559 case "$(GET page)" in
|
pascal@208
|
560 gparted)
|
pascal@208
|
561 /usr/sbin/gparted
|
pascal@208
|
562 xhtml_header
|
pascal@208
|
563 page_redirection home
|
pascal@208
|
564 ;;
|
pascal@208
|
565 install)
|
pascal@208
|
566 read_setup
|
pascal@208
|
567 xhtml_header
|
pascal@208
|
568 form_start
|
pascal@208
|
569 display_action install
|
pankso@253
|
570 # The config file is generic and will be created now.
|
pankso@253
|
571 # Should be done after: moveto_page home write ?
|
pankso@253
|
572 #check_setup
|
pascal@208
|
573 select_source
|
pascal@208
|
574 select_partition
|
pascal@208
|
575 select_home
|
pascal@208
|
576 select_hostname
|
pascal@208
|
577 select_root
|
pascal@208
|
578 select_user
|
pascal@208
|
579 select_grub
|
pascal@208
|
580 moveto_page home write
|
pascal@208
|
581 form_end
|
pascal@208
|
582 ;;
|
pascal@208
|
583 upgrade)
|
pascal@208
|
584 read_setup
|
pascal@208
|
585 xhtml_header
|
pascal@208
|
586 form_start
|
pascal@208
|
587 display_action upgrade
|
pascal@208
|
588 check_setup
|
pascal@208
|
589 select_source
|
pascal@208
|
590 select_old_slitaz
|
pascal@208
|
591 select_grub
|
pascal@208
|
592 moveto_page home write
|
pascal@208
|
593 form_end
|
pascal@208
|
594 ;;
|
pascal@208
|
595 write)
|
pascal@208
|
596 write_setup
|
pascal@208
|
597 xhtml_header
|
pascal@208
|
598 if ! (tazinst check $INSTFILE); then
|
pascal@208
|
599 page_redirection $(GET INST_ACTION)
|
pascal@208
|
600 else
|
pascal@208
|
601 read_setup
|
pascal@208
|
602 form_start
|
pascal@208
|
603 display_action $(GET INST_ACTION)
|
pascal@208
|
604 if run_tazinst; then
|
pascal@208
|
605 moveto_page home reboot
|
pascal@208
|
606 else
|
pascal@208
|
607 moveto_page home failed
|
pascal@208
|
608 fi
|
pascal@208
|
609 form_end
|
pascal@208
|
610 fi
|
pascal@208
|
611 ;;
|
pascal@208
|
612 reboot)
|
pascal@208
|
613 reboot ;;
|
pascal@208
|
614 home)
|
pascal@208
|
615 xhtml_header
|
pascal@208
|
616 select_action
|
pascal@208
|
617 select_gparted
|
pascal@208
|
618 select_install
|
pascal@208
|
619 select_upgrade
|
pascal@208
|
620 ;;
|
pascal@208
|
621 failed)
|
pascal@208
|
622 xhtml_header
|
pascal@208
|
623 display_log
|
pascal@208
|
624 ;;
|
domcox@234
|
625 menu_install)
|
domcox@234
|
626 xhtml_header
|
domcox@234
|
627 if check_ressources; then
|
domcox@234
|
628 select_action
|
domcox@234
|
629 select_gparted
|
domcox@234
|
630 select_install
|
domcox@234
|
631 fi
|
domcox@234
|
632 ;;
|
domcox@234
|
633 menu_upgrade)
|
domcox@234
|
634 xhtml_header
|
domcox@234
|
635 if check_ressources; then
|
domcox@234
|
636 select_action
|
domcox@234
|
637 select_upgrade
|
domcox@234
|
638 fi
|
domcox@234
|
639 ;;
|
pascal@208
|
640 *)
|
pascal@208
|
641 xhtml_header
|
pascal@208
|
642 if check_ressources; then
|
pascal@208
|
643 page_redirection home
|
pascal@208
|
644 fi
|
pascal@208
|
645 ;;
|
pascal@208
|
646 esac
|
pascal@208
|
647
|
pascal@208
|
648 xhtml_footer
|
pascal@208
|
649
|
pascal@208
|
650 exit 0
|