tazinst annotate installer.cgi @ rev 91

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