tazinst annotate slitaz-installer @ rev 2

Use UUIDs, boot delay on mobile disks, GPT support, boot flag, new slitaz-installer and web frontends
author Dominique Corbex <domcox@slitaz.org>
date Thu Feb 14 13:12:12 2013 +0100 (2013-02-14)
parents
children 5996df6fd4a7
rev   line source
domcox@2 1 #!/bin/sh
domcox@2 2 #"
domcox@2 3 # slitaz-installer - A CLI frontend to tazinst, the
domcox@2 4 # SliTaz GNU/Linux installer
domcox@2 5 #
domcox@2 6 # (C) 2007-2013 SliTaz - GNU General Public License v3.
domcox@2 7 #
domcox@2 8 # Authors : Christophe Lincoln <pankso@slitaz.org>
domcox@2 9 # Dominique Corbex <domcox@slitaz.org>
domcox@2 10 #
domcox@2 11
domcox@2 12 TAZINST_REQUIRED_VERSION="2.98"
domcox@2 13 BACKLIST="SliTaz GNU/Linux installer"
domcox@2 14 DIALOG=dialog
domcox@2 15 VERSION="3.90"
domcox@2 16
domcox@2 17 #--------------
domcox@2 18 # msgs section
domcox@2 19 #--------------
domcox@2 20
domcox@2 21 # info msgs
domcox@2 22
domcox@2 23 MODE_MSG="\n$(gettext "Welcome to the slitaz-installer").\n
domcox@2 24 \Z2$(gettext "Which type of installation do you want to start?")\Zn\n"
domcox@2 25
domcox@2 26 MEDIA_MSG="\n$(gettext "SliTaz can be installed from different media.")\n\n\
domcox@2 27 \Z2$(gettext "Select a media from the following list:")\Zn\n"
domcox@2 28
domcox@2 29 SOURCE_USB_MSG="\n$(gettext "You have selected the option to install SliTaz \
domcox@2 30 from an USB Key")\n\n\
domcox@2 31 \Z2$(gettext "Enter the partition where SliTaz Live is located:"):\Zn\n"
domcox@2 32
domcox@2 33 SOURCE_ISO_MSG="\n$(gettext "You have selected the option to install SliTaz \
domcox@2 34 from an ISO file located on a local disk.")\n\n\
domcox@2 35 \Z2$(gettext "Please, select a file below:")\Zn\n"
domcox@2 36
domcox@2 37 SOURCE_WEB_MSG="\n$(gettext "You have selected the option to install SliTaz \
domcox@2 38 from the web")\n\n\\Z2$(gettext "Please, select a version:")\Zn\n"
domcox@2 39
domcox@2 40 SOURCE_DEF_MSG="\n$(gettext "Select the source"):\n"
domcox@2 41
domcox@2 42 ROOT_UUID_DEFAULT_MSG="$(gettext "\nDrive selection")\n\n\Z2$(gettext "Please specify the partition where to install SliTaz:")\Zn\n"
domcox@2 43
domcox@2 44 ROOT_UUID_UPGRADE_MSG="$(gettext "The installer will upgrade the existing \
domcox@2 45 SliTaz system by saving all configuration files and the list of installed \
domcox@2 46 packages. Then, it will clean the partition and install the new version \
domcox@2 47 of SliTaz, restore the configuration files and reinstall any packages which \
domcox@2 48 are not present on the cdrom.
domcox@2 49 You will need an active internet connection before upgrading.")\n \
domcox@2 50 \Z2$(gettext "Partition containing the system to upgrade:")\Zn\n"
domcox@2 51
domcox@2 52 ROOT_FORMAT_MSG="\n$(gettext "Only the filesystems actually installed on your \
domcox@2 53 system are listed. If you intend to use another filesystem, you have to \
domcox@2 54 install it before. \
domcox@2 55 Unless you know what you are doing, it's safe to use ext2, ext3 or ext4.\n\n\
domcox@2 56 \Z2To format this partition, please select a filesystem below:")\Zn\n"
domcox@2 57
domcox@2 58 HOME_UUID_MSG="\n$(gettext "Separate /home partition")\n\n\
domcox@2 59 \Z2$(gettext "Please, select the partition to use:")\Zn\n"
domcox@2 60
domcox@2 61 HOSTNAME_MSG="\n$(gettext "Hostname configuration allows you to specify the \
domcox@2 62 machine name. The hostname is used internally to identify the host on the \
domcox@2 63 network. This value can be changed after the system is installed.\n\n\
domcox@2 64 \Z2Enter a hostname:\Zn\n")"
domcox@2 65
domcox@2 66 ROOT_PWD_MSG="\n$(gettext "The root administrator privilege lets you manage \
domcox@2 67 and configure the full system. A root user can damage your system so you \
domcox@2 68 should always setup a strong password with special characters and/or numbers.\
domcox@2 69 ")\n\n\
domcox@2 70 \Z2$(gettext "Enter the password for root:")\Zn\n"
domcox@2 71
domcox@2 72 USER_LOGIN_MSG="\n$(gettext "The default user for the system will have their \
domcox@2 73 personal files stored in /home/*user* (and will be automatically added to the \
domcox@2 74 audio group)")\n\n\Z2$(gettext "Enter the name of the first user:")\Zn\n"
domcox@2 75
domcox@2 76 USER_PWD_MSG="\n$(gettext "The password for default user").
domcox@2 77 $(gettext "It may be a security risk if too weak and should always be strong \
domcox@2 78 if you use a SSH connection through the web.")\n
domcox@2 79 \Z2$(gettext "Enter the password for the default user:")\Zn\n"
domcox@2 80
domcox@2 81 END_OF_INSTALL_MSG="\n$(gettext "Installation is now finished, you can exit \
domcox@2 82 the installer or reboot on your new SliTaz GNU/Linux operating system")."
domcox@2 83
domcox@2 84
domcox@2 85 # questions msgs
domcox@2 86
domcox@2 87 ASK_ROOT_FORMAT="\n$(gettext "The next step lets you format the target \
domcox@2 88 partition. Choose between robust, stable and/or journaled filesystem. If the \
domcox@2 89 partition is already formated you can skip this stage, if not just accept.\n
domcox@2 90 Warning! formating a partition will destroy all current data.\n
domcox@2 91 \Z2Do you wish to format the partition ?\Zn")"
domcox@2 92
domcox@2 93 ASK_HOME_UUID="\n$(gettext "On most GNU/Linux systems users personal \
domcox@2 94 files are stored in the directory /home. Home can be on a separate partition \
domcox@2 95 or another hard disk.\n
domcox@2 96 \Z2DO you want to use a separate Home partition ?\Zn")"
domcox@2 97
domcox@2 98 ASK_HOME_FORMAT="\n$(gettext "/home will be installed on a separate partition. \
domcox@2 99 The next step lets you format the /home partition. If the partition \
domcox@2 100 is already formated you can skip this stage, if not just accept. Warning \
domcox@2 101 formating a partition will destroy all current data.\n
domcox@2 102 \Z2Do you wish to format the /home partition ?\Zn")"
domcox@2 103
domcox@2 104 ASK_BOOTLOADER="\n$(gettext "You have now the option to install a \
domcox@2 105 bootloader which is capable of booting almost any kind of operating system.\n\n\
domcox@2 106 If you want to use an existing bootloader installation, skip this step \
domcox@2 107 and configure your bootloader to boot SliTaz (refer to your bootloader's \
domcox@2 108 documentation on how to do this)").\n\n\
domcox@2 109 \Z2$(gettext "Install a bootloader?")\Zn\n"
domcox@2 110
domcox@2 111 ASK_WINBOOT="\n$(gettext "Do you want to implement a dual-boot with \
domcox@2 112 Windows? At start-up, you will be asked whether you want to boot into \
domcox@2 113 Windows or SliTaz GNU/Linux.\n
domcox@2 114 \Z2Install a dual-boot with Windows ?")\n"
domcox@2 115
domcox@2 116 ASK_SUMMARY="$(gettext "Installation settings summary and last chance to \
domcox@2 117 cancel or restart all installation steps.")\n
domcox@2 118 \Z2Go and install SliTaz?\Zn\n\n"
domcox@2 119
domcox@2 120 EMPTY_MENU_MSG="\n$(gettext "Sorry, no device, nor file found or available.")"
domcox@2 121
domcox@2 122 #---------------"
domcox@2 123 # check section
domcox@2 124 #---------------
domcox@2 125
domcox@2 126 check_tazinst()
domcox@2 127 {
domcox@2 128 local version
domcox@2 129 # search for tazinst
domcox@2 130 if ! [ -x /usr/sbin/tazinst ] ; then
domcox@2 131 printf "$(gettext "Error 2: ")
domcox@2 132 $(gettext "The lightweight SliTaz HDD installer 'tazinst' is missing.
domcox@2 133 Check permissions, or reinstall the slitaz-tools package.")\n"
domcox@2 134 exit 2
domcox@2 135 fi
domcox@2 136 # check version
domcox@2 137 version=$(tazinst version | tr -d '[:alpha:]')
domcox@2 138 if ! (echo "$version" | awk -v req="$TAZINST_REQUIRED_VERSION" '
domcox@2 139 {ver=$0+0}{ if (ver < req) exit 1}') ; then
domcox@2 140 printf "$(gettext "Error 2: ")
domcox@2 141 $(gettext "The lightweight SliTaz HDD installer tazinst ($version) is not
domcox@2 142 at the required version ($TAZINST_REQUIRED_VERSION), use tazinst in a xterm or
domcox@2 143 reinstall the slitaz-tools package.")\n"
domcox@2 144 exit 2
domcox@2 145 fi
domcox@2 146 }
domcox@2 147
domcox@2 148 #----------------
domcox@2 149 # dialog section
domcox@2 150 #----------------
domcox@2 151
domcox@2 152 # select msgs to display
domcox@2 153 msg()
domcox@2 154 {
domcox@2 155 local option="$1"
domcox@2 156 case "$option" in
domcox@2 157 mode)
domcox@2 158 printf "$MODE_MSG" ;;
domcox@2 159 media)
domcox@2 160 printf "$MEDIA_MSG" ;;
domcox@2 161 source)
domcox@2 162 local media="$(tazinst get media)"
domcox@2 163 case "$media" in
domcox@2 164 usb)
domcox@2 165 printf "$SOURCE_USB_MSG" ;;
domcox@2 166 iso)
domcox@2 167 printf "$SOURCE_ISO_MSG" ;;
domcox@2 168 web)
domcox@2 169 printf "$SOURCE_WEB_MSG" ;;
domcox@2 170 *)
domcox@2 171 printf "$SOURCE_DEF_MSG" ;;
domcox@2 172 esac ;;
domcox@2 173 root_uuid)
domcox@2 174 local mode="$(tazinst get mode)"
domcox@2 175 [ "$mode" = "upgrade" ] && printf "$ROOT_UUID_UPGRADE_MSG" \
domcox@2 176 || printf "$ROOT_UUID_DEFAULT_MSG" ;;
domcox@2 177 root_format|home_format)
domcox@2 178 printf "$ROOT_FORMAT_MSG" ;;
domcox@2 179 home_uuid)
domcox@2 180 printf "$HOME_UUID_MSG" ;;
domcox@2 181 hostname)
domcox@2 182 printf "$HOSTNAME_MSG" ;;
domcox@2 183 root_pwd)
domcox@2 184 printf "$ROOT_PWD_MSG" ;;
domcox@2 185 user_login)
domcox@2 186 printf "$USER_LOGIN_MSG" ;;
domcox@2 187 user_pwd)
domcox@2 188 printf "$USER_PWD_MSG" ;;
domcox@2 189 esac
domcox@2 190 }
domcox@2 191
domcox@2 192 # select questions to ask
domcox@2 193 ask()
domcox@2 194 {
domcox@2 195 local option="$1"
domcox@2 196 case "$option" in
domcox@2 197 root_format)
domcox@2 198 printf "$ASK_ROOT_FORMAT" ;;
domcox@2 199 home_uuid)
domcox@2 200 printf "$ASK_HOME_UUID" ;;
domcox@2 201 home_format)
domcox@2 202 printf "$ASK_HOME_FORMAT" ;;
domcox@2 203 bootloader)
domcox@2 204 printf "$ASK_BOOTLOADER" ;;
domcox@2 205 winboot)
domcox@2 206 printf "$ASK_WINBOOT" ;;
domcox@2 207 summary)
domcox@2 208 printf "$ASK_SUMMARY"
domcox@2 209
domcox@2 210 esac
domcox@2 211 }
domcox@2 212
domcox@2 213 # make text dialog compatible
domcox@2 214 text2dlg()
domcox@2 215 {
domcox@2 216 printf "$@" | awk '
domcox@2 217 {
domcox@2 218 num=split($0,list)
domcox@2 219 printf "%s ",$1
domcox@2 220 for (x=2; x<=num; x++){
domcox@2 221 if (x!=num)
domcox@2 222 printf "%s ", list[x]
domcox@2 223 else
domcox@2 224 printf "%s\n", list[x]
domcox@2 225 }
domcox@2 226 }'
domcox@2 227 }
domcox@2 228
domcox@2 229 # menu items msgs
domcox@2 230 list_items()
domcox@2 231 {
domcox@2 232 local data ref
domcox@2 233 case "$1" in
domcox@2 234 mode)
domcox@2 235 text2dlg "$(tazinst help mode)" ;;
domcox@2 236 media)
domcox@2 237 text2dlg "$(tazinst help media)" ;;
domcox@2 238 usb)
domcox@2 239 tazinst list usb ;;
domcox@2 240 iso)
domcox@2 241 tazinst list iso | awk '{print $0, " "}' ;;
domcox@2 242 web)
domcox@2 243 text2dlg "$(tazinst help web)" ;;
domcox@2 244 root_uuid)
domcox@2 245 tazinst list uuid ;;
domcox@2 246 root_format)
domcox@2 247 for i in $(tazinst list format); do
domcox@2 248 text2dlg "$(tazinst help root_format | grep $i)"
domcox@2 249 done ;;
domcox@2 250 home_uuid)
domcox@2 251 tazinst list uuid ;;
domcox@2 252 home_format)
domcox@2 253 for i in $(tazinst list format); do
domcox@2 254 text2dlg "$(tazinst help home_format | grep $i)"
domcox@2 255 done ;;
domcox@2 256 bootloader)
domcox@2 257 text2dlg "$(tazinst help bootloader)" ;;
domcox@2 258 esac
domcox@2 259 }
domcox@2 260
domcox@2 261 summary_list()
domcox@2 262 {
domcox@2 263 local option
domcox@2 264 for option in $SEQUENCE; do
domcox@2 265 case "$option" in
domcox@2 266 mode)
domcox@2 267 local mode="$(tazinst get mode)"
domcox@2 268 printf "\n\n$(gettext "Mode"): "
domcox@2 269 printf "$(tazinst help mode | grep "$mode")" ;;
domcox@2 270 media)
domcox@2 271 printf "\n$(gettext "From media"): $(tazinst get media)" ;;
domcox@2 272 source)
domcox@2 273 local source="$(tazinst get source)"
domcox@2 274 [ -n "$source" ] && printf " ($source)" ;;
domcox@2 275 root_uuid)
domcox@2 276 printf "\n$(gettext "To the disk"): $(tazinst get root_uuid)" ;;
domcox@2 277 root_format)
domcox@2 278 local root_format="$(tazinst get root_format)"
domcox@2 279 [ -n "$root_format" ] \
domcox@2 280 && printf " $(gettext "(Formatting as"): $root_format)" \
domcox@2 281 || printf " $(gettext "(No formatting)")" ;;
domcox@2 282 home_uuid)
domcox@2 283 local home_uuid="$(tazinst get home_uuid)"
domcox@2 284 [ -n "$home_uuid" ] \
domcox@2 285 && printf "\n$(gettext "Separate /home is"): $home_uuid" \
domcox@2 286 || printf "\n$(gettext "No separate /home partition")" ;;
domcox@2 287 home_format)
domcox@2 288 local home_format="$(tazinst get home_format)"
domcox@2 289 [ -n "$home_uuid" ] && ([ -n "$home_format" ] \
domcox@2 290 && printf " $(gettext "(Formatting as"): $home_format)" \
domcox@2 291 || printf " $(gettext "(No /home formatting)")";) ;;
domcox@2 292 hostname)
domcox@2 293 printf "\nHostname: $(tazinst get hostname)" ;;
domcox@2 294 user_login)
domcox@2 295 printf "\n$(gettext "User login"): $(tazinst get user_login)" ;;
domcox@2 296 bootloader)
domcox@2 297 local bootloader="$(tazinst get bootloader)"
domcox@2 298 [ -n "$bootloader" ] \
domcox@2 299 && printf "\n$(gettext "Bootloader: installed")" \
domcox@2 300 || printf "\n$(gettext "No bootloader installed")" ;;
domcox@2 301 winboot)
domcox@2 302 local winboot="$(tazinst get winboot)"
domcox@2 303 [ -n "$winboot" ] \
domcox@2 304 && printf "$(gettext ", with Windows dual-boot")" \
domcox@2 305 || printf "$(gettext ", no dual-boot")" ;;
domcox@2 306 esac
domcox@2 307 done
domcox@2 308 }
domcox@2 309
domcox@2 310 dialog_menu()
domcox@2 311 {
domcox@2 312 local option="$1" items="$2" sighup=1 sigint=2 sigquit=3
domcox@2 313 if [ -z "$items" ]; then
domcox@2 314 "$DIALOG" \
domcox@2 315 --title " Select $option " --clear \
domcox@2 316 --msgbox "$EMPTY_MENU_MSG" 10 41
domcox@2 317 fi
domcox@2 318 tempfile="$(mktemp)"
domcox@2 319 trap "rm -f $tempfile ; exit 1" $sighup $sigint $sigquit
domcox@2 320 "$DIALOG" \
domcox@2 321 --clear --colors \
domcox@2 322 --title " Select $option " \
domcox@2 323 --backtitle "$BACKLIST" \
domcox@2 324 --default-item "$(tazinst get "$option")" \
domcox@2 325 --ok-label "$(gettext "Ok")" \
domcox@2 326 --cancel-label "$(gettext "Cancel")" \
domcox@2 327 --menu "$(msg $option)" 18 70 6 $items 2> "$tempfile"
domcox@2 328 retval="$?"
domcox@2 329 choice=$(cat "$tempfile")
domcox@2 330 rm -f "$tempfile"
domcox@2 331 case "$retval" in
domcox@2 332 0)
domcox@2 333 # a '$choice' was selected
domcox@2 334 tazinst set "$option" "$choice" && move up || \
domcox@2 335 "$DIALOG" \
domcox@2 336 --title " Select $option " --clear \
domcox@2 337 --msgbox "\n$(tazinst check "$option" 2>&1)" 10 41 ;;
domcox@2 338 1|255)
domcox@2 339 # voluntary exit or ESC pressed
domcox@2 340 move back ;;
domcox@2 341 esac
domcox@2 342 return "$retval"
domcox@2 343 }
domcox@2 344
domcox@2 345 dialog_yesno()
domcox@2 346 {
domcox@2 347 local option="$1"
domcox@2 348 "$DIALOG" \
domcox@2 349 --clear --colors \
domcox@2 350 --title " Select $option " \
domcox@2 351 --backtitle "$BACKLIST" \
domcox@2 352 --ok-label "$(gettext "Yes")" \
domcox@2 353 --cancel-label "$(gettext "Cancel")" \
domcox@2 354 --extra-button --extra-label "$(gettext "No")" \
domcox@2 355 --yesno "$(ask $option)" 18 70
domcox@2 356 retval="$?"
domcox@2 357 case "$retval" in
domcox@2 358 # 0: yes
domcox@2 359 1) # cancel
domcox@2 360 move back ;;
domcox@2 361 3) # no
domcox@2 362 tazinst unset "$option"
domcox@2 363 move up ;;
domcox@2 364 255)# ESC pressed
domcox@2 365 move back ;;
domcox@2 366 esac
domcox@2 367 return "$retval"
domcox@2 368 }
domcox@2 369
domcox@2 370 dialog_input()
domcox@2 371 {
domcox@2 372 local option="$1" sighup=1 sigint=2 sigquit=3
domcox@2 373 local value="$(tazinst get "$option")"
domcox@2 374 tempfile="$(mktemp)"
domcox@2 375 trap "rm -f $tempfile; exit 1" $sighup $sigint $sigquit
domcox@2 376 $DIALOG \
domcox@2 377 --clear --colors \
domcox@2 378 --title " Select $option " \
domcox@2 379 --ok-label "$(gettext "Ok")" \
domcox@2 380 --cancel-label "$(gettext "Cancel")" \
domcox@2 381 --inputbox "$(msg $option)" 16 51 "$value" 2> "$tempfile"
domcox@2 382 retval="$?"
domcox@2 383 choice="$(cat $tempfile)"
domcox@2 384 rm -f "$tempfile"
domcox@2 385 case "$retval" in
domcox@2 386 0) # new value
domcox@2 387 tazinst set "$option" "$choice"
domcox@2 388 retcode=$?
domcox@2 389 [ "$retcode" -gt "0" ] && \
domcox@2 390 "$DIALOG" \
domcox@2 391 --title " Select $option " --clear \
domcox@2 392 --msgbox "\n$(tazinst check "$option" 2>&1)" 10 41
domcox@2 393 # continue if no error (0) or only warning (>127)
domcox@2 394 [ "$retcode" -le "0" ] && move up
domcox@2 395 [ "$retcode" -gt "127" ] && move up ;;
domcox@2 396 1) # cancel pressed."
domcox@2 397 move back ;;
domcox@2 398 255)# ESC pressed
domcox@2 399 move back ;;
domcox@2 400 esac
domcox@2 401 return "$retval"
domcox@2 402 }
domcox@2 403
domcox@2 404 # tiny summary and last chance to cancel or restart
domcox@2 405 summary()
domcox@2 406 {
domcox@2 407 "$DIALOG" \
domcox@2 408 --clear --colors \
domcox@2 409 --title " Summary " \
domcox@2 410 --backtitle "$BACKLIST" \
domcox@2 411 --yes-label "$(gettext "Yes")" \
domcox@2 412 --no-label "$(gettext "No")" \
domcox@2 413 --yesno "$(ask summary)$(summary_list)" 18 70
domcox@2 414 retval="$?"
domcox@2 415 case "$retval" in
domcox@2 416 0) # yes
domcox@2 417 move up ;;
domcox@2 418 1) # Cancel
domcox@2 419 move back ;;
domcox@2 420 3) # no
domcox@2 421 return 3 ;;
domcox@2 422 255)# ESC pressed
domcox@2 423 move back ;;
domcox@2 424 esac
domcox@2 425 }
domcox@2 426
domcox@2 427 #--------------------
domcox@2 428 # sequencing section
domcox@2 429 #--------------------
domcox@2 430
domcox@2 431 # get list of settings
domcox@2 432 sequence()
domcox@2 433 {
domcox@2 434 SEQUENCE="$(tazinst get settings) summary"
domcox@2 435 MAX="$(echo "$SEQUENCE" | wc -w)"
domcox@2 436 }
domcox@2 437
domcox@2 438 # get the setting name corresponding to an index in the list of settings
domcox@2 439 key()
domcox@2 440 {
domcox@2 441 local index="$1" num=1 string
domcox@2 442 for string in $SEQUENCE; do
domcox@2 443 [ "$num" = "$index" ] && printf "$string"
domcox@2 444 num=$(($num + 1))
domcox@2 445 done
domcox@2 446 }
domcox@2 447
domcox@2 448 # move index in list of settings
domcox@2 449 move()
domcox@2 450 {
domcox@2 451 local way="$1"
domcox@2 452 case "$way" in
domcox@2 453 init)
domcox@2 454 INDEX=1
domcox@2 455 WAY="up" ;;
domcox@2 456 up)
domcox@2 457 INDEX=$(($INDEX+1))
domcox@2 458 WAY="up" ;;
domcox@2 459 back)
domcox@2 460 INDEX=$(($INDEX-1))
domcox@2 461 WAY="down" ;;
domcox@2 462 away)
domcox@2 463 # continue to move in the same way (move up or move back)
domcox@2 464 [ "$WAY" = "up" ] && INDEX=$(($INDEX+1)) || INDEX=$(($INDEX-1)) ;;
domcox@2 465 esac
domcox@2 466 }
domcox@2 467
domcox@2 468 source_menu()
domcox@2 469 {
domcox@2 470 media="$(tazinst get media)"
domcox@2 471 case "$media" in
domcox@2 472 cdrom)
domcox@2 473 tazinst unset source || exit 2
domcox@2 474 move away ;;
domcox@2 475 usb)
domcox@2 476 dialog_menu source "$(list_items usb)" ;;
domcox@2 477 iso)
domcox@2 478 dialog_menu source "$(list_items iso)" ;;
domcox@2 479 web)
domcox@2 480 dialog_menu source "$(list_items web)" ;;
domcox@2 481 *)
domcox@2 482 move away ;;
domcox@2 483 esac
domcox@2 484 }
domcox@2 485
domcox@2 486 #--------------
domcox@2 487 # main section
domcox@2 488 #--------------
domcox@2 489
domcox@2 490 check_tazinst && tazinst new
domcox@2 491 tazinst get mode || exit 1
domcox@2 492 sequence
domcox@2 493 move init
domcox@2 494
domcox@2 495 while [ "$INDEX" -le "$MAX" ]
domcox@2 496 do
domcox@2 497 OPTION="$(key $INDEX)"
domcox@2 498 case "$OPTION" in
domcox@2 499 "")
domcox@2 500 exit 0 ;;
domcox@2 501 mode)
domcox@2 502 dialog_menu mode "$(list_items mode)" && sequence ;;
domcox@2 503 media)
domcox@2 504 dialog_menu media "$(list_items media)" ;;
domcox@2 505 source)
domcox@2 506 source_menu ;;
domcox@2 507 root_uuid)
domcox@2 508 dialog_menu root_uuid "$(list_items root_uuid)" ;;
domcox@2 509 root_format)
domcox@2 510 dialog_yesno root_format && \
domcox@2 511 dialog_menu root_format "$(list_items root_format)" ;;
domcox@2 512 home_uuid)
domcox@2 513 dialog_yesno home_uuid && \
domcox@2 514 dialog_menu home_uuid "$(list_items home_uuid)" ;;
domcox@2 515 home_format)
domcox@2 516 if [ -n "$(tazinst get home_uuid)" ]; then
domcox@2 517 dialog_yesno home_format && \
domcox@2 518 dialog_menu home_format "$(list_items home_format)"
domcox@2 519 else
domcox@2 520 tazinst unset home_format
domcox@2 521 move away
domcox@2 522 fi ;;
domcox@2 523 hostname)
domcox@2 524 dialog_input hostname ;;
domcox@2 525 root_pwd)
domcox@2 526 dialog_input root_pwd ;;
domcox@2 527 user_login)
domcox@2 528 dialog_input user_login ;;
domcox@2 529 user_pwd)
domcox@2 530 dialog_input user_pwd ;;
domcox@2 531 bootloader)
domcox@2 532 dialog_yesno bootloader && \
domcox@2 533 { tazinst set bootloader "auto" && move up; } || \
domcox@2 534 { tazinst unset bootloader ;
domcox@2 535 tazinst unset winboot ; } ;;
domcox@2 536 winboot)
domcox@2 537 if [ -n "$(tazinst get bootloader)" ]; then
domcox@2 538 dialog_yesno winboot && \
domcox@2 539 { tazinst set winboot "auto" && move up; } || \
domcox@2 540 tazinst unset winboot
domcox@2 541 else
domcox@2 542 move away
domcox@2 543 fi ;;
domcox@2 544 summary)
domcox@2 545 summary ;;
domcox@2 546 *)
domcox@2 547 exit 1 ;;
domcox@2 548 esac
domcox@2 549 done
domcox@2 550
domcox@2 551 # execute process
domcox@2 552 tazinst execute | awk 'BEGIN{
domcox@2 553 printf "XXX\n0\n"
domcox@2 554 }
domcox@2 555 {
domcox@2 556 num=$1+0
domcox@2 557 if (num>=1){
domcox@2 558 printf "XXX\nXXX\n%s\n", num
domcox@2 559 printf "\n%s\n",substr($0,length($1)+2)
domcox@2 560 }
domcox@2 561 else
domcox@2 562 printf "%s\n",$0
domcox@2 563 }
domcox@2 564 END{
domcox@2 565 print "XXX"
domcox@2 566 }' | $DIALOG --title "Slitaz-Installer" --gauge "Installing.." 20 70 0
domcox@2 567
domcox@2 568
domcox@2 569 # end_of_install
domcox@2 570 if tazinst log | grep -q "x-x-" ; then
domcox@2 571 tazinst clean
domcox@2 572 $DIALOG --title " Installation complete " \
domcox@2 573 --backtitle "$BACKLIST" \
domcox@2 574 --yes-label "Exit" \
domcox@2 575 --no-label "Reboot" \
domcox@2 576 --clear --colors --yesno "$END_OF_INSTALL_MSG" 18 70
domcox@2 577 retval=$?
domcox@2 578 case $retval in
domcox@2 579 0)
domcox@2 580 exit 0 ;;
domcox@2 581 1)
domcox@2 582 reboot || reboot -f ;;
domcox@2 583 255)
domcox@2 584 echo -e "ESC pressed.\n" && exit 0 ;;
domcox@2 585 esac
domcox@2 586 else
domcox@2 587 $DIALOG --title " Process not completed " \
domcox@2 588 --backtitle "$BACKLIST" \
domcox@2 589 --clear --msgbox \
domcox@2 590 "$(tazinst log | awk '$1 == "-x-x-",$1 == "x-x-x"')" 18 70
domcox@2 591 retval=$?
domcox@2 592 case $retval in
domcox@2 593 0)
domcox@2 594 exit 0 ;;
domcox@2 595 255)
domcox@2 596 echo -e "ESC pressed.\n" && exit 0 ;;
domcox@2 597 esac
domcox@2 598 fi