tazinst annotate installer.cgi @ rev 110

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