tazpanel view installer.cgi @ rev 303

3 weeks forging ;) Some bugs fixed, maybe all i18n improved (please, recheck 'po's!), couple of new features added... Enjoy!
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri May 04 13:00:43 2012 +0300 (2012-05-04)
parents e1b450c92890
children 42367a53cf50
line source
1 #!/bin/sh
2 #
3 # Main CGI interface for Tazinst, the SliTaz installer.
4 #
5 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
6 #
7 # Authors : Dominique Corbex <domcox@slitaz.org>
8 #
10 VERSION=0.30
12 # Common functions from libtazpanel
13 . lib/libtazpanel
14 header
15 get_config
17 # Include gettext helper script.
18 . /usr/bin/gettext.sh
20 # Export package name for gettext.
21 #TEXTDOMAIN='installer'
22 #export TEXTDOMAIN
24 TITLE=$(gettext 'TazPanel - Installer')
26 # Tazinst required version
27 TAZINST_REQUIRED_VERSION="3.3"
29 # Tazinst setup file
30 INSTFILE=/var/lib/tazinst.conf
33 write_setup()
34 {
35 if [ -e "$INSTFILE" ]; then
36 # Install type
37 INST_TYPE=$(GET INST_TYPE)
38 # Source File
39 case "$INST_TYPE" in
40 usb)
41 SRC_FILE=$(GET SRC_USB) ;;
42 iso)
43 SRC_FILE=$(GET SRC_ISO) ;;
44 web)
45 SRC_FILE=$(GET SRC_WEB) ;;
46 esac
47 SRC_FILE=$(echo "$SRC_FILE" | sed 's/\//\\\//'g)
48 [ -n $(GET URL) ] && SRC_WEB=$(GET URL)
49 # Main Partition
50 TGT_PARTITION=$(echo "$(GET TGT_PARTITION)" | sed 's/\//\\\//'g)
51 [ -n "$(GET MAIN_FMT)" ] && TGT_FS=$(GET MAIN_FS) || TGT_FS=""
52 # Home Partition
53 if [ -n "$(GET HOME_SELECT)" ] ; then
54 TGT_HOME=$(echo "$(GET TGT_HOME)" | sed 's/\//\\\//'g)
55 [ -n "$(GET HOME_FMT)" ] && TGT_HOME_FS=$(GET HOME_FS) || TGT_HOME_FS=""
56 else
57 TGT_HOME=""
58 TGT_HOME_FS=""
59 fi
60 # Hostname
61 TGT_HOSTNAME=$(GET TGT_HOSTNAME)
62 # Root pwd
63 TGT_ROOT_PWD=$(GET TGT_ROOT_PWD)
64 # User Login
65 TGT_USER=$(GET TGT_USER)
66 # User Pwd
67 TGT_USER_PWD=$(GET TGT_USER_PWD)
68 # Grub
69 TGT_GRUB=$(GET TGT_GRUB)
70 [ "$TGT_GRUB" == "yes" ] || TGT_GRUB=no
71 # Win Dual-Boot
72 TGT_WINBOOT=$(GET TGT_WINBOOT)
74 # Save changes to INSTFILE
75 sed -i s/"^INST_TYPE=.*"/"INST_TYPE=\"$INST_TYPE\"/" $INSTFILE
76 sed -i s/"^SRC_FILE=.*"/"SRC_FILE=\"$SRC_FILE\"/" $INSTFILE
77 sed -i s/"^TGT_PARTITION=.*"/"TGT_PARTITION=\"$TGT_PARTITION\"/" $INSTFILE
78 sed -i s/"^TGT_FS=.*"/"TGT_FS=\"$TGT_FS\"/" $INSTFILE
79 sed -i s/"^TGT_HOME=.*"/"TGT_HOME=\"$TGT_HOME\"/" $INSTFILE
80 sed -i s/"^TGT_HOME_FS=.*"/"TGT_HOME_FS=\"$TGT_HOME_FS\"/" $INSTFILE
81 sed -i s/"^TGT_HOSTNAME=.*"/"TGT_HOSTNAME=\"$TGT_HOSTNAME\"/" $INSTFILE
82 sed -i s/"^TGT_ROOT_PWD=.*"/"TGT_ROOT_PWD=\"$TGT_ROOT_PWD\"/" $INSTFILE
83 sed -i s/"^TGT_USER=.*"/"TGT_USER=\"$TGT_USER\"/" $INSTFILE
84 sed -i s/"^TGT_USER_PWD=.*"/"TGT_USER_PWD=\"$TGT_USER_PWD\"/" $INSTFILE
85 sed -i s/"^TGT_GRUB=.*"/"TGT_GRUB=\"$TGT_GRUB\"/" $INSTFILE
86 sed -i s/"^TGT_WINBOOT=.*"/"TGT_WINBOOT=\"$TGT_WINBOOT\"/" $INSTFILE
87 fi
88 }
90 read_setup()
91 {
92 # various checks on setup file
93 if [ -e "$INSTFILE" ]; then
94 # validity check + reformat output
95 tazinst check $INSTFILE | awk '
96 BEGIN{
97 fmt1="<span class=\"msg-nok\">"
98 fmt2="<br /></span>"
99 OFS=""
100 }
101 {
102 # make html compliant
103 str=$0
104 gsub(/\[1m/,"",str)
105 gsub(/\[0m/,"",str)
106 gsub(/\s/,"\\&nbsp;",str)
107 gsub(/</,"\\&lt",str)
108 gsub(/>/,"\\&gt",str)
109 a[i++]=str
110 } END {
111 {print fmt1,a[i-1],fmt2}
112 {for (j=0; j<i-1;) print fmt1,substr(a[j++],3),fmt2}
113 }'
114 else
115 # no setup file found: creating
116 eval_gettext 'Creating setup file $INSTFILE.'
117 tazinst new $INSTFILE
118 if [ ! -e "$INSTFILE" ]; then
119 cat <<EOT
120 <span class="msg-nok">$(gettext 'Setup File Error')<br />
121 $(eval_gettext "The setup file <strong>\$INSTFILE</strong> doesn't \
122 exist.")</span><br />
123 EOT
124 else
125 if [ ! -r $INSTFILE ]; then
126 cat <<EOT
127 <span class="msg-nok">$(gettext 'Setup File Error')<br />
128 $(eval_gettext "The setup file <strong>$INSTFILE</strong> is not readable. \
129 Check permissions and ownership.")</span><br />
130 EOT
131 fi
132 fi
133 fi
134 # read setup file
135 . $INSTFILE
136 }
138 select_action()
139 {
140 cat <<EOT
141 <div id="wrapper">
142 <h2>$(gettext 'SliTaz Installer')</h2>
144 <p>$(gettext "The SliTaz Installer installs or upgrades SliTaz to a hard disk \
145 drive from a device like a Live-CD or LiveUSB key, from a SliTaz ISO file, or \
146 from the web by downloading an ISO file.")</p>
147 </div>
148 EOT
149 }
151 select_install()
152 {
153 cat <<EOT
154 <div class="box">
155 <h4>$(gettext 'Install')</h4>
157 <p>$(gettext "Install SliTaz on a partition of your hard disk drive. If you \
158 decide to format your partition, all data will be lost. If you do not format, \
159 all data except for any existing /home directory will be removed, the home \
160 directory will be kept as is.")</p>
162 <p>$(gettext "Before installation, you may need to create or resize partitions \
163 on your hard disk drive in order to make space for SliTaz GNU/Linux. You can \
164 graphically manage your partitions with Gparted")</p>
165 </div>
166 <p><a class="button" href="$SCRIPT_NAME?page=partitioning">$(gettext "Install \
167 SliTaz")</a>
168 EOT
169 }
171 select_upgrade()
172 {
173 cat <<EOT
174 <div class="box">
175 <h4>$(gettext 'Upgrade')</h4>
177 <p>$(gettext "Upgrade an already installed SliTaz system on your hard disk \
178 drive. Your /home /etc /var/www directories will be kept, all other \
179 directories will be removed. Any additional packages added to your old Slitaz \
180 system will be updated as long you have an active internet connection.")</p>
181 </div>
182 <p><a class="button" href="$SCRIPT_NAME?page=upgrade">$(gettext "Upgrade \
183 SliTaz")</a></p>
184 EOT
185 }
187 select_gparted()
188 {
189 cat <<EOT
190 <h4>$(gettext 'Partitioning')</h4>
191 <div class="box">
193 <p>$(gettext "On most used systems, the hard drive is already dedicated to \
194 partitions for Windows<sup>&trade;</sup>, or Linux, or another operating \
195 system. You'll need to resize these partitions in order to make space for \
196 SliTaz GNU/Linux. SliTaz will co-exist with other operating systems already \
197 installed on your hard drive.")</p>
199 <p>$(gettext "The amount of space needed depends on how much software you plan \
200 to install and how much space you require for users. It's conceivable that you \
201 could run a minimal SliTaz system in 300 megs or less, but 2 gigs is indeed \
202 more comfy.")</p>
204 <p>$(gettext "A separate home partition, and a partition that will be used as \
205 Linux swap space may be created if needed. Slitaz detects and uses swap \
206 partitions automatically.")</p>
208 </div>
210 <div class="box">
212 <p>$(gettext "You can graphically manage your partitions with Gparted. GParted \
213 is a partition editor for graphically managing your disk partitions. Gparted \
214 allows you to create, destroy, resize and copy partitions without data loss.")</p>
216 <p>$(gettext "Gparted supports ext2, ext3, ext4, linux swap, ntfs and fat32 \
217 filesystems right out of the box. Support for xjs, jfs, hfs and other \
218 filesystems is available as well but you first need to add drivers for these \
219 filesystems by installing the related packages xfsprogs, jfsutils, linux-hfs \
220 and so on.")</p>
221 </div>
223 <a class="button" href="$SCRIPT_NAME?page=gparted">$(gettext 'Execute Gparted')</a>
225 <h5>$(gettext 'Continue installation')</h5>
227 <p>$(gettext "Once you've made room for SliTaz on your drive, you should be \
228 able to continue installation.")
230 <hr />
231 <a class="button" value="$1" href="$SCRIPT_NAME?page=home" >
232 $(gettext 'Back to Installer Start Page')</a>
233 <a class="button" value="$2" href="$SCRIPT_NAME?page=install">
234 $(gettext 'Continue Installation')</a>
235 EOT
236 }
238 display_action()
239 {
240 case $1 in
241 install)
242 cat << EOT
243 <div id="wrapper">
244 <h3>$(gettext 'Install SliTaz')</h3>
246 <p>$(gettext "You're going to install SliTaz on a partition of your hard disk \
247 drive. If you decide to format your HDD, all data will be lost. If you do not \
248 format, all data except for any existing /home directory will be removed, the \
249 home directory will be kept as is.")<p>
250 </div>
251 <input type="hidden" name="INST_ACTION" value="$1">
252 EOT
253 ;;
254 upgrade)
255 cat << EOT
256 <div id="wrapper">
257 <h2>$(gettext 'Upgrade SliTaz')</h2>
259 <p>$(gettext "You're going to upgrade an already installed SliTaz system on \
260 your hard disk drive. Your /home /etc /var/www directories will be kept, all \
261 other directories will be removed. Any additional packages added to your old \
262 Slitaz system will be updated as long you have an active internet connection.")<p>
263 </div>
264 <input type="hidden" name="INST_ACTION" value="$1">
265 EOT
266 ;;
267 esac
268 }
270 select_source()
271 {
272 cat <<EOT
273 <h4 id="source">$(gettext 'Slitaz source media')</h4>
275 <div class="box">
276 <input type="radio" name="INST_TYPE" value="cdrom" $([ "$INST_TYPE" == "cdrom" ] && echo "checked") id="cdrom" />
277 <label for="cdrom">$(gettext 'LiveCD')</label>
278 <br />
279 <input type="radio" name="INST_TYPE" value="usb" $([ "$INST_TYPE" == "usb" ] && echo "checked") id="usb" />
280 <label for="usb">$(gettext 'LiveUSB:')
281 <select name="SRC_USB">
282 EOT
283 # List disks if plugged USB device
284 usb=0
285 if [ -d /proc/scsi/usb-storage ]; then
286 for DEV in /sys/block/sd* ; do
287 if readlink $DEV | grep -q usb; then
288 DEV=$(basename $DEV)
289 if [ -d /sys/block/${DEV}/${DEV}1 ]; then
290 for i in $(fdisk -l /dev/$DEV | awk '/^\/dev/ {printf "%s ", $1}') ; do
291 echo "<option value='$i' $([ "$i" == "$SRC_FILE" ] && echo 'selected') >$i</option>"
292 usb=$usb+1
293 done
294 fi
295 fi
296 done
297 fi
298 if [ $usb -lt 1 ]; then
299 echo "<option value="">$(gettext 'Not found')</option>"
300 fi
301 cat << EOT
302 </select>
303 </label>
304 <br />
305 <input type="radio" name="INST_TYPE" value="iso" $([ "$INST_TYPE" == "iso" ] && echo "checked") id="iso" />
306 <label for="iso">$(gettext 'ISO file:')</label>
307 <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')" />
308 <br />
309 <input type="radio" name="INST_TYPE" value="web" $([ "$INST_TYPE" == "web" ] && echo "checked") id="web" />
310 <label for="web">$(gettext 'Web:')
311 <a class="button" onclick="document.forms['ConfigForm'].url.value = '$(tazinst showurl stable)'; return true;">$(gettext 'Stable')</a>
312 <a class="button" onclick="document.forms['ConfigForm'].url.value = '$(tazinst showurl cooking)'; return true;">$(gettext 'Cooking')</a>
314 $(gettext 'URL:')
315 <input id="url" type="url" size="55" name="SRC_WEB" $([ "$INST_TYPE" == "web" ] && echo -e "value=\"$SRC_FILE\"") placeholder="$(gettext 'Full url to an ISO image file')" />
316 </label>
317 </div>
318 EOT
319 }
321 select_hdd()
322 {
323 cat <<EOT
324 <h4 id="hdd">$(gettext 'Hard Disk Drive')</h4>
325 EOT
326 }
328 select_partition()
329 {
330 cat <<EOT
331 <div class="box">
332 <a name="partition"></a>
333 $(gettext 'Install Slitaz to partition:')
334 <select name="TGT_PARTITION">
335 EOT
336 # List partitions
337 if fdisk -l | grep -q ^/dev/ ; then
338 echo "<option value="">$(gettext 'None')</option>"
339 for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
340 echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo 'selected')>$i</option>"
341 done
342 else
343 echo "<option value="">$(gettext 'Not found')</option>"
344 fi
345 cat << EOT
346 </select>
347 <br />
348 <input type="checkbox" name="MAIN_FMT" value="yes" $([ -n "$TGT_FS" ] && echo "checked") id="mainfs" />
349 <label for="mainfs">$(gettext 'Format partition as:')</label>
350 <select name="MAIN_FS">
351 EOT
352 scan_mkfs
353 for i in $FS
354 do
355 echo "<option value='$i' $([ "$i" == "$TGT_FS" ] && echo 'selected')>$i</option>"
356 done
357 cat <<EOT
358 </select>
359 </div>
360 EOT
361 }
363 select_old_slitaz()
364 {
365 cat <<EOT
366 <div class="box">
367 <a name="partition"></a>
368 $(gettext 'Existing SliTaz partition to upgrade:')
369 <select name="TGT_PARTITION">
370 EOT
371 # List partitions
372 if fdisk -l | grep -q ^/dev/ ; then
373 echo "<option value="">$(gettext 'None')</option>"
374 for i in $(blkid | cut -d ":" -f 1); do
375 echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo 'selected')>$i</option>"
376 done
377 else
378 echo "<option value="">$(gettext 'Not found')</option>"
379 fi
380 cat <<EOT
381 </select>
382 </div>
383 EOT
384 }
386 select_options()
387 {
388 cat <<EOT
389 <h4 id="options">$(gettext 'Options')</h4>
390 EOT
391 }
393 select_home()
394 {
395 cat <<EOT
396 <div>
397 <h5 id="home">$(gettext 'home partition')</h5>
399 <input type="checkbox" name="HOME_SELECT" value="yes" $([ -n "$TGT_HOME" ] && echo "checked") id="homepart" />
400 <label for="homepart">$(gettext 'Use a separate partition for /home:')</label>
401 <select name="TGT_HOME">
402 EOT
403 # List disk if plugged USB device
404 if fdisk -l | grep -q ^/dev/ ; then
405 echo "<option value="">$(gettext 'None')</option>"
406 for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
407 echo "<option value='$i' $([ "$i" == "$TGT_HOME" ] && echo 'selected')>$i</option>"
408 done
409 else
410 echo "<option value="">$(gettext 'Not found')</option>"
411 fi
412 cat <<EOT
413 </select>
415 <input type="checkbox" name="HOME_FMT" value="yes" $([ -n "$TGT_HOME_FS" ] && echo "checked") id="homefs" />
416 <label for="homefs">$(gettext 'Format partition as:')</label>
417 <select name="HOME_FS">"
418 EOT
419 for i in $FS
420 do
421 echo "<option value='$i' $([ "$i" == "$TGT_HOME_FS" ] && echo 'selected')>$i</option>"
422 done
423 cat <<EOT
424 </select>
425 </div>
426 EOT
427 }
429 select_hostname()
430 {
431 cat << EOT
432 <div>
433 <h5 id="hostname">$(gettext 'Hostname')</h5>
435 $(gettext 'Set Hostname to:')
436 <input type="text" id="hostname" name="TGT_HOSTNAME" value="$TGT_HOSTNAME" placeholder="$(gettext 'Name of your system')" onkeyup="checkLogin('hostname','msgHostname'); return false;" />
437 <span id="msgHostname"></span>
438 </div>
439 EOT
440 }
442 select_root()
443 {
444 cat << EOT
445 <div class="box2">
446 <h5 id="root">$(gettext 'Root')</h5>
448 $(gettext 'Root passwd:')
449 <input type="password" id="rootPwd1" name="TGT_ROOT_PWD" value="$TGT_ROOT_PWD" placeholder="$(gettext 'Password of root')" onkeyup="checkPwd('rootPwd1','rootPwd2','msgRootPwd'); return false;" />
451 $(gettext 'Confirm password:')
452 <input type="password" id="rootPwd2" value="$TGT_ROOT_PWD" placeholder="$(gettext 'Password of root')" onkeyup="checkPwd('rootPwd1','rootPwd2','msgRootPwd'); return false;" />
454 <span id="msgRootPwd"></span>
455 </div>
456 EOT
457 }
459 select_user()
460 {
461 cat << EOT
462 <div class="box2">
463 <h5 id="user">$(gettext 'User')</h5>
465 $(gettext 'User login:')
466 <input type="text" id="user" name="TGT_USER" value="$TGT_USER" placeholder="$(gettext 'Name of the first user')" onkeyup="checkLogin('user','msgUser'); return false;" />
467 <span id="msgUser"></span>
468 <br /><br />
470 $(gettext 'User passwd:')
471 <input type="password" id="userPwd1" name="TGT_USER_PWD" value="$TGT_USER_PWD" placeholder="$(gettext 'Password of the first user')" onkeyup="checkPwd('userPwd1','userPwd2','msgUserPwd'); return false;" />
473 $(gettext 'Confirm password:')
474 <input class="confirm" type="password" id="userPwd2" value="$TGT_USER_PWD" placeholder="$(gettext 'Password of the first user')" onkeyup="checkPwd('userPwd1','userPwd2','msgUserPwd'); return false;" />
475 <span id="msgUserPwd"></span>
476 </div>
477 EOT
478 }
480 select_grub()
481 {
482 cat << EOT
483 <div>
484 <h5 id="grub">$(gettext 'Grub')</h5>
486 <input type="checkbox" name="TGT_GRUB" value="yes" $([ "$TGT_GRUB" == "yes" ] && echo "checked") id="grub" />
487 <label for="grub">$(gettext "Install Grub bootloader. Usually you should \
488 answer yes, unless you want to install grub by hand yourself.")<br /></label>
489 <input type="checkbox" name="TGT_WINBOOT" value="auto" $([ -n "$TGT_WINBOOT" ] && echo "checked") id="dualboot" />
490 <label for="dualboot">$(gettext 'Enable Windows Dual-Boot.')</label>
491 </div>
492 EOT
493 }
495 moveto_page()
496 {
497 case $1 in
498 partitioning)
499 title1=$(gettext 'Back to partitioning') ;;
500 *)
501 page=home
502 title1=$(gettext 'Back to Installer Start Page') ;;
503 esac
504 case $2 in
505 write|run)
506 title2=$(gettext 'Proceed to SliTaz installation') ;;
507 reboot)
508 title2=$(gettext 'Installation complete. You can now restart (reboot)') ;;
509 failed)
510 title2=$(gettext 'Installation failed. See log') ;;
511 *)
512 page=home
513 title2=$(gettext 'Back to Installer Start Page') ;;
514 esac
515 cat <<EOT
516 <hr />
517 <input type="hidden" name="page" value="$2" />
518 <a class="button" value="$1" href="$SCRIPT_NAME?page=$1" >$title1</a>
519 <input type="submit" value="$title2">
520 EOT
521 }
523 page_redirection()
524 {
525 cat <<EOT
526 <!DOCTYPE html>
527 <html>
528 <head>
529 <meta charset="utf-8">
530 <title>$(gettext "A web page that points a browser to a different page after \
531 2 seconds")</title>
532 <meta http-equiv="refresh" content="0; URL=$SCRIPT_NAME?page=$1">
533 <meta name="keywords" content="automatic redirection">
534 </head>
535 <body>
536 <p>$(gettext "If your browser doesn't automatically redirect within a few \
537 seconds, you may want to go there manually")</p>
538 <p><a href="$SCRIPT_NAME?page=$1">$1</a></p>
539 </body>
540 </html>
541 EOT
542 }
544 check_ressources()
545 {
546 local code
547 code=0
548 # Check tazinst
549 if ! [ -x /usr/sbin/tazinst ] ; then
550 cat <<EOT
551 <h3>$(gettext 'Tazinst Error')</h3>
552 <p>$(gettext "<strong>tazinst</strong>, the lightweight SliTaz HDD installer \
553 is missing. Any installation can not be done without tazinst.")</p>
555 <p>$(gettext "Check tazinst' permissions, or reinstall the slitaz-tools \
556 package:")</p>
557 <code># tazpkg get-install slitaz-tools --forced</code>
558 EOT
559 code=1
560 else
561 # Check tazinst required version
562 v=$(tazinst version | tr -d '[:alpha:]')
563 r=$TAZINST_REQUIRED_VERSION
564 if ! (echo "$v" | awk -v r=$r '{v=$v+0}{ if (v < r) exit 1}') ; then
565 cat <<EOT
566 <h3>$(gettext 'Tazinst Error')</h3>
568 <p>$(eval_gettext "<strong>tazinst</strong> ($v) is not at the required \
569 version ($r), use tazinst in a xterm or reinstall the slitaz-tools package:")</p>
570 <code># tazpkg get-install slitaz-tools --forced</code>
571 EOT
572 code=1
573 fi
574 fi
575 return $code
576 }
578 run_tazinst()
579 {
580 cat << EOT
581 <h4>$(gettext 'Proceeding: ()')</h4>
582 <p>$(gettext 'Please wait until processing is complete')</p>
583 EOT
584 table_start
585 tazinst $(GET INST_ACTION) $INSTFILE | \
586 awk '{print "<tr><td><tt>" $0 "</tt></td></tr>"}'
587 table_end
588 echo "<p>$(gettext 'Completed.')</p>"
589 return $(grep -c "cancelled on error" $INSTFILE)
590 }
592 tazinst_log()
593 {
594 echo "<pre>$(tazinst log)</pre>"
595 }
597 scan_mkfs()
598 {
599 for path in /bin /sbin /usr/bin /usr/sbin
600 do
601 [ -e $path/mkfs.btrfs ] && FS=btrfs
602 [ -e $path/mkfs.cramfs ] && FS="$FS cramfs"
603 [ -e $path/mkfs.ext2 ] && FS="$FS ext2"
604 [ -e $path/mkfs.ext3 ] && FS="$FS ext3"
605 [ -e $path/mkfs.ext4 ] && FS="$FS ext4"
606 [ -e $path/mkfs.jfs ] && FS="$FS jfs"
607 [ -e $path/mkfs.minix ] && FS="$FS minix"
608 [ -e $path/mkfs.reiserfs ] && FS="$FS reiserfs"
609 [ -e $path/mkfs.xfs ] && FS="$FS xfs"
610 done
611 }
613 form_start()
614 {
615 cat <<EOT
616 <script src="lib/user.js"></script>
617 <script type="text/javascript">
618 function Validate(page) {
619 if (page == "install") {
620 // hostname
621 if (false == checkLogin('hostname','msgHostname')) {
622 alert("$(gettext 'Hostname error')");
623 return false;
624 // root pwd
625 } else if (false == checkPwd('rootPwd1','rootPwd2','msgRootPwd')) {
626 alert("$(gettext 'Root password error')");
627 return false;
628 // user
629 } else if (false == checkLogin('user','msgUser')) {
630 alert("$(gettext 'User login error')");
631 return false;
632 // user pwd
633 } else if (false == checkPwd('userPwd1','userPwd2','msgUserPwd')) {
634 alert("$(gettext 'User password error')");
635 return false;
636 } else {
637 var r=confirm("$(gettext 'Do you really want to continue?')");
638 if (r==true)
639 {
640 document.ConfigForm.submit();
641 } else {
642 return false;
643 }
644 }
645 } else if (page == "write") {
646 return true;
647 } else {
648 var r=confirm("$(gettext 'Do you really want to continue?')");
649 if (r==true)
650 {
651 document.ConfigForm.submit();
652 } else {
653 return false;
654 }
655 }
656 }
657 </script>
658 <form name="ConfigForm" method="get" onsubmit="return Validate('$1')" action="$SCRIPT_NAME">
659 EOT
660 }
662 form_end()
663 {
664 echo "</form>"
665 }
667 #
668 # Main
669 #
671 case "$(GET page)" in
672 home)
673 xhtml_header
674 select_action
675 select_install
676 select_upgrade
677 ;;
678 partitioning)
679 xhtml_header
680 display_action install
681 select_gparted
682 ;;
683 gparted)
684 su - -c "exec env DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' /usr/sbin/gparted"
685 xhtml_header
686 page_redirection partitioning
687 ;;
688 install)
689 xhtml_header
690 form_start install
691 display_action install
692 read_setup
693 select_source
694 select_hdd
695 select_partition
696 select_options
697 select_home
698 select_hostname
699 select_root
700 select_user
701 select_grub
702 moveto_page partitioning write
703 form_end
704 ;;
705 upgrade)
706 xhtml_header
707 form_start upgrade
708 display_action upgrade
709 read_setup
710 select_source
711 select_hdd
712 select_old_slitaz
713 select_options
714 select_grub
715 moveto_page home write
716 form_end
717 ;;
718 write)
719 write_setup
720 xhtml_header
721 if ! (tazinst check $INSTFILE); then
722 page_redirection $(GET INST_ACTION)
723 else
724 read_setup
725 form_start write
726 display_action $(GET INST_ACTION)
727 if run_tazinst; then
728 moveto_page home reboot
729 else
730 moveto_page home failed
731 fi
732 form_end
733 fi
734 ;;
735 reboot)
736 reboot ;;
737 failed)
738 xhtml_header
739 display_log
740 ;;
741 menu_install)
742 xhtml_header
743 if check_ressources; then
744 page_redirection partitioning
745 fi
746 ;;
747 menu_upgrade)
748 xhtml_header
749 if check_ressources; then
750 page_redirection upgrade
751 fi
752 ;;
753 *)
754 xhtml_header
755 if check_ressources; then
756 page_redirection home
757 fi
758 ;;
759 esac
761 xhtml_footer
763 exit 0