tazinst rev 13
Make .cgi compliant with the latest Tazpanel.
author | Dominique Corbex <domcox@slitaz.org> |
---|---|
date | Sat Aug 17 21:49:10 2013 +0200 (2013-08-17) |
parents | 14c1b0fdb94a |
children | 5996df6fd4a7 |
files | installer.cgi |
line diff
1.1 --- a/installer.cgi Sat Aug 17 21:44:53 2013 +0200 1.2 +++ b/installer.cgi Sat Aug 17 21:49:10 2013 +0200 1.3 @@ -11,23 +11,13 @@ 1.4 # restricted path 1.5 PATH="/usr/sbin:/usr/bin:/sbin:/bin" 1.6 1.7 -VERSION=3.90 1.8 +VERSION=3.91 1.9 1.10 -# panel location and theme 1.11 -PANEL="/var/www/tazpanel" 1.12 -STYLE="default" 1.13 +# Common functions from libtazpanel 1.14 +. lib/libtazpanel 1.15 +get_config 1.16 1.17 -# absolute paths to images 1.18 -IMAGES="/styles/$STYLE/images" 1.19 - 1.20 -# tazpanel config 1.21 -[ -r /etc/slitaz/tazpanel.conf ] && . /etc/slitaz/tazpanel.conf 1.22 - 1.23 -# include gettext helper script. 1.24 -. /usr/bin/gettext.sh 1.25 - 1.26 -# get parameters with GET, POST and FILE functions 1.27 -. /usr/bin/httpd_helper.sh 1.28 +TITLE=$(gettext 'TazPanel - Installer') 1.29 1.30 # export package name for gettext. 1.31 TEXTDOMAIN='installer' 1.32 @@ -40,20 +30,6 @@ 1.33 # tazinst setup file 1.34 INSTFILE=/root/tazinst.conf 1.35 1.36 -#------ 1.37 -# menu 1.38 -#------ 1.39 -case "$1" in 1.40 -menu) cat << EOT 1.41 -<li><a href="/installer.cgi">$(gettext 'Install')</a> 1.42 - <ul> 1.43 - <li><a href="/installer.cgi?page=menu_install">$(gettext 'Install SliTaz')</a></li> 1.44 - <li><a href="/installer.cgi?page=menu_upgrade">$(gettext 'Upgrade system')</a></li> 1.45 - </ul> 1.46 -</li> 1.47 -EOT 1.48 - exit 1.49 -esac 1.50 1.51 #----------- 1.52 # home page 1.53 @@ -61,28 +37,28 @@ 1.54 1.55 select_action() 1.56 { 1.57 - comment "welcome message" 1.58 - open_div_id "wrapper" 1.59 - h4 $(gettext "Welcome to the Slitaz Installer!") 1.60 - p $(gettext "The SliTaz Installer installs or upgrades SliTaz to a \ 1.61 + comment "Welcome message" 1.62 + open_div 'id="wrapper"' 1.63 + h4 "$(gettext "Welcome to the Slitaz Installer!")" 1.64 + p "$(gettext "The SliTaz Installer installs or upgrades SliTaz to a \ 1.65 hard disk drive from a device like a Live-CD or LiveUSB key, from a SliTaz \ 1.66 -ISO file, or from the web by downloading an ISO file.") 1.67 - h5 $(gettext "Which type of installation do you want to start?") 1.68 +ISO file, or from the web by downloading an ISO file.")" 1.69 + h5 "$(gettext "Which type of installation do you want to start?")" 1.70 close_div 1.71 } 1.72 1.73 select_install() 1.74 { 1.75 - comment "install message" 1.76 - open_div_class "box" 1.77 - h4 $(gettext "Install") 1.78 - p $(gettext "Install SliTaz on a partition of your hard disk drive. If you \ 1.79 -decide to format your partition, all data will be lost. If you do not \ 1.80 + comment "Install message" 1.81 + open_div 'class="box"' 1.82 + h4 "$(gettext 'Install')" 1.83 + p "$(gettext "Install SliTaz on a partition of your hard disk drive. If \ 1.84 +you decide to format your partition, all data will be lost. If you do not \ 1.85 format, all data except for any existing /home directory will be removed, \ 1.86 -the home directory will be kept as is.") 1.87 - p $(gettext "Before installation, you may need to create or resize \ 1.88 +the home directory will be kept as is.")" 1.89 + p "$(gettext "Before installation, you may need to create or resize \ 1.90 partitions on your hard disk drive in order to make space for SliTaz \ 1.91 -GNU/Linux. You can graphically manage your partitions with Gparted") 1.92 +GNU/Linux. You can graphically manage your partitions with Gparted")" 1.93 close_div 1.94 button "install" \ 1.95 "$(gettext 'Install SliTaz')" \ 1.96 @@ -91,13 +67,13 @@ 1.97 1.98 select_upgrade() 1.99 { 1.100 - comment "upgrade message" 1.101 - open_div_class "box" 1.102 - h4 $(gettext "Upgrade") 1.103 - p $(gettext "Upgrade an already installed SliTaz system on your hard disk \ 1.104 + comment "Upgrade message" 1.105 + open_div 'class="box"' 1.106 + h4 "$(gettext 'Upgrade')" 1.107 + p "$(gettext "Upgrade an already installed SliTaz system on your hard disk \ 1.108 drive. Your /home /etc /var/www directories will be kept, all other \ 1.109 directories will be removed. Any additional packages added to your old \ 1.110 -Slitaz system will be updated as long you have an active internet connection.") 1.111 +Slitaz system will be updated as long you have an active internet connection.")" 1.112 close_div 1.113 button "upgrade" \ 1.114 "$(gettext 'Upgrade SliTaz')" \ 1.115 @@ -110,46 +86,46 @@ 1.116 1.117 exec_gparted() 1.118 { 1.119 - /bin/su - -c "exec env DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' \ 1.120 - /usr/sbin/gparted" 1.121 + /bin/su - -c \ 1.122 + "exec env DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' /usr/sbin/gparted" 1.123 } 1.124 1.125 select_gparted() 1.126 { 1.127 - comment "gparted message" 1.128 - h5 $(gettext "Partitioning") 1.129 - open_div_class "box" 1.130 - p $(gettext "On most used systems, the hard drive is already dedicated to \ 1.131 + comment "GParted message" 1.132 + h5 "$(gettext "Partitioning")" 1.133 + open_div 'class="box"' 1.134 + p "$(gettext "On most used systems, the hard drive is already dedicated to \ 1.135 partitions for Windows<sup>™</sup>, or Linux, or another operating \ 1.136 system. You'll need to resize these partitions in order to make space for \ 1.137 SliTaz GNU/Linux. SliTaz will co-exist with other operating systems already \ 1.138 -installed on your hard drive.") 1.139 - p $(gettext "The amount of space needed depends on how much software you \ 1.140 +installed on your hard drive.")" 1.141 + p "$(gettext "The amount of space needed depends on how much software you \ 1.142 plan to install and how much space you require for users. It's conceivable \ 1.143 that you could run a minimal SliTaz system in 300 megs or less, but 2 gigs \ 1.144 -is indeed more comfy.") 1.145 - p $(gettext "A separate home partition, and a partition that will be used \ 1.146 +is indeed more comfy.")" 1.147 + p "$(gettext "A separate home partition, and a partition that will be used \ 1.148 as Linux swap space may be created if needed. Slitaz detects and uses swap \ 1.149 -partitions automatically.") 1.150 +partitions automatically.")" 1.151 close_div 1.152 - open_div_class "box" 1.153 - p $(gettext "You can graphically manage your partitions with GParted. \ 1.154 + open_div 'class="box"' 1.155 + p "$(gettext "You can graphically manage your partitions with GParted. \ 1.156 GParted is a partition editor for graphically managing your disk partitions. \ 1.157 GParted allows you to create, destroy, resize and copy partitions without \ 1.158 -data loss.") 1.159 - p $(gettext "GParted supports ext2, ext3, ext4, linux swap, ntfs and fat32 \ 1.160 -filesystems right out of the box. Support for xjs, jfs, hfs and other \ 1.161 +data loss.")" 1.162 + p "$(gettext "GParted supports ext2, ext3, ext4, linux swap, ntfs and \ 1.163 +fat32 filesystems right out of the box. Support for xjs, jfs, hfs and other \ 1.164 filesystems is available as well but you first need to add drivers for these \ 1.165 filesystems by installing the related packages xfsprogs, jfsutils, linux-hfs \ 1.166 -and so on.") 1.167 +and so on.")" 1.168 close_div 1.169 - comment "launch GParted" 1.170 + comment "Launch GParted" 1.171 button "gparted" \ 1.172 "$(gettext 'Execute GParted')" \ 1.173 "$(gettext 'Launch GParted, the partition editor tool')" 1.174 - h5 $(gettext "Continue installation") 1.175 - p $(gettext "Once you've made room for SliTaz on your drive, you should be \ 1.176 -able to continue installation.") 1.177 + h5 "$(gettext "Continue installation")" 1.178 + p "$(gettext "Once you've made room for SliTaz on your drive, you should \ 1.179 +be able to continue installation.")" 1.180 } 1.181 1.182 #------------ 1.183 @@ -162,13 +138,14 @@ 1.184 local media="$(/usr/sbin/tazinst get media "$INSTFILE")" 1.185 local source="$(/usr/sbin/tazinst get source "$INSTFILE")" 1.186 local list_media="$(/usr/sbin/tazinst list media)" 1.187 + local error 1.188 1.189 - # default media 1.190 + # set default media 1.191 [ "$media" ] || media="$(tazinst list media | cut -d ' ' -f1)" 1.192 - local error 1.193 - comment "source selection" 1.194 + 1.195 + comment "Source selection" 1.196 # cdrom 1.197 - if printf "$list_media" | grep -q "cdrom"; then 1.198 + if printf '%s' "$list_media" | grep -q "cdrom"; then 1.199 input_media "cdrom" \ 1.200 "$media" 1.201 label_media "cdrom" \ 1.202 @@ -178,13 +155,14 @@ 1.203 br 1.204 fi 1.205 # usb 1.206 - if printf "$list_media" | grep -q "usb"; then 1.207 + if printf '%s' "$list_media" | grep -q "usb"; then 1.208 input_media "usb" \ 1.209 "$media" 1.210 label_media "usb" \ 1.211 "$(gettext 'LiveUSB:')" \ 1.212 "$media" \ 1.213 - "$(gettext 'Enter the partition where SliTaz Live is located on your USB Key')" 1.214 + "$(gettext 'Enter the partition where SliTaz Live is located on 1.215 + your USB Key')" 1.216 error="$?" 1.217 select "$(/usr/sbin/tazinst list usb "$INSTFILE")" \ 1.218 "$source" \ 1.219 @@ -206,14 +184,14 @@ 1.220 input "text" \ 1.221 "src_iso" \ 1.222 "$source" "" \ 1.223 - "$(gettext 'Select an ISO or enter the full path to the ISO file')" \ 1.224 + "$(gettext 'Select an ISO or enter the full path to the ISO file')"\ 1.225 "iso" 1.226 else 1.227 input "text" \ 1.228 "src_iso" \ 1.229 "" \ 1.230 "none" \ 1.231 - "$(gettext 'Select an ISO or enter the full path to the ISO file')" \ 1.232 + "$(gettext 'Select an ISO or enter the full path to the ISO file')"\ 1.233 "iso" 1.234 fi 1.235 datalist "$(/usr/sbin/tazinst list iso "$INSTFILE")" \ 1.236 @@ -234,14 +212,14 @@ 1.237 input "text" \ 1.238 "src_web" \ 1.239 "$source" "" \ 1.240 - "$(gettext 'Select a version or enter the full url to an ISO file')" \ 1.241 + "$(gettext 'Select a version or enter the full url to an ISO file')"\ 1.242 "web" 1.243 else 1.244 input "text" \ 1.245 "src_web" \ 1.246 "" \ 1.247 "none" \ 1.248 - "$(gettext 'Select a version or enter the full url to an ISO file')" \ 1.249 + "$(gettext 'Select a version or enter the full url to an ISO file')"\ 1.250 "web" 1.251 fi 1.252 datalist "$(/usr/sbin/tazinst help web "$INSTFILE")" \ 1.253 @@ -287,7 +265,7 @@ 1.254 1.255 select_options() 1.256 { 1.257 - printf "<h4 id=\"options\">$(gettext 'Options')</h4>" 1.258 + printf '<h4 id="options">%s</h4>' "$(gettext 'Options')" 1.259 } 1.260 1.261 select_home_uuid() 1.262 @@ -398,8 +376,8 @@ 1.263 "$bootloader" 1.264 label "bootloader" \ 1.265 "$(gettext 'Install a bootloader.')" \ 1.266 - "$(gettext "Usually you should answer yes, unless you want to install a \ 1.267 -bootloader by hand yourself.")" 1.268 + "$(gettext "Usually you should answer yes, unless you want to install \ 1.269 +a bootloader by hand yourself.")" 1.270 error="$?" 1.271 error_msg "$error" \ 1.272 "bootloader" 1.273 @@ -416,8 +394,8 @@ 1.274 "$winboot" 1.275 label "winboot" \ 1.276 "$(gettext 'Enable Windows Dual-Boot.')" \ 1.277 - "$(gettext "At start-up, you will be asked whether you want to boot into \ 1.278 -Windows™ or SliTaz GNU/Linux.")" 1.279 + "$(gettext "At start-up, you will be asked whether you want to boot \ 1.280 +into Windows™ or SliTaz GNU/Linux.")" 1.281 error="$?" 1.282 error_msg "$error" \ 1.283 "winboot" 1.284 @@ -426,9 +404,9 @@ 1.285 errors_msg() 1.286 { 1.287 if [ "$CHECK" ]; then 1.288 - echo "<span class=\"alert\">" 1.289 + echo '<span class="alert">' 1.290 p $(gettext "Errors found. Please check your settings.") 1.291 - echo "</span>" 1.292 + echo '</span>' 1.293 fi 1.294 } 1.295 1.296 @@ -437,31 +415,31 @@ 1.297 local settings="$(/usr/sbin/tazinst get settings "$INSTFILE")" 1.298 CHECK=$(GET CHECK) 1.299 errors_msg 1.300 - h4 $(gettext "Select source media:") 1.301 - open_div_class "box" 1.302 - open_div_class "media" 1.303 + h4 "$(gettext "Select source media:")" 1.304 + open_div 'class="box"' 1.305 + open_div 'class="media"' 1.306 select_source 1.307 close_div 1.308 close_div 1.309 - h4 $(gettext "Select destination") 1.310 - open_div_class "box" 1.311 + h4 "$(gettext "Select destination")" 1.312 + open_div 'class="box"' 1.313 select_root_uuid 1.314 - printf "$settings" | grep -q "root_format" \ 1.315 + printf '%s' "$settings" | grep -q "root_format" \ 1.316 && select_root_format 1.317 close_div 1.318 select_options 1.319 - open_div_class "options" 1.320 - printf "$settings" | grep -q "home_uuid" && select_home_uuid 1.321 - printf "$settings" | grep -q "home_format" \ 1.322 + open_div 'class="options"' 1.323 + printf '%s' "$settings" | grep -q "home_uuid" && select_home_uuid 1.324 + printf '%s' "$settings" | grep -q "home_format" \ 1.325 && select_home_format 1.326 - printf "$settings" | grep -q "hostname" && select_hostname 1.327 - printf "$settings" | grep -q "root_pwd" && select_root_pwd 1.328 - printf "$settings" | grep -q "user_login" && select_user_login 1.329 - printf "$settings" | grep -q "user_pwd" && select_user_pwd 1.330 + printf '%s' "$settings" | grep -q "hostname" && select_hostname 1.331 + printf '%s' "$settings" | grep -q "root_pwd" && select_root_pwd 1.332 + printf '%s' "$settings" | grep -q "user_login" && select_user_login 1.333 + printf '%s' "$settings" | grep -q "user_pwd" && select_user_pwd 1.334 close_div 1.335 - open_div_class "bootloader" 1.336 - printf "$settings" | grep -q "bootloader" && select_bootloader 1.337 - printf "$settings" | grep -q "winboot" && select_winboot 1.338 + open_div 'class="bootloader"' 1.339 + printf '%s' "$settings" | grep -q "bootloader" && select_bootloader 1.340 + printf '%s' "$settings" | grep -q "winboot" && select_winboot 1.341 close_div 1.342 br 1.343 } 1.344 @@ -572,8 +550,8 @@ 1.345 1.346 tazinst_log() 1.347 { 1.348 - h4 $(gettext "Tazinst log") 1.349 - printf "<pre>$(/usr/sbin/tazinst log | sed 's/\%/ percent/g')</pre>" 1.350 + h4 "$(gettext "Tazinst log")" 1.351 + printf '<pre>%s</pre>' "$(/usr/sbin/tazinst log | sed 's/\%/ percent/g')" 1.352 } 1.353 1.354 1.355 @@ -586,22 +564,22 @@ 1.356 local mode="$(/usr/sbin/tazinst get mode "$INSTFILE")" 1.357 case $mode in 1.358 install) 1.359 - open_div_id "wrapper" 1.360 - h4 $(gettext "Install SliTaz") 1.361 - p $(gettext "You're going to install SliTaz on a partition of your \ 1.362 -hard disk drive. If you decide to format your HDD, all data will be \ 1.363 + open_div 'id="wrapper"' 1.364 + h4 "$(gettext "Install SliTaz")" 1.365 + p "$(gettext "You're going to install SliTaz on a partition of \ 1.366 +your hard disk drive. If you decide to format your HDD, all data will be \ 1.367 lost. If you do not format, all data except for any existing /home \ 1.368 -directory will be removed, the home directory will be kept as is.") 1.369 +directory will be removed, the home directory will be kept as is.")" 1.370 close_div 1.371 ;; 1.372 upgrade) 1.373 - open_div_id "wrapper" 1.374 - h4 $(gettext "Upgrade SliTaz") 1.375 - p $(gettext "You're going to upgrade an already installed SliTaz \ 1.376 + open_div 'id="wrapper"' 1.377 + h4 "$(gettext "Upgrade SliTaz")" 1.378 + p "$(gettext "You're going to upgrade an already installed SliTaz \ 1.379 system on your hard disk drive. Your /home /etc /var/www directories \ 1.380 will be kept, all other directories will be removed. Any additional \ 1.381 packages added to your old Slitaz system will be updated as long you \ 1.382 -have an active internet connection.") 1.383 +have an active internet connection.")" 1.384 close_div 1.385 ;; 1.386 esac 1.387 @@ -609,8 +587,8 @@ 1.388 1.389 moveto_page() 1.390 { 1.391 - local back="$1" next="$2" back_msg next_msg 1.392 - case "$back" in 1.393 + local back_page="$1" next_page="$2" back_msg next_msg 1.394 + case "$back_page" in 1.395 partitioning) 1.396 back_msg=$(gettext 'Back to partitioning') ;; 1.397 input) 1.398 @@ -618,7 +596,7 @@ 1.399 *) 1.400 back_msg=$(gettext 'Back to Installer Start Page') ;; 1.401 esac 1.402 - case "$next" in 1.403 + case "$next_page" in 1.404 execute|run) 1.405 next_msg=$(gettext 'Proceed to SliTaz installation') ;; 1.406 reboot) 1.407 @@ -631,11 +609,8 @@ 1.408 next_msg=$(gettext 'Back to Installer Start Page') ;; 1.409 esac 1.410 hr 1.411 - input_hidden "page" \ 1.412 - "$next" 1.413 - a "$back" \ 1.414 - "$SCRIPT_NAME?page=$back" \ 1.415 - "$back_msg" 1.416 + input_hidden "page" "$next_page" 1.417 + a "$back_page" "$back_msg" 1.418 input "submit" \ 1.419 "" \ 1.420 "$next_msg" 1.421 @@ -643,10 +618,7 @@ 1.422 1.423 moveto_home() 1.424 { 1.425 - local msg=$(gettext 'Back to Installer Start Page') 1.426 - a "home" \ 1.427 - "$SCRIPT_NAME?page=home" \ 1.428 - "$msg" 1.429 + a "home" "$(gettext 'Back to Installer Start Page')" 1.430 } 1.431 1.432 page_redirection() 1.433 @@ -690,7 +662,7 @@ 1.434 # check tazinst minimum version 1.435 v=$(/usr/sbin/tazinst version | tr -d '[:alpha:]') 1.436 r=$TAZINST_MINIMUM_VERSION 1.437 - if ! (echo "$v" | /bin/busybox awk -v r=$r \ 1.438 + if ! (printf '%s' "$v" | /bin/busybox awk -v r=$r \ 1.439 '{v=$v+0}{ if (v < r) exit 1}') ; then 1.440 h4 $(gettext "Tazinst Error") 1.441 p $(gettext "<strong>tazinst</strong>, the slitaz-installer \ 1.442 @@ -703,7 +675,7 @@ 1.443 # check tazinst maximum version 1.444 v=$(/usr/sbin/tazinst version | tr -d '[:alpha:]') 1.445 r=$TAZINST_MAXIMUM_VERSION 1.446 - if ! (echo "$v" | /bin/busybox awk -v r=$r \ 1.447 + if ! (printf '%s' "$v" | /bin/busybox awk -v r=$r \ 1.448 '{v=$v+0}{ if (v > r) exit 1}') ; then 1.449 h4 $(gettext "Tazinst Error") 1.450 p $(gettext "<strong>tazinst</strong>, the slitaz-installer \ 1.451 @@ -724,78 +696,77 @@ 1.452 1.453 br() 1.454 { 1.455 - echo "<br />" 1.456 + echo '<br />' 1.457 } 1.458 1.459 hr() 1.460 { 1.461 - echo "<hr />" 1.462 + echo '<hr />' 1.463 } 1.464 1.465 comment() 1.466 { 1.467 - echo "<!-- $@ -->" 1.468 + printf '<!-- %s -->\n' "$@" 1.469 } 1.470 1.471 a() 1.472 { 1.473 - echo "<a class=\"button\" value=\"$1\" href=\"$2\">$3</a>" 1.474 + local page="$1" text="$2" 1.475 + printf '<a class="button" value="%s" href="%s?page=%s">%s</a>\n' \ 1.476 + "$page" "$SCRIPT_NAME" "$page" "$text" 1.477 +} 1.478 + 1.479 +button() 1.480 +{ 1.481 + local action="$1" msg="$2" title="$3" 1.482 + printf '<a class="button" href="%s?page=%s" title="%s">%s</a>\n' \ 1.483 + "$SCRIPT_NAME" "$action" "$title" "$msg" 1.484 } 1.485 1.486 open_div() 1.487 { 1.488 - echo "<div>" 1.489 -} 1.490 - 1.491 -open_div_id() 1.492 -{ 1.493 - echo "<div id=\"$1\">" 1.494 -} 1.495 - 1.496 -open_div_class() 1.497 -{ 1.498 - echo "<div class=\"$1\">" 1.499 + [ "$1" ] && printf '<div %s>\n' "$1" || echo '<div>' 1.500 } 1.501 1.502 close_div() 1.503 { 1.504 - echo "</div>" 1.505 + echo '</div>' 1.506 } 1.507 1.508 p() 1.509 { 1.510 - echo "<p>$@</p>" 1.511 + printf '<p>%s</p>\n' "$@" 1.512 } 1.513 1.514 h4() 1.515 { 1.516 - echo "<h4>$@</h4>" 1.517 + printf '<h4>%s</h4>\n' "$@" 1.518 } 1.519 1.520 h5() 1.521 { 1.522 - echo "<h5>$@</h5>" 1.523 + printf '<h5>%s</h5>\n' "$@" 1.524 } 1.525 1.526 label() 1.527 { 1.528 local setting="$1" label="$2" title="$3" name="$4" error=0 1.529 [ -z "$name" ] && name="$setting" 1.530 - printf "<label for=\"$name\"" 1.531 - [ "$title" ] && echo " title=\"$title\">" || echo ">" 1.532 + printf '<label for="%s"' "$name" 1.533 + [ "$title" ] && printf ' title="%s">' "$title" || printf '%s' '>' 1.534 # display label in red in case of error 1.535 if [ "$CHECK" ]; then 1.536 /usr/sbin/tazinst check "$setting" "$INSTFILE" 1.537 error="$?" 1.538 [ "$error" -gt "0" ] && [ "$error" -lt "127" ] && \ 1.539 - printf "<span class=\"alert\">" 1.540 - printf "$label" 1.541 + printf '%s' '<span class="alert">' 1.542 + printf '%s' "$label" 1.543 [ "$error" -gt "0" ] && [ "$error" -lt "127" ] && \ 1.544 - printf "<sup>*</sup></span>" 1.545 + printf '%s' "<sup>*</sup></span>" 1.546 else 1.547 - printf "$label" 1.548 + printf '%s' "$label" 1.549 fi 1.550 - echo "</label>" 1.551 + echo '</label>' 1.552 return "$error" 1.553 } 1.554 1.555 @@ -809,8 +780,8 @@ 1.556 "$media" 1.557 retcode="$?" 1.558 else 1.559 - printf "<label for=\"$id\"" 1.560 - [ "$title" ] && echo " title=\"$title\">" || echo ">" 1.561 + printf '<label for="%s"' "$id" 1.562 + [ "$title" ] && printf ' title="%s">' "$title" || echo '>' 1.563 echo "$label</label>" 1.564 fi 1.565 return "$retcode" 1.566 @@ -821,24 +792,25 @@ 1.567 local error="$1" setting="$2" line="$3" 1.568 if [ "$CHECK" ]; then 1.569 if [ "$error" -gt "0" ]; then 1.570 - [ "$error" -lt "128" ] && printf "<span class=\"alert\">" \ 1.571 - || printf "<span class=\"warning\">" 1.572 + [ "$error" -lt "128" ] && printf '%s' '<span class="alert">' \ 1.573 + || printf '%s' '<span class="warning">' 1.574 if [ "$line" ]; then 1.575 /usr/sbin/tazinst check "$setting" "$INSTFILE" 2>&1 | \ 1.576 /bin/busybox awk -v LINE="$line" '{if (NR==LINE){print}}' 1.577 else 1.578 /usr/sbin/tazinst check "$setting" "$INSTFILE" 2>&1 1.579 fi 1.580 - echo "</span>" 1.581 + echo '</span>' 1.582 fi 1.583 fi 1.584 } 1.585 1.586 select() 1.587 { 1.588 - local list="$1" selected="$2" name="$3" type="$4" none="$(gettext 'None')" 1.589 - printf "$list" | /bin/busybox awk -v SELECTED="$selected" -v NONE="$none" \ 1.590 - -v NAME="$name" -v TYPE="$type" 'BEGIN{ 1.591 + local list="$1" selected="$2" name="$3" type="$4" 1.592 + printf '%s' "$list" | \ 1.593 + /bin/busybox awk -v SELECTED="$selected" -v NONE="$(gettext "None")" \ 1.594 + -v NAME="$name" -v TYPE="$type" 'BEGIN{ 1.595 TYPE=TYPE+0 1.596 print "<select name=\"" NAME "\">" 1.597 print "<option value=>< " NONE " ></option>" 1.598 @@ -861,48 +833,51 @@ 1.599 input() 1.600 { 1.601 local type="$1" name="$2" value="$3" selected="$4" help="$5" action="$6" 1.602 - printf "<input type=\"$type\" id=\"$name\" list=\"list_$name\" " 1.603 - printf "name=\"$(printf $name | tr [a-z] [A-Z])\" class=\"$type\" " 1.604 - [ "$value" ] && printf "value=\"$value\" " 1.605 - [ "$value" == "$selected" ] && printf "checked " 1.606 + printf '<input type="%s" id="%s" list="list_%s" ' "$type" "$name" "$name" 1.607 + printf 'name="%s" class="%s" ' "$(printf $name | tr [a-z] [A-Z])" "$type" 1.608 + [ "$value" ] && printf 'value="%s" ' "$value" 1.609 + [ "$value" == "$selected" ] && printf '%s' "checked " 1.610 [ "$action" ] && printf \ 1.611 - "onInput=\"document.getElementById('$action').checked = true;\" " 1.612 - [ "$help" ] && echo "placeholder=\"$help\" />" || echo "/>" 1.613 + 'onInput="document.getElementById(%s).checked = true;" ' "'$action'" 1.614 + [ "$help" ] && printf 'placeholder="%s" />\n' "$help" || echo "/>" 1.615 } 1.616 1.617 input_media() 1.618 { 1.619 local id="$1" media="$2" 1.620 - echo -n "<input type=\"radio\" name=\"MEDIA\" value=\"$id\" id=\"$id\" " 1.621 - echo "$([ "$media" == "$id" ] && echo 'checked') />" 1.622 + printf '<input type="radio" name="MEDIA" value="%s" id="%s" ' "$id" "$id" 1.623 + [ "$media" == "$id" ] && echo 'checked />' || echo '/>' 1.624 } 1.625 1.626 input_hidden() 1.627 { 1.628 - echo "<input type=\"hidden\" name=\"$1\" value=\"$2\" />" 1.629 + local name="$1" value="$2" 1.630 + printf '<input type="hidden" name="%s" value="%s" />\n' "$name" "$value" 1.631 } 1.632 1.633 datalist() 1.634 { 1.635 - local list="$1" name="$2" none="$(gettext 'None')" 1.636 - echo "<datalist id=\"list_$name\">" 1.637 + local list="$1" name="$2" 1.638 + printf '<datalist id="list_%s">\n' "$name" 1.639 # workaround for browsers that don’t support the datalist element.. 1.640 - echo "<select class=\"workaround\" id=\"sel_$name\" \ 1.641 -onChange='displaySelValue(\"sel_$name\",\"$name\")' \ 1.642 -onBlur='displaySelValue(\"sel_$name\",\"$name\")'>" 1.643 + local script="displaySelValue(\"select_$name\",\"$name\")" 1.644 + printf '<select class="workaround" id="select_%s" ' "$name" 1.645 + printf "onChange='%s' onBlur='%s'>\n" "$script" "$script" 1.646 + 1.647 # workaround ..end 1.648 - printf "$list" | /bin/busybox awk -v NONE="$none" 'BEGIN{ 1.649 + printf '%s' "$list" | \ 1.650 + /bin/busybox awk -v NONE="$(gettext "None")" 'BEGIN{ 1.651 line=0 1.652 } 1.653 { 1.654 TEXT=$1 1.655 sub(".*/","",TEXT) 1.656 - print "<option value=\"" $1 "\">" TEXT "</option>" 1.657 + printf "<option value=\"%s\">%s</option>\n", $1, TEXT 1.658 line++ 1.659 } 1.660 END{ 1.661 if (line < 1) 1.662 - print "<option value=>< " NONE " ></option>" 1.663 + printf "<option value=>< %s ></option>\n", NONE 1.664 }' 1.665 echo "</select>" 1.666 echo "</datalist>" 1.667 @@ -911,13 +886,13 @@ 1.668 format() 1.669 { 1.670 list_fs="$1" selected="$2" name="$3" none="$(gettext 'Do not format')" 1.671 - cat << EOT 1.672 -<label for="$name" title="$(gettext "To format this partition, \ 1.673 -select a filesystem, usually it's safe to use ext4")"> 1.674 -$(gettext "Formatting option:")</label> 1.675 -EOT 1.676 - printf "$list_fs" | /bin/busybox awk -v SELECTED=$selected -v NONE="$none" \ 1.677 - -v NAME="$name" 'BEGIN{ 1.678 + printf '<label for="%s" ' "$name" 1.679 + printf 'title="%s">' "$(gettext "To format this partition, select a \ 1.680 +filesystem, usually it's safe to use ext4")" 1.681 + printf '%s</label>\n' "$(gettext "Formatting option:")" 1.682 + printf '%s' "$list_fs" | \ 1.683 + /bin/busybox awk -v SELECTED=$selected -v NONE="$none" -v NAME="$name" ' 1.684 +BEGIN{ 1.685 RS=" " 1.686 print "<select name=\"" NAME "\">" 1.687 print "<option value=\"\">" NONE "</option>" 1.688 @@ -936,129 +911,74 @@ 1.689 }' 1.690 } 1.691 1.692 -button() 1.693 -{ 1.694 - local action="$1" msg="$2" title="$3" 1.695 - echo "<a class=\"button\" href=\"$SCRIPT_NAME?page=$action\" \ 1.696 -title=\"$title\">$msg</a>" 1.697 -} 1.698 - 1.699 form_start() 1.700 { 1.701 - local name="$1" 1.702 - cat <<EOT 1.703 -<form name="Form_$name" method="get" onsubmit="return true" \ 1.704 -action="$SCRIPT_NAME"> 1.705 -EOT 1.706 + printf '<form name="%s" method="get" ' "Form" 1.707 + printf 'onsubmit="return true" action="%s">\n' "$SCRIPT_NAME" 1.708 } 1.709 1.710 form_end() 1.711 { 1.712 - echo "</form>" 1.713 + echo '</form>' 1.714 } 1.715 1.716 -xhtml_header() 1.717 +add_style() 1.718 { 1.719 - cat << EOT 1.720 -<!DOCTYPE html> 1.721 -<html xmlns="http://www.w3.org/1999/xhtml" lang="$(echo $LANG | cut -f1 -d_)"> 1.722 -<head> 1.723 - <title>$(gettext "SliTaz Installer")</title> 1.724 - <meta charset="utf-8" /> 1.725 - <link rel="shortcut icon" href="/styles/$STYLE/favicon.ico" /> 1.726 - <style type="text/css"> 1.727 - .box label { 1.728 - display:inline-block; 1.729 - vertical-align:middle; 1.730 - width: 130px; 1.731 + printf '<!-- add specific styles --> 1.732 +<style type="text/css"> 1.733 + .box label { 1.734 + display:inline-block; 1.735 + vertical-align:middle; 1.736 + width: 130px; 1.737 + } 1.738 + .media label { 1.739 + display:inline-block; 1.740 + vertical-align:middle; 1.741 + width: 110px; 1.742 + } 1.743 + .options label { 1.744 + display:inline-block; 1.745 + vertical-align:middle; 1.746 + width: 140px; 1.747 + } 1.748 + .box .text { 1.749 + width: 350px; 1.750 + } 1.751 + input {margin-bottom:3px;} 1.752 + span.alert {color: red} 1.753 + span.warning { color: darkgray} 1.754 + #progress { 1.755 + background-color: #f8f8f8; 1.756 + border: 1px solid #ddd; 1.757 + color: #666; 1.758 + cursor: progress; 1.759 + position: absolute; 1.760 + width: 348px; 1.761 + padding: 4px 4px 2px; 1.762 + } 1.763 +</style> 1.764 +<!-- workaround for browsers that do not support the datalist element --> 1.765 +<style type="text/css"> 1.766 + .workaround {width: 110px;} 1.767 +</style> 1.768 +<script> 1.769 + function displaySelValue(selectId,inputId) 1.770 + { 1.771 + var slct = document.getElementById(selectId); 1.772 + var input = document.getElementById(inputId); 1.773 + document.getElementById("src_iso").value=""; 1.774 + document.getElementById("src_web").value=""; 1.775 + if (inputId =="src_iso"){ 1.776 + document.getElementById("iso").checked = true; 1.777 } 1.778 - .media label { 1.779 - display:inline-block; 1.780 - vertical-align:middle; 1.781 - width: 110px; 1.782 + if (inputId =="src_web"){ 1.783 + document.getElementById("web").checked = true; 1.784 } 1.785 - .options label { 1.786 - display:inline-block; 1.787 - vertical-align:middle; 1.788 - width: 140px; 1.789 - } 1.790 - .box .text { 1.791 - width: 350px; 1.792 - } 1.793 - input {margin-bottom:3px;} 1.794 - span.alert {color: red} 1.795 - span.warning { color: darkgray} 1.796 - #progress { 1.797 - background-color: #f8f8f8; 1.798 - border: 1px solid #ddd; 1.799 - color: #666; 1.800 - cursor: progress; 1.801 - position: absolute; 1.802 - width: 348px; 1.803 - padding: 4px 4px 2px; 1.804 - } 1.805 - </style> 1.806 - <link rel="stylesheet" type="text/css" href="/styles/$STYLE/style.css" /> 1.807 - <!-- Function to hide the loading message when page is generated. --> 1.808 - <script type="text/javascript"> 1.809 - function showProgress(){ 1.810 - document.getElementById("progress").style.display='none'; 1.811 - } 1.812 - </script> 1.813 - <!-- workaround for browsers that don’t support the datalist element --> 1.814 - <style type="text/css"> 1.815 - .workaround {width: 110px;} 1.816 - </style> 1.817 - <script> 1.818 - function displaySelValue(selectId,inputId) 1.819 - { 1.820 - var slct = document.getElementById(selectId); 1.821 - var input = document.getElementById(inputId); 1.822 - document.getElementById("src_iso").value=""; 1.823 - document.getElementById("src_web").value=""; 1.824 - if (inputId =="src_iso"){ 1.825 - document.getElementById("iso").checked = true; 1.826 - } 1.827 - if (inputId =="src_web"){ 1.828 - document.getElementById("web").checked = true; 1.829 - } 1.830 - input.value = slct.options[slct.selectedIndex].value; 1.831 - 1.832 - } 1.833 - </script> 1.834 - <!-- workaround end --> 1.835 -</head> 1.836 -<body onload="showProgress()"> 1.837 -</head> 1.838 -<body> 1.839 - 1.840 -<!-- 1.841 -<div id="header"> 1.842 - <h1>$(gettext "SliTaz Installer")</h1> 1.843 -</div> 1.844 ---> 1.845 - 1.846 -<!-- Page content --> 1.847 -<div id="content"> 1.848 -EOT 1.849 -} 1.850 - 1.851 -xhtml_footer() 1.852 -{ 1.853 - cat << EOT 1.854 -<!-- End of content--> 1.855 -</div> 1.856 - 1.857 -<div id="footer"> 1.858 - $(gettext "Copyright") © 2012–2013 1.859 - <a href="http://www.slitaz.org/">SliTaz GNU/Linux</a> 1.860 - — <a href="/index.cgi?file=/usr/share/licenses/bsd.txt"> 1.861 - $(gettext "BSD License")</a> 1.862 -</div> 1.863 - 1.864 -</body> 1.865 -</html> 1.866 -EOT 1.867 + input.value = slct.options[slct.selectedIndex].value; 1.868 + } 1.869 +</script> 1.870 +<!-- datalist workaround end --> 1.871 +\n' 1.872 } 1.873 1.874 1.875 @@ -1100,10 +1020,11 @@ 1.876 ;; 1.877 input) 1.878 xhtml_header 1.879 + add_style 1.880 form_start 1.881 display_mode 1.882 select_settings 1.883 - moveto_page partitioning execute 1.884 + moveto_page home execute 1.885 form_end 1.886 ;; 1.887 execute)