tazpanel view installer.cgi @ rev 346
hardware.cgi: add menu shortcut
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Feb 02 14:49:17 2013 +0100 (2013-02-02) |
parents | a66d70e402b9 |
children |
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/,"\\ ",str)
107 gsub(/</,"\\<",str)
108 gsub(/>/,"\\>",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 <section>
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 (note the home \
160 directory contents 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>
166 <a class="button" href="$SCRIPT_NAME?page=partitioning">$(gettext "Install \
167 SliTaz") <img src="$IMAGES/go-next.png" /></a>
168 </section>
169 EOT
170 }
172 select_upgrade()
173 {
174 cat <<EOT
175 <section>
176 <h4>$(gettext 'Upgrade')</h4>
178 <p>$(gettext "Upgrade an already installed SliTaz system on your hard disk \
179 drive. Your /home /etc /var/www directories will be kept, all other \
180 directories will be removed. Any additional packages added to your old Slitaz \
181 system will be updated as long you have an active internet connection.")</p>
183 <a class="button" href="$SCRIPT_NAME?page=upgrade">$(gettext "Upgrade \
184 SliTaz") <img src="$IMAGES/go-next.png" /></a>
185 </section>
186 EOT
187 }
189 select_gparted()
190 {
191 cat <<EOT
192 <h4>$(gettext 'Partitioning')</h4>
193 <div class="box">
195 <p>$(gettext "On most used systems, the hard drive is already dedicated to \
196 partitions for Windows<sup>™</sup>, or Linux, or another operating \
197 system. You'll need to resize these partitions in order to make space for \
198 SliTaz GNU/Linux. SliTaz will co-exist with other operating systems already \
199 installed on your hard drive.")</p>
201 <p>$(gettext "The amount of space needed depends on how much software you plan \
202 to install and how much space you require for users. It's conceivable that you \
203 could run a minimal SliTaz system in 300 megs or less, but 2 gigs is indeed \
204 more comfy.")</p>
206 <p>$(gettext "A separate home partition, and a partition that will be used as \
207 Linux swap space may be created if needed. Slitaz detects and uses swap \
208 partitions automatically.")</p>
210 </div>
212 <div class="box">
214 <p>$(gettext "You can graphically manage your partitions with Gparted. GParted \
215 is a partition editor for graphically managing your disk partitions. Gparted \
216 allows you to create, destroy, resize and copy partitions without data loss.")</p>
218 <p>$(gettext "Gparted supports ext2, ext3, ext4, linux swap, ntfs and fat32 \
219 filesystems right out of the box. Support for xjs, jfs, hfs and other \
220 filesystems is available as well but you first need to add drivers for these \
221 filesystems by installing the related packages xfsprogs, jfsutils, linux-hfs \
222 and so on.")</p>
223 </div>
225 <a class="button" href="$SCRIPT_NAME?page=gparted">$(gettext 'Execute Gparted')</a>
227 <h5>$(gettext 'Continue installation')</h5>
229 <p>$(gettext "Once you've made room for SliTaz on your drive, you should be \
230 able to continue installation.")
232 <hr />
233 <a class="button" value="$1" href="$SCRIPT_NAME?page=home" >
234 <img src="$IMAGES/go-first.png"/> $(gettext 'Back to Installer Start Page')</a>
235 <a class="button" value="$2" href="$SCRIPT_NAME?page=install">
236 $(gettext 'Continue Installation') <img src="$IMAGES/go-next.png" /></a>
237 EOT
238 }
240 display_action()
241 {
242 case $1 in
243 install)
244 cat << EOT
245 <div id="wrapper">
246 <h3>$(gettext 'Install SliTaz')</h3>
248 <p>$(gettext "You're going to install SliTaz on a partition of your hard disk \
249 drive. If you decide to format your HDD, all data will be lost. If you do not \
250 format, all data except for any existing /home directory will be removed (note the \
251 home directory contents will be kept as is)."<p>
252 </div>
253 <input type="hidden" name="INST_ACTION" value="$1">
254 EOT
255 ;;
256 upgrade)
257 cat << EOT
258 <div id="wrapper">
259 <h2>$(gettext 'Upgrade SliTaz')</h2>
261 <p>$(gettext "You're going to upgrade an already installed SliTaz system on \
262 your hard disk drive. Your /home /etc /var/www directories will be kept, all \
263 other directories will be removed. Any additional packages added to your old \
264 Slitaz system will be updated as long you have an active internet connection.")<p>
265 </div>
266 <input type="hidden" name="INST_ACTION" value="$1">
267 EOT
268 ;;
269 esac
270 }
272 select_source()
273 {
274 cat <<EOT
275 <h4 id="source">$(gettext 'Slitaz source media')</h4>
277 <div class="box">
278 <input type="radio" name="INST_TYPE" value="cdrom" $([ "$INST_TYPE" == "cdrom" ] && echo "checked") id="cdrom" />
279 <label for="cdrom">$(gettext 'LiveCD')</label>
280 <br />
281 <input type="radio" name="INST_TYPE" value="usb" $([ "$INST_TYPE" == "usb" ] && echo "checked") id="usb" />
282 <label for="usb">$(gettext 'LiveUSB:')
283 <select name="SRC_USB">
284 EOT
285 # List disks if plugged USB device
286 usb=0
287 if [ -d /proc/scsi/usb-storage ]; then
288 for DEV in /sys/block/sd* ; do
289 if readlink $DEV | grep -q usb; then
290 DEV=$(basename $DEV)
291 if [ -d /sys/block/${DEV}/${DEV}1 ]; then
292 for i in $(fdisk -l /dev/$DEV | awk '/^\/dev/ {printf "%s ", $1}') ; do
293 echo "<option value='$i' $([ "$i" == "$SRC_FILE" ] && echo 'selected') >$i</option>"
294 usb=$usb+1
295 done
296 fi
297 fi
298 done
299 fi
300 if [ $usb -lt 1 ]; then
301 echo "<option value="">$(gettext 'Not found')</option>"
302 fi
303 cat << EOT
304 </select>
305 </label>
306 <br />
307 <input type="radio" name="INST_TYPE" value="iso" $([ "$INST_TYPE" == "iso" ] && echo "checked") id="iso" />
308 <label for="iso">$(gettext 'ISO file:')</label>
309 <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')" />
310 <br />
311 <input type="radio" name="INST_TYPE" value="web" $([ "$INST_TYPE" == "web" ] && echo "checked") id="web" />
312 <label for="web">$(gettext 'Web:')
313 <a class="button" onclick="document.forms['ConfigForm'].url.value = '$(tazinst showurl stable)'; return true;">$(gettext 'Stable')</a>
314 <a class="button" onclick="document.forms['ConfigForm'].url.value = '$(tazinst showurl cooking)'; return true;">$(gettext 'Cooking')</a>
316 $(gettext 'URL:')
317 <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')" />
318 </label>
319 </div>
320 EOT
321 }
323 select_hdd()
324 {
325 cat <<EOT
326 <h4 id="hdd">$(gettext 'Hard Disk Drive')</h4>
327 EOT
328 }
330 select_partition()
331 {
332 cat <<EOT
333 <div class="box">
334 <a name="partition"></a>
335 $(gettext 'Install Slitaz to partition:')
336 <select name="TGT_PARTITION">
337 EOT
338 # List partitions
339 if fdisk -l | grep -q ^/dev/ ; then
340 echo "<option value="">$(gettext 'None')</option>"
341 for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
342 echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo 'selected')>$i</option>"
343 done
344 else
345 echo "<option value="">$(gettext 'Not found')</option>"
346 fi
347 cat << EOT
348 </select>
349 <br />
350 <input type="checkbox" name="MAIN_FMT" value="yes" $([ -n "$TGT_FS" ] && echo "checked") id="mainfs" />
351 <label for="mainfs">$(gettext 'Format partition as:')</label>
352 <select name="MAIN_FS">
353 EOT
354 scan_mkfs
355 for i in $FS
356 do
357 echo "<option value='$i' $([ "$i" == "$TGT_FS" ] && echo 'selected')>$i</option>"
358 done
359 cat <<EOT
360 </select>
361 </div>
362 EOT
363 }
365 select_old_slitaz()
366 {
367 cat <<EOT
368 <div class="box">
369 <a name="partition"></a>
370 $(gettext 'Existing SliTaz partition to upgrade:')
371 <select name="TGT_PARTITION">
372 EOT
373 # List partitions
374 if fdisk -l | grep -q ^/dev/ ; then
375 echo "<option value="">$(gettext 'None')</option>"
376 for i in $(blkid | cut -d ":" -f 1); do
377 echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo 'selected')>$i</option>"
378 done
379 else
380 echo "<option value="">$(gettext 'Not found')</option>"
381 fi
382 cat <<EOT
383 </select>
384 </div>
385 EOT
386 }
388 select_options()
389 {
390 cat <<EOT
391 <h4 id="options">$(gettext 'Options')</h4>
392 EOT
393 }
395 select_home()
396 {
397 cat <<EOT
398 <div>
399 <h5 id="home">$(gettext 'home partition')</h5>
401 <input type="checkbox" name="HOME_SELECT" value="yes" $([ -n "$TGT_HOME" ] && echo "checked") id="homepart" />
402 <label for="homepart">$(gettext 'Use a separate partition for /home:')</label>
403 <select name="TGT_HOME">
404 EOT
405 # List disk if plugged USB device
406 if fdisk -l | grep -q ^/dev/ ; then
407 echo "<option value="">$(gettext 'None')</option>"
408 for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
409 echo "<option value='$i' $([ "$i" == "$TGT_HOME" ] && echo 'selected')>$i</option>"
410 done
411 else
412 echo "<option value="">$(gettext 'Not found')</option>"
413 fi
414 cat <<EOT
415 </select>
417 <input type="checkbox" name="HOME_FMT" value="yes" $([ -n "$TGT_HOME_FS" ] && echo "checked") id="homefs" />
418 <label for="homefs">$(gettext 'Format partition as:')</label>
419 <select name="HOME_FS">"
420 EOT
421 for i in $FS
422 do
423 echo "<option value='$i' $([ "$i" == "$TGT_HOME_FS" ] && echo 'selected')>$i</option>"
424 done
425 cat <<EOT
426 </select>
427 </div>
428 EOT
429 }
431 select_hostname()
432 {
433 cat << EOT
434 <div>
435 <h5 id="hostname">$(gettext 'Hostname')</h5>
437 $(gettext 'Set Hostname to:')
438 <input type="text" id="hst" name="TGT_HOSTNAME" value="$TGT_HOSTNAME" placeholder="$(gettext 'Name of your system')" onkeyup="checkLogin('hst','msgHst'); return false;" />
439 <span id="msgHst"></span>
440 </div>
441 EOT
442 }
444 select_root()
445 {
446 cat << EOT
447 <div>
448 <h5 id="root">$(gettext 'Root')</h5>
450 $(gettext 'Root passwd:')
451 <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;" />
453 $(gettext 'Confirm password:')
454 <input type="password" id="rootPwd2" value="$TGT_ROOT_PWD" placeholder="$(gettext 'Password of root')" onkeyup="checkPwd('rootPwd1','rootPwd2','msgRootPwd'); return false;" />
456 <span id="msgRootPwd"></span>
457 </div>
458 EOT
459 }
461 select_user()
462 {
463 cat << EOT
464 <div>
465 <h5 id="user">$(gettext 'User')</h5>
467 $(gettext 'User login:')
468 <input type="text" id="usr" name="TGT_USER" value="$TGT_USER" placeholder="$(gettext 'Name of the first user')" onkeyup="checkLogin('usr','msgUsr'); return false;" />
469 <span id="msgUsr"></span>
470 <br /><br />
472 $(gettext 'User passwd:')
473 <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;" />
475 $(gettext 'Confirm password:')
476 <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;" />
477 <span id="msgUserPwd"></span>
478 </div>
479 EOT
480 }
482 select_grub()
483 {
484 cat << EOT
485 <div>
486 <h5 id="grub">$(gettext 'Grub')</h5>
488 <input type="checkbox" name="TGT_GRUB" value="yes" $([ "$TGT_GRUB" == "yes" ] && echo "checked") id="grub" />
489 <label for="grub">$(gettext "Install Grub bootloader. Usually you should \
490 answer yes, unless you want to install grub by hand yourself.")<br /></label>
491 <input type="checkbox" name="TGT_WINBOOT" value="auto" $([ -n "$TGT_WINBOOT" ] && echo "checked") id="dualboot" />
492 <label for="dualboot">$(gettext 'Enable Windows Dual-Boot.')</label>
493 </div>
494 EOT
495 }
497 moveto_page()
498 {
499 case $1 in
500 partitioning)
501 title1="<img src=\"$IMAGES/go-previous.png\" /> $(gettext 'Back to partitioning')" ;;
502 *)
503 page=home
504 title1="<img src=\"$IMAGES/go-first.png\" /> $(gettext 'Back to Installer Start Page')" ;;
505 esac
506 case $2 in
507 write|run)
508 title2="$(gettext 'Proceed to SliTaz installation') <img src=\"$IMAGES/go-next.png\" />" ;;
509 reboot)
510 title2=$(gettext 'Installation complete. You can now restart (reboot)') ;;
511 failed)
512 title2=$(gettext 'Installation failed. See log') ;;
513 *)
514 page=home
515 title2="<img src=\"$IMAGES/go-first.png\" /> $(gettext 'Back to Installer Start Page')" ;;
516 esac
517 cat <<EOT
518 <hr />
519 <a class="button" value="$1" href="$SCRIPT_NAME?page=$1" >$title1</a>
520 <a class="button" value="$2" href="$SCRIPT_NAME?page=$2" >$title2</a>
521 EOT
522 }
524 page_redirection()
525 {
526 cat << EOT
527 <!DOCTYPE html>
528 <html>
529 <head>
530 <meta charset="utf-8">
531 <title>$(gettext "A web page that points a browser to a different page after \
532 2 seconds")</title>
533 <meta http-equiv="refresh" content="0; URL=$SCRIPT_NAME?page=$1">
534 <meta name="keywords" content="automatic redirection">
535 </head>
536 <body>
537 <p>$(gettext "If your browser doesn't automatically redirect within a few \
538 seconds, you may want to go there manually")</p>
539 <p><a href="$SCRIPT_NAME?page=$1">$1</a></p>
540 </body>
541 </html>
542 EOT
543 }
545 check_ressources()
546 {
547 local code
548 code=0
549 # Check tazinst
550 if ! [ -x /usr/sbin/tazinst ] ; then
551 cat <<EOT
552 <h3>$(gettext 'Tazinst Error')</h3>
553 <p>$(gettext "<strong>tazinst</strong>, the lightweight SliTaz HDD installer \
554 is missing. Any installation cannot be done without tazinst.")</p>
556 <p>$(gettext "Check tazinst' permissions, or reinstall the slitaz-tools \
557 package:")</p>
558 <code># tazpkg get-install slitaz-tools --forced</code>
559 EOT
560 code=1
561 else
562 # Check tazinst required version
563 v=$(tazinst version | tr -d '[:alpha:]')
564 r=$TAZINST_REQUIRED_VERSION
565 if ! (echo "$v" | awk -v r=$r '{v=$v+0}{ if (v < r) exit 1}') ; then
566 cat <<EOT
567 <h3>$(gettext 'Tazinst Error')</h3>
569 <p>$(eval_gettext "<strong>tazinst</strong> ($v) is not at the required \
570 version ($r), use tazinst in a xterm or reinstall the slitaz-tools package:")</p>
571 <code># tazpkg get-install slitaz-tools --forced</code>
572 EOT
573 code=1
574 fi
575 fi
576 return $code
577 }
579 run_tazinst()
580 {
581 cat << EOT
582 <h4>$(gettext 'Proceeding: ()')</h4>
583 <p>$(gettext 'Please wait until processing is complete')</p>
584 EOT
585 table_start
586 tazinst $(GET INST_ACTION) $INSTFILE | \
587 awk '{print "<tr><td><tt>" $0 "</tt></td></tr>"}'
588 table_end
589 echo "<p>$(gettext 'Completed.')</p>"
590 return $(grep -c "cancelled on error" $INSTFILE)
591 }
593 tazinst_log()
594 {
595 echo "<pre>$(tazinst log)</pre>"
596 }
598 scan_mkfs()
599 {
600 for path in /bin /sbin /usr/bin /usr/sbin
601 do
602 [ -e $path/mkfs.btrfs ] && FS=btrfs
603 [ -e $path/mkfs.cramfs ] && FS="$FS cramfs"
604 [ -e $path/mkfs.ext2 ] && FS="$FS ext2"
605 [ -e $path/mkfs.ext3 ] && FS="$FS ext3"
606 [ -e $path/mkfs.ext4 ] && FS="$FS ext4"
607 [ -e $path/mkfs.jfs ] && FS="$FS jfs"
608 [ -e $path/mkfs.minix ] && FS="$FS minix"
609 [ -e $path/mkfs.reiserfs ] && FS="$FS reiserfs"
610 [ -e $path/mkfs.xfs ] && FS="$FS xfs"
611 done
612 }
614 form_start()
615 {
616 cat <<EOT
617 <script src="lib/user.js"></script>
618 <script type="text/javascript">
619 function Validate(page) {
620 if (page == "install") {
621 // hostname
622 if (false == checkLogin('hst','msgHst')) {
623 alert("$(gettext 'Hostname error')");
624 return false;
625 // root pwd
626 } else if (false == checkPwd('rootPwd1','rootPwd2','msgRootPwd')) {
627 alert("$(gettext 'Root password error')");
628 return false;
629 // user
630 } else if (false == checkLogin('usr','msgUsr')) {
631 alert("$(gettext 'User login error')");
632 return false;
633 // user pwd
634 } else if (false == checkPwd('userPwd1','userPwd2','msgUserPwd')) {
635 alert("$(gettext 'User password error')");
636 return false;
637 } else {
638 var r=confirm("$(gettext 'Do you really want to continue?')");
639 if (r==true)
640 {
641 document.ConfigForm.submit();
642 } else {
643 return false;
644 }
645 }
646 } else if (page == "write") {
647 return true;
648 } else {
649 var r=confirm("$(gettext 'Do you really want to continue?')");
650 if (r==true)
651 {
652 document.ConfigForm.submit();
653 } else {
654 return false;
655 }
656 }
657 }
658 </script>
659 <form name="ConfigForm" method="get" onsubmit="return Validate('$1')" action="$SCRIPT_NAME">
660 EOT
661 }
663 form_end()
664 {
665 echo "</form>"
666 }
668 #
669 # Main
670 #
672 case "$(GET page)" in
673 home)
674 xhtml_header
675 select_action
676 select_install
677 select_upgrade
678 ;;
679 partitioning)
680 xhtml_header
681 display_action install
682 select_gparted
683 ;;
684 gparted)
685 su - -c "exec env DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' /usr/sbin/gparted"
686 xhtml_header
687 page_redirection partitioning
688 ;;
689 install)
690 xhtml_header
691 form_start install
692 display_action install
693 read_setup
694 select_source
695 select_hdd
696 select_partition
697 select_options
698 select_home
699 select_hostname
700 select_root
701 select_user
702 select_grub
703 moveto_page partitioning write
704 form_end
705 ;;
706 upgrade)
707 xhtml_header
708 form_start upgrade
709 display_action upgrade
710 read_setup
711 select_source
712 select_hdd
713 select_old_slitaz
714 select_options
715 select_grub
716 moveto_page home write
717 form_end
718 ;;
719 write)
720 write_setup
721 xhtml_header
722 if ! (tazinst check $INSTFILE); then
723 page_redirection $(GET INST_ACTION)
724 else
725 read_setup
726 form_start write
727 display_action $(GET INST_ACTION)
728 if run_tazinst; then
729 moveto_page home reboot
730 else
731 moveto_page home failed
732 fi
733 form_end
734 fi
735 ;;
736 reboot)
737 reboot ;;
738 failed)
739 xhtml_header
740 display_log
741 ;;
742 menu_install)
743 xhtml_header
744 if check_ressources; then
745 page_redirection partitioning
746 fi
747 ;;
748 menu_upgrade)
749 xhtml_header
750 if check_ressources; then
751 page_redirection upgrade
752 fi
753 ;;
754 *)
755 xhtml_header
756 if check_ressources; then
757 page_redirection home
758 fi
759 ;;
760 esac
762 xhtml_footer
764 exit 0