tazinst annotate installer.cgi @ rev 17

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