tazpanel view installer.cgi @ rev 288

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