tazinst view installer.cgi @ rev 62

installer/fr.po: typos
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jul 13 11:51:25 2015 +0200 (2015-07-13)
parents 1e48e851f915
children ce62c558e0b4
line source
1 #!/bin/sh
2 #
3 # Main CGI interface for Tazinst, the SliTaz installer.
4 #
5 # Copyright (C) 2012-2015 SliTaz GNU/Linux - BSD License
6 #
7 # Authors : Dominique Corbex <domcox@slitaz.org>
8 #
11 # restricted path
12 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
14 VERSION=3.98
16 # Common functions from libtazpanel
17 . lib/libtazpanel
18 get_config
20 TITLE=$(gettext 'TazPanel - Installer')
22 # export package name for gettext.
23 TEXTDOMAIN='installer'
24 export TEXTDOMAIN
26 # tazinst required version
27 TAZINST_MINIMUM_VERSION="3.8"
28 TAZINST_MAXIMUM_VERSION="4.99"
30 # tazinst setup file
31 INSTFILE=/root/tazinst.conf
34 #------
35 # menu
36 #------
38 case "$1" in
39 menu)
40 cat <<EOT
41 <li tabindex="0">
42 <span>$(gettext 'Installation')</span>
43 <menu>
44 <li><a data-icon="install"
45 href="installer.cgi" data-root>$(gettext 'Installation')</a></li>
46 <li><a data-icon="slitaz"
47 href="installer.cgi?page=install" data-root>$(gettext 'Install SliTaz')</a></li>
48 <li><a data-icon="upgrade"
49 href="installer.cgi?page=upgrade" data-root>$(gettext 'Upgrade system')</a></li>
50 </menu>
51 </li>
52 EOT
53 exit
54 esac
57 #-----------
58 # home page
59 #-----------
61 select_action() {
62 cat <<EOT
63 <!-- Welcome message -->
65 <h2>$(gettext "Welcome to the Slitaz Installer!")</h2>
67 <p>$(gettext "The SliTaz Installer installs or upgrades SliTaz to a \
68 hard disk drive from a device like a Live-CD or LiveUSB key, from a SliTaz \
69 ISO file, or from the web by downloading an ISO file.")</p>
71 <p>$(gettext "Which type of installation do you want to start?")</p>
72 EOT
73 }
76 select_install() {
77 cat <<EOT
78 <!-- Install message -->
80 <section>
81 <header>$(gettext 'Install')</header>
83 <div>
84 <p>$(gettext "Install SliTaz on a partition of your hard disk drive. If \
85 you decide to format your partition, all data will be lost. If you do not \
86 format, all data except for any existing /home directory will be removed \
87 (the home directory will be kept as is).")</p>
88 <p>$(gettext "Before installation, you may need to create or resize \
89 partitions on your hard disk drive in order to make space for SliTaz \
90 GNU/Linux. You can graphically manage your partitions with Gparted")</p>
91 </div>
93 <footer>
94 <form>
95 <button name="page" value="install" data-icon="slitaz"
96 title="$(gettext 'Proceed to a new SliTaz installation')"
97 >$(gettext 'Install SliTaz')</button>
98 </form>
99 </footer>
100 </section>
101 EOT
102 }
105 select_upgrade() {
106 cat <<EOT
107 <!-- Upgrade message -->
109 <section>
110 <header>$(gettext 'Upgrade')</header>
112 <div>
113 <p>$(gettext "Upgrade an already installed SliTaz system on your hard disk \
114 drive. Your /home /etc /var/www directories will be kept, all other \
115 directories will be removed. Any additional packages added to your old \
116 Slitaz system will be updated as long you have an active internet connection.")</p>
117 </div>
119 <footer>
120 <form>
121 <button name="page" value="upgrade" data-icon="upgrade"
122 title="$(gettext 'Upgrade an existing SliTaz system')"
123 >$(gettext 'Upgrade SliTaz')</button>
124 </form>
125 </footer>
126 </section>
127 EOT
128 }
131 #--------------------
132 # partitioning page
133 #--------------------
135 exec_gparted() {
136 /bin/su - -c \
137 "exec env DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' /usr/sbin/gparted"
138 }
141 select_gparted() {
142 cat <<EOT
143 <!-- GParted message -->
145 <section>
146 <header>$(gettext "Partitioning")</header>
148 <div>
149 <p>$(gettext "On most used systems, the hard drive is already dedicated to \
150 partitions for Windows&trade;, or Linux, or another operating \
151 system. You'll need to resize these partitions in order to make space for \
152 SliTaz GNU/Linux. SliTaz will co-exist with other operating systems already \
153 installed on your hard drive.")</p>
154 <p>$(gettext "The amount of space needed depends on how much software you \
155 plan to install and how much space you require for users. It's conceivable \
156 that you could run a minimal SliTaz system in 300 megs or less, but 2 gigs \
157 is indeed more comfy.")</p>
158 <p>$(gettext "A separate home partition and a partition that will be used \
159 as Linux swap space may be created if needed. Slitaz detects and uses swap \
160 partitions automatically.")</p>
161 <hr/>
162 <p>$(gettext "You can graphically manage your partitions with GParted. \
163 GParted is a partition editor for graphically managing your disk partitions. \
164 GParted allows you to create, destroy, resize and copy partitions without \
165 data loss.")</p>
166 <p>$(gettext "GParted supports ext2, ext3, ext4, linux swap, ntfs and \
167 fat32 filesystems right out of the box. Support for xjs, jfs, hfs and other \
168 filesystems is available as well but you first need to add drivers for these \
169 filesystems by installing the related packages xfsprogs, jfsutils, linux-hfs \
170 and so on.")</p>
171 </div>
173 <footer>
174 <!-- Launch GParted -->
175 <form>
176 <button name="page" value="gparted" data-icon="hdd"
177 title="$(gettext 'Launch GParted, the partition editor tool')"
178 >$(gettext 'Execute GParted')</button>
179 </form>
180 </footer>
181 </section>
183 <section>
184 <header>$(gettext "Without Partitioning / Formating")</header>
186 <div>
187 <p>$(gettext "SliTaz and Windows&trade; can coexist in the same partition.")</p>
188 <p>$(gettext "Slitaz will be in the \slitaz directory like UMSDOS did \
189 in the previous century...")</p>
190 </div>
192 <footer>
193 <form action="boot.cgi">
194 <input type="hidden" name="iso"/>
195 <input type="hidden" name="action" value="install"/>
196 <button data-icon="install">$(gettext 'Install')</button>
197 </form>
198 </footer>
199 </section>
202 <h5>$(gettext "Continue installation")</h5>
204 <p>$(gettext "Once you've made room for SliTaz on your drive, you should \
205 be able to continue installation.")</p>
206 EOT
207 }
210 #------------
211 # input page
212 #------------
214 select_source() {
215 local media="$(/usr/sbin/tazinst get media "$INSTFILE")"
216 local source="$(/usr/sbin/tazinst get source "$INSTFILE")"
217 local list_media="$(/usr/sbin/tazinst list media)"
218 local error
220 # set default media
221 [ "$media" ] || media="$(tazinst list media | cut -d ' ' -f1)"
223 comment "Source selection"
224 # cdrom
225 if printf '%s' "$list_media" | grep -q "cdrom"; then
226 input_media "cdrom" \
227 "$media"
228 label_media "cdrom" \
229 "$(gettext 'LiveCD')" \
230 "$media" \
231 "$(gettext 'Use the SliTaz LiveCD')"
232 br
233 fi
234 # usb
235 if printf '%s' "$list_media" | grep -q "usb"; then
236 input_media "usb" \
237 "$media"
238 label_media "usb" \
239 "$(gettext 'LiveUSB:')" \
240 "$media" \
241 "$(gettext 'Enter the partition where SliTaz Live is located on
242 your USB Key')"
243 error="$?"
244 select "$(/usr/sbin/tazinst list usb "$INSTFILE" | cut -d' ' -f2)" \
245 "$source" \
246 "SRC_USB"
247 error_msg "$error" \
248 "source" \
249 2
250 br
251 fi
252 # iso
253 input_media "iso" \
254 "$media"
255 label_media "iso" \
256 "$(gettext 'ISO file:')" \
257 "$media" \
258 "$(gettext 'Select a SliTaz ISO file located on a local disk')"
259 error="$?"
260 if [ "$media" == "iso" ]; then
261 input "text" \
262 "src_iso" \
263 "$source" "" \
264 "$(gettext 'Select an ISO or enter the full path to the ISO file')"\
265 "iso"
266 else
267 input "text" \
268 "src_iso" \
269 "" \
270 "none" \
271 "$(gettext 'Select an ISO or enter the full path to the ISO file')"\
272 "iso"
273 fi
274 datalist "$(/usr/sbin/tazinst list iso "$INSTFILE")" \
275 "src_iso"
276 error_msg "$error" \
277 "source"
278 br
279 # web
280 input_media "web" \
281 "$media"
282 label_media "web" \
283 "$(gettext 'Web:')" \
284 "$media" \
285 "$(gettext 'Select a SliTaz version on the Web')"
286 error="$?"
288 if [ "$media" == "web" ]; then
289 input "text" \
290 "src_web" \
291 "$source" "" \
292 "$(gettext 'Select a version or enter the full url to an ISO file')"\
293 "web"
294 else
295 input "text" \
296 "src_web" \
297 "" \
298 "none" \
299 "$(gettext 'Select a version or enter the full url to an ISO file')"\
300 "web"
301 fi
302 datalist "$(/usr/sbin/tazinst help web "$INSTFILE")" \
303 "src_web"
304 error_msg "$error" \
305 "source"
306 }
308 select_root_uuid()
309 {
310 local root_uuid="$(/usr/sbin/tazinst get root_uuid "$INSTFILE")"
311 local mode="$(/usr/sbin/tazinst get mode "$INSTFILE")"
312 comment "root_uuid selection"
313 if [ "$mode" == "upgrade" ]; then
314 label "root_uuid" \
315 "$(gettext 'Existing SliTaz partition to upgrade:')" \
316 "$(gettext 'Specify the partition containing the system to upgrade')"
317 error="$?"
318 else
319 label "root_uuid" \
320 "$(gettext 'Install Slitaz to partition:')" \
321 "$(gettext 'Specify the partition where to install SliTaz')"
322 error="$?"
323 fi
324 select "$(/usr/sbin/tazinst list uuid "$INSTFILE")" \
325 "$root_uuid" \
326 "ROOT_UUID" \
327 0
328 error_msg "$error" \
329 "root_uuid" \
330 0
331 br
332 }
334 select_root_format()
335 {
336 local root_format="$(/usr/sbin/tazinst get root_format "$INSTFILE")"
337 comment "root_format selection"
338 format "$(/usr/sbin/tazinst list format "$INSTFILE")" \
339 "$root_format" \
340 "ROOT_FORMAT"
341 }
343 select_home_uuid() {
344 local home_uuid="$(/usr/sbin/tazinst get home_uuid "$INSTFILE")"
346 cat <<EOT
347 <!-- home_uuid selection -->
349 <fieldset>
350 <legend>$(gettext "home partition")</legend>
352 $(
353 label "home_uuid" \
354 "$(gettext 'Separate partition for /home:')" \
355 "$(gettext 'Specify the partition containing /home')"
356 select "$(/usr/sbin/tazinst list uuid "$INSTFILE")" \
357 "$home_uuid" \
358 "HOME_UUID" \
359 0
360 )
361 <br/>
362 EOT
363 }
365 select_home_format()
366 {
367 local home_format="$(/usr/sbin/tazinst get home_format "$INSTFILE")"
369 comment "home_format selection"
370 format "$(/usr/sbin/tazinst list format "$INSTFILE")" \
371 "$home_format" \
372 "HOME_FORMAT"
373 cat <<EOT
374 </fieldset>
375 EOT
376 }
379 select_hostname() {
380 local hostname="$(/usr/sbin/tazinst get hostname "$INSTFILE")" error
382 cat <<EOT
383 <!-- hostname selection -->
385 <fieldset>
386 <legend>$(gettext "Hostname")</legend>
387 $(
388 label "hostname" \
389 "$(gettext 'Set Hostname to:')" \
390 "$(gettext 'Hostname configuration allows you to specify the machine name')"
391 error=$?
392 input "text" \
393 "HOSTNAME" \
394 "$hostname" \
395 "" \
396 "$(gettext 'Name of your system')"
397 error_msg "$error" \
398 "hostname" \
399 2
400 )
401 </fieldset>
402 EOT
403 }
406 select_root_pwd() {
407 local root_pwd="$(/usr/sbin/tazinst get root_pwd "$INSTFILE")" error
409 cat <<EOT
410 <!-- root_pwd selection -->
412 <fieldset>
413 <legend>$(gettext "Root superuser")</legend>
414 $(
415 label "root_pwd" \
416 "$(gettext 'Root passwd:')" \
417 "$(gettext 'Enter the password for root')"
418 error="$?"
419 input "text" \
420 "ROOT_PWD" \
421 "$root_pwd" \
422 "" \
423 "$(gettext 'Password of root')"
424 error_msg "$error" \
425 "root_pwd"
426 )
427 </fieldset>
428 EOT
429 }
432 select_user_login() {
433 local user_login="$(/usr/sbin/tazinst get user_login "$INSTFILE")" error
435 cat <<EOT
436 <!-- user_login selection -->
438 <fieldset>
439 <legend>$(gettext "User")</legend>
440 $(
441 label "user_login" \
442 "$(gettext 'User login:')" \
443 "$(gettext 'Enter the name of the first user')"
444 error="$?"
445 input "text" \
446 "USER_LOGIN" \
447 "$user_login" \
448 "" \
449 "$(gettext 'Name of the first user')"
450 error_msg "$error" \
451 "user_login" \
452 2
453 )
454 <br/>
455 EOT
456 }
459 select_user_pwd()
460 {
461 local user_pwd="$(/usr/sbin/tazinst get user_pwd "$INSTFILE")" error
463 label "user_pwd" \
464 "$(gettext 'User passwd:')" \
465 "$(gettext 'The password for default user')"
466 error="$?"
467 input "text" \
468 "USER_PWD" \
469 "$user_pwd" \
470 "" \
471 "$(gettext 'Password of the first user')"
472 error_msg "$error" \
473 "user_pwd"
474 cat <<EOT
475 </fieldset>
476 EOT
477 }
480 select_bootloader()
481 {
482 local bootloader="$(/usr/sbin/tazinst get bootloader "$INSTFILE")" error
484 cat <<EOT
485 <!-- bootloader selection -->
487 <fieldset>
488 <legend>$(gettext "Bootloader")</legend>
490 $(
491 input "checkbox" \
492 "bootloader" \
493 "auto" \
494 "$bootloader"
495 label "bootloader" \
496 "$(gettext 'Install a bootloader.')" \
497 "$(gettext "Usually you should answer yes, unless you want to install \
498 a bootloader by hand yourself.")"
499 error="$?"
500 error_msg "$error" \
501 "bootloader"
502 )
503 <br/>
504 EOT
505 }
508 select_winboot()
509 {
510 local winboot="$(/usr/sbin/tazinst get winboot "$INSTFILE")" error
512 comment "winboot selection"
513 input "checkbox" \
514 "winboot" \
515 "auto" \
516 "$winboot"
517 label "winboot" \
518 "$(gettext 'Enable Windows Dual-Boot.')" \
519 "$(gettext "At start-up, you will be asked whether you want to boot \
520 into Windows&trade; or SliTaz GNU/Linux.")"
521 error="$?"
522 error_msg "$error" \
523 "winboot"
524 cat <<EOT
525 </fieldset>
526 EOT
527 }
530 errors_msg()
531 {
532 if [ "$CHECK" ]; then
533 echo '<span class="alert">'
534 p "$(gettext "Errors found. Please check your settings.")"
535 echo '</span>'
536 fi
537 }
540 select_settings() {
541 local settings="$(/usr/sbin/tazinst get settings "$INSTFILE")"
542 CHECK=$(GET CHECK)
543 errors_msg
545 cat<<EOT
546 <fieldset>
547 <legend>$(gettext "Select source media:")</legend>
549 <div class="media">$(select_source)</div>
550 </fieldset>
553 <fieldset>
554 <legend>$(gettext "Select destination")</legend>
556 <div>$(
557 select_root_uuid
558 printf '%s' "$settings" | grep -q "root_format" && select_root_format
559 )</div>
560 </fieldset>
563 <fieldset id="options">
564 <legend>$(gettext 'Options')</legend>
566 <div class="options">$(
567 printf '%s' "$settings" | grep -q "home_uuid" && select_home_uuid
568 printf '%s' "$settings" | grep -q "home_format" && select_home_format
569 printf '%s' "$settings" | grep -q "hostname" && select_hostname
570 printf '%s' "$settings" | grep -q "root_pwd" && select_root_pwd
571 printf '%s' "$settings" | grep -q "user_login" && select_user_login
572 printf '%s' "$settings" | grep -q "user_pwd" && select_user_pwd
573 )</div>
575 <div class="bootloader">$(
576 printf '%s' "$settings" | grep -q "bootloader" && select_bootloader
577 printf '%s' "$settings" | grep -q "winboot" && select_winboot
578 )</div>
579 </fieldset>
581 <br/>
582 EOT
583 }
586 #--------------
587 # execute page
588 #--------------
590 save_settings()
591 {
592 h5 "$(gettext "Checking settings...")"
594 # install type
595 /usr/sbin/tazinst set media "$(GET MEDIA)" "$INSTFILE"
597 # source File
598 case "$(/usr/sbin/tazinst get media "$INSTFILE")" in
599 usb)
600 /usr/sbin/tazinst set source "$(GET SRC_USB)" "$INSTFILE" ;;
601 iso)
602 /usr/sbin/tazinst set source "$(GET SRC_ISO)" "$INSTFILE" ;;
603 web)
604 /usr/sbin/tazinst set source "$(GET SRC_WEB)" "$INSTFILE" ;;
605 esac
607 # set defined url
608 [ $(GET URL) ] && SRC_WEB=$(GET URL)
610 # root Partition
611 /usr/sbin/tazinst set root_uuid "$(GET ROOT_UUID)" "$INSTFILE"
613 # format root partition
614 [ "$(GET ROOT_FORMAT)" ] \
615 && /usr/sbin/tazinst set root_format "$(GET ROOT_FORMAT)" "$INSTFILE" \
616 || /usr/sbin/tazinst unset root_format "$INSTFILE"
618 # home Partition
619 if [ "$(GET HOME_UUID)" ] ; then
620 /usr/sbin/tazinst set home_uuid "$(GET HOME_UUID)" "$INSTFILE"
621 [ "$(GET HOME_FORMAT)" ] \
622 && /usr/sbin/tazinst set home_format "$(GET HOME_FORMAT)" \
623 "$INSTFILE" \
624 || /usr/sbin/tazinst unset home_format "$INSTFILE"
625 else
626 /usr/sbin/tazinst unset home_uuid "$INSTFILE"
627 /usr/sbin/tazinst unset home_format "$INSTFILE"
628 fi
630 # hostname
631 /usr/sbin/tazinst set hostname "$(GET HOSTNAME)" "$INSTFILE"
633 # root pwd
634 /usr/sbin/tazinst set root_pwd "$(GET ROOT_PWD)" "$INSTFILE"
636 # user Login
637 /usr/sbin/tazinst set user_login "$(GET USER_LOGIN)" "$INSTFILE"
639 # user Pwd
640 /usr/sbin/tazinst set user_pwd "$(GET USER_PWD)" "$INSTFILE"
642 # win Dual-Boot
643 /usr/sbin/tazinst set winboot "$(GET WINBOOT)" "$INSTFILE"
645 # bootloader
646 if [ "$(GET BOOTLOADER)" == "auto" ]; then
647 /usr/sbin/tazinst set bootloader "auto" "$INSTFILE"
648 else
649 /usr/sbin/tazinst unset bootloader "$INSTFILE"
650 /usr/sbin/tazinst unset winboot "$INSTFILE"
651 fi
652 input_hidden "CHECK" "yes"
653 }
656 tazinst_run()
657 {
658 local mode="$(/usr/sbin/tazinst get mode "$INSTFILE")" error
659 h4 "Proceeding to: $mode"
660 /usr/sbin/tazinst execute "$INSTFILE" | /bin/busybox awk '{
661 num=$1+0
662 if (num>0 && num<=100){
663 print "<script type=\"text/javascript\">"
664 printf "document.write(\047<div id=\"progress\">"
665 printf "<img src=\"/styles/default/images/loader.gif\" />"
666 printf $1 "&#37; " substr($0, length($1)+2, 40)
667 print "</div>\047)"
668 print "</script>"
669 }
670 }'
671 # end_of_install
672 if /usr/sbin/tazinst log | grep -q "x-x-" ; then
673 error=1
674 echo "<script type=\"text/javascript\">"
675 printf "document.write(\047<div id=\"progress\">"
676 printf "<img src=\"/styles/default/images/stop.png\" />"
677 printf "$(gettext 'Errors encountered.')"
678 printf "</div>\047)\n"
679 echo "</script>"
680 br
681 br
682 /usr/sbin/tazinst log | \
683 /bin/busybox awk '$1 == "-x-x-",$1 == "x-x-x"' | sed 's/-x-x-/ /' \
684 | grep -v "x-x-x"
685 else
686 error=0
687 echo "<script type=\"text/javascript\">"
688 printf "document.write(\047<div id=\"progress\">"
689 printf "<img src=\"/styles/default/images/tux.png\" />"
690 printf "$(gettext 'Process completed!')"
691 printf "</div>\047)\n"
692 echo "</script>"
693 br
694 br
695 br
696 p $(gettext "Installation is now finished, you can exit the installer \
697 or reboot on your new SliTaz GNU/Linux operating system.")
698 fi
699 return "$error"
701 }
704 tazinst_log()
705 {
706 h4 "$(gettext "Tazinst log")"
707 printf '<pre>%s</pre>' "$(/usr/sbin/tazinst log | sed 's/\%/ percent/g')"
708 }
711 #-----------------
712 # page navigation
713 #-----------------
715 display_mode() {
716 local mode="$(/usr/sbin/tazinst get mode "$INSTFILE")"
717 case $mode in
718 install)
719 cat <<EOT
720 <h2>$(gettext "Install SliTaz")</h2>
722 <p>$(gettext "You're going to install SliTaz on a partition of \
723 your hard disk drive. If you decide to format your HDD, all data will be \
724 lost. If you do not format, all data except for any existing /home \
725 directory will be removed (the home directory will be kept as is).")</p>
726 EOT
727 ;;
728 upgrade)
729 cat <<EOT
730 <h2>$(gettext "Upgrade SliTaz")</h2>
732 <p>$(gettext "You're going to upgrade an already installed SliTaz \
733 system on your hard disk drive. Your /home /etc /var/www directories \
734 will be kept, all other directories will be removed. Any additional \
735 packages added to your old Slitaz system will be updated as long you \
736 have an active internet connection.")</p>
737 EOT
738 ;;
739 esac
740 }
743 moveto_page()
744 {
745 local back_page="$1" next_page="$2" back_msg next_msg
747 case "$back_page" in
748 partitioning)
749 back_msg=$(gettext 'Back to partitioning') ;;
750 input)
751 back_msg=$(gettext 'Back to entering settings') ;;
752 *)
753 back_msg=$(gettext 'Back to Installer Start Page') ;;
754 esac
756 case "$next_page" in
757 execute|run)
758 next_msg=$(gettext 'Proceed to SliTaz installation') ;;
759 reboot)
760 next_msg=$(gettext 'Installation complete. You can now restart') ;;
761 failed)
762 next_msg=$(gettext 'Installation failed. See log') ;;
763 input)
764 next_msg=$(gettext 'Continue installation.') ;;
765 *)
766 next_msg=$(gettext 'Back to Installer Start Page') ;;
767 esac
769 cat <<EOT
770 <hr/>
771 <form>
772 <button name="page" value="$back_page" data-icon="back" >$back_msg</button>
773 <button name="page" value="$next_page" data-icon="start">$next_msg</button>
774 </form>
775 EOT
776 }
779 moveto_home() {
780 cat <<EOT
781 <form>
782 <button name="page" value="home" data-icon="back"
783 >$(gettext 'Back to Installer Start Page')</button>
784 </form>
785 EOT
786 }
789 page_redirection() {
790 local page="$1"
791 cat <<EOT
792 <!DOCTYPE html>
793 <html>
794 <head>
795 <meta charset="UTF-8">
796 <title>$(gettext "A web page that points a browser to a different page after \
797 2 seconds")</title>
798 <meta http-equiv="refresh" content="0; URL=$SCRIPT_NAME?page=$1">
799 <meta name="keywords" content="automatic redirection">
800 </head>
801 <body>
802 <p>$(gettext "If your browser doesn't automatically redirect within a few \
803 seconds, you may want to go there manually")
804 <a href="$SCRIPT_NAME?page=$page">$(gettext "here")</a></p>
805 </body>
806 </html>
807 EOT
808 }
811 #----------
812 # checking
813 #----------
815 check_ressources() {
816 local errorcode=0
817 comment "check_ressources"
818 if ! [ -x /usr/sbin/tazinst ] ; then
819 h4 $(gettext "Tazinst Error")
820 p $(gettext "<strong>tazinst</strong>, the backend to slitaz-installer \
821 is missing. Any installation can not be done without tazinst.")
822 p $(gettext "Check tazinst permissions, or reinstall the \
823 slitaz-installer package.")
824 errorcode=1
825 else
826 # check tazinst minimum version
827 v=$(/usr/sbin/tazinst version | tr -d '[:alpha:]')
828 r=$TAZINST_MINIMUM_VERSION
829 if ! (printf '%s' "$v" | /bin/busybox awk -v r=$r \
830 '{v=$v+0}{ if (v < r) exit 1}') ; then
831 h4 $(gettext "Tazinst Error")
832 p $(gettext "<strong>tazinst</strong>, the slitaz-installer \
833 backend, is not at the minimum required version. Any installation \
834 cannot be done without tazinst.")
835 p $(gettext "Reinstall the slitaz-installer package, or use \
836 tazinst in CLI mode.")
837 errorcode=1
838 fi
839 # check tazinst maximum version
840 v=$(/usr/sbin/tazinst version | tr -d '[:alpha:]')
841 r=$TAZINST_MAXIMUM_VERSION
842 if ! (printf '%s' "$v" | /bin/busybox awk -v r=$r \
843 '{v=$v+0}{ if (v > r) exit 1}') ; then
844 h4 $(gettext "Tazinst Error")
845 p $(gettext "<strong>tazinst</strong>, the slitaz-installer \
846 backend, is at a higher version than the maximum authorized \
847 by the slitaz-installer. Any installation cannot be done.")
848 p $(gettext "Reinstall the slitaz-installer package, or use \
849 tazinst in CLI mode.")
850 errorcode=1
851 fi
852 fi
853 return $errorcode
854 }
857 #---------------
858 # html snippets
859 #---------------
861 br() {
862 echo '<br />'
863 }
865 hr() {
866 echo '<hr />'
867 }
869 comment() {
870 printf '<!-- %s -->\n' "$@"
871 }
873 a() {
874 local page="$1" text="$2"
875 printf '<a class="button" value="%s" href="%s?page=%s">%s</a>\n' \
876 "$page" "$SCRIPT_NAME" "$page" "$text"
877 }
879 button() {
880 local action="$1" msg="$2" title="$3"
881 printf '<a class="button" href="%s?page=%s" title="%s">%s</a>\n' \
882 "$SCRIPT_NAME" "$action" "$title" "$msg"
883 }
885 open_div() {
886 [ "$1" ] && printf '<div %s>\n' "$1" || echo '<div>'
887 }
889 close_div() {
890 echo '</div>'
891 }
893 p() {
894 printf '<p>%s</p>\n' "$@"
895 }
897 h4() {
898 printf '<h4>%s</h4>\n' "$@"
899 }
901 h5() {
902 printf '<h5>%s</h5>\n' "$@"
903 }
905 label() {
906 local setting="$1" label="$2" title="$3" name="$4" error=0
907 [ -z "$name" ] && name="$setting"
908 printf '<label for="%s"' "$name"
909 [ "$title" ] && printf ' title="%s">' "$title" || printf '%s' '>'
910 # display label in red in case of error
911 if [ "$CHECK" ]; then
912 /usr/sbin/tazinst check "$setting" "$INSTFILE"
913 error="$?"
914 [ "$error" -gt "0" ] && [ "$error" -lt "127" ] && \
915 printf '%s' '<span class="alert">'
916 printf '%s' "$label"
917 [ "$error" -gt "0" ] && [ "$error" -lt "127" ] && \
918 printf '%s' "<sup>*</sup></span>"
919 else
920 printf '%s' "$label"
921 fi
922 echo '</label>'
923 return "$error"
924 }
927 label_media() {
928 local id="$1" label="$2" media="$3" title="$4" retcode=0
929 if [ "$media" == "$id" ]; then
930 label "source" \
931 "$label" \
932 "$title" \
933 "$media"
934 retcode="$?"
935 else
936 printf '<label for="%s"' "$id"
937 [ "$title" ] && printf ' title="%s">' "$title" || echo '>'
938 echo "$label</label>"
939 fi
940 return "$retcode"
941 }
944 error_msg() {
945 local error="$1" setting="$2" line="$3"
946 if [ "$CHECK" ]; then
947 if [ "$error" -gt "0" ]; then
948 [ "$error" -lt "128" ] && printf '%s' '<span class="alert">' \
949 || printf '%s' '<span class="warning">'
950 if [ "$line" ]; then
951 /usr/sbin/tazinst check "$setting" "$INSTFILE" 2>&1 | \
952 /bin/busybox awk -v LINE="$line" '{if (NR==LINE){print}}'
953 else
954 /usr/sbin/tazinst check "$setting" "$INSTFILE" 2>&1
955 fi
956 echo '</span>'
957 fi
958 fi
959 }
962 select() {
963 local list="$1" selected="$2" name="$3" type="$4"
964 printf '%s' "$list" | \
965 /bin/busybox awk -v SELECTED="$selected" -v NONE="$(gettext "None")" \
966 -v NAME="$name" -v TYPE="$type" 'BEGIN{
967 TYPE=TYPE+0
968 print "<select name=\"" NAME "\">"
969 print "<option value=>< " NONE " ></option>"
970 }
971 {
972 printf "<option value=\"" $1 "\""
973 if ($1 == SELECTED) printf " selected"
974 if (TYPE == 0)
975 print ">" $0 "</option>"
976 if (TYPE == 1)
977 print ">" substr($0,12) "</option>"
978 if (TYPE == 2)
979 print ">" $2 "</option>"
980 }
981 END{
982 print "</select>"
983 }'
984 }
986 input()
987 {
988 local type="$1" name="$2" value="$3" selected="$4" help="$5" action="$6"
989 printf '<input type="%s" id="%s" list="list_%s" ' "$type" "$name" "$name"
990 printf 'name="%s" class="%s" ' "$(printf $name | tr [a-z] [A-Z])" "$type"
991 [ "$value" ] && printf 'value="%s" ' "$value"
992 [ "$value" == "$selected" ] && printf '%s' "checked "
993 [ "$action" ] && printf \
994 'onInput="document.getElementById(%s).checked = true;" ' "'$action'"
995 [ "$help" ] && printf 'placeholder="%s" />\n' "$help" || echo "/>"
996 }
998 input_media()
999 {
1000 local id="$1" media="$2"
1001 printf '<input type="radio" name="MEDIA" value="%s" id="%s" ' "$id" "$id"
1002 [ "$media" == "$id" ] && echo 'checked />' || echo '/>'
1005 input_hidden()
1007 local name="$1" value="$2"
1008 printf '<input type="hidden" name="%s" value="%s" />\n' "$name" "$value"
1011 datalist()
1013 local list="$1" name="$2"
1014 printf '<datalist id="list_%s">\n' "$name"
1015 # workaround for browsers that don’t support the datalist element..
1016 local script="displaySelValue(\"select_$name\",\"$name\")"
1017 printf '<select class="workaround" id="select_%s" ' "$name"
1018 printf "onChange='%s' onBlur='%s'>\n" "$script" "$script"
1020 # workaround ..end
1021 printf '%s' "$list" | \
1022 /bin/busybox awk -v NONE="$(gettext "None")" 'BEGIN{
1023 line=0
1026 TEXT=$1
1027 sub(".*/","",TEXT)
1028 printf "<option value=\"%s\">%s</option>\n", $1, TEXT
1029 line++
1031 END{
1032 if (line < 1)
1033 printf "<option value=>< %s ></option>\n", NONE
1034 }'
1035 echo "</select>"
1036 echo "</datalist>"
1039 format()
1041 list_fs="$1" selected="$2" name="$3" none="$(gettext 'Do not format')"
1042 printf '<label for="%s" ' "$name"
1043 printf 'title="%s">' "$(gettext "To format this partition, select a \
1044 filesystem, usually it's safe to use ext4")"
1045 printf '%s</label>\n' "$(gettext "Formatting option:")"
1046 printf '%s' "$list_fs" | \
1047 /bin/busybox awk -v SELECTED=$selected -v NONE="$none" -v NAME="$name" '
1048 BEGIN{
1049 RS=" "
1050 print "<select name=\"" NAME "\">"
1051 print "<option value=\"\">" NONE "</option>"
1052 line=0
1055 printf "<option value=\"" $1 "\""
1056 if ($1 == SELECTED) printf " selected"
1057 print ">" $0 "</option>"
1058 line++
1060 END{
1061 if (line < 1)
1062 print "<option value=>< " NONE " ></option>"
1063 print "</select>"
1064 }'
1067 form_start()
1069 printf '<form name="%s" method="get" ' "Form"
1070 printf 'onsubmit="return true" action="%s">\n' "$SCRIPT_NAME"
1073 form_end()
1075 echo '</form>'
1078 add_style()
1080 printf '<!-- add specific styles -->
1081 <style type="text/css">
1082 section label {
1083 display:inline-block;
1084 vertical-align:middle;
1085 width: 130px;
1087 .media label {
1088 display:inline-block;
1089 vertical-align:middle;
1090 width: 110px;
1092 .options label {
1093 display:inline-block;
1094 vertical-align:middle;
1095 width: 140px;
1097 .text {
1098 width: 350px;
1100 input {margin-bottom:3px;}
1101 span.alert {color: red}
1102 span.warning { color: darkgray}
1103 #progress {
1104 background-color: #f8f8f8;
1105 border: 1px solid #ddd;
1106 color: #666;
1107 cursor: progress;
1108 position: absolute;
1109 width: 348px;
1110 padding: 4px 4px 2px;
1112 </style>
1113 <!-- workaround for browsers that do not support the datalist element -->
1114 <style type="text/css">
1115 .workaround {width: 110px;}
1116 </style>
1117 <script>
1118 function displaySelValue(selectId,inputId)
1120 var slct = document.getElementById(selectId);
1121 var input = document.getElementById(inputId);
1122 document.getElementById("src_iso").value="";
1123 document.getElementById("src_web").value="";
1124 if (inputId =="src_iso"){
1125 document.getElementById("iso").checked = true;
1127 if (inputId =="src_web"){
1128 document.getElementById("web").checked = true;
1130 input.value = slct.options[slct.selectedIndex].value;
1132 </script>
1133 <!-- datalist workaround end -->
1134 \n'
1139 # main
1142 header
1144 case "$(GET page)" in
1145 home)
1146 xhtml_header
1147 select_action
1148 select_install
1149 select_upgrade
1150 ;;
1151 install)
1152 xhtml_header
1153 /usr/sbin/tazinst set mode install "$INSTFILE"
1154 page_redirection partitioning
1155 ;;
1156 partitioning)
1157 xhtml_header
1158 form_start
1159 display_mode
1160 select_gparted
1161 moveto_page home input
1162 form_end
1163 ;;
1164 gparted)
1165 exec_gparted
1166 xhtml_header
1167 page_redirection partitioning
1168 ;;
1169 upgrade)
1170 xhtml_header
1171 /usr/sbin/tazinst set mode upgrade "$INSTFILE"
1172 page_redirection input
1173 ;;
1174 input)
1175 xhtml_header
1176 add_style
1177 form_start
1178 display_mode
1179 select_settings
1180 moveto_page home execute
1181 form_end
1182 ;;
1183 execute)
1184 xhtml_header
1185 form_start
1186 display_mode
1187 save_settings
1188 if ! (/usr/sbin/tazinst check all $INSTFILE > /dev/null); then
1189 page_redirection "input&CHECK=yes"
1190 else
1191 tazinst_run && moveto_page home reboot \
1192 || moveto_page input failed
1193 fi
1194 form_end
1195 ;;
1196 reboot)
1197 /usr/sbin/tazinst clean "$INSTFILE"
1198 reboot ;;
1199 failed)
1200 xhtml_header
1201 form_start
1202 tazinst_log
1203 moveto_home
1204 form_end
1205 ;;
1206 *)
1207 xhtml_header
1208 if check_ressources; then
1209 /usr/sbin/tazinst new "$INSTFILE"
1210 page_redirection home
1211 fi
1212 ;;
1213 esac
1215 xhtml_footer
1217 exit 0