diff --git a/src/lib/dialogs.sh b/src/lib/dialogs.sh index 4bc17f4..f9552af 100644 --- a/src/lib/dialogs.sh +++ b/src/lib/dialogs.sh @@ -533,74 +533,3 @@ edit_configs() edit_configs } -# dialog helper functions - -msgbox() -{ - tput civis - dialog --cr-wrap --backtitle "$BT" --title " $1 " --msgbox "$2\n" 0 0 -} - -menubox() -{ - local title="$1" - local body="$2" - local h=$3 - local w=$4 - local n=$5 - shift 5 - local response - if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --menu "$body" $h $w $n "$@")"; then - return 1 - fi - printf "%s" "$response" -} - -checkbox() -{ - local title="$1" - local body="$2" - local h=$3 - local w=$4 - local n=$5 - shift 5 - local response - if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --checklist "$body" $h $w $n "$@")"; then - return 1 - fi - printf "%s" "$response" -} - -getinput() -{ - local answer - if ! answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel --backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")" || [[ $answer == '' ]]; then - return 1 - fi - printf "%s" "$answer" -} - -infobox() -{ - local sec="$3" - tput civis - dialog --cr-wrap --backtitle "$BT" --title " $1 " --infobox "$2\n" 0 0 - sleep ${sec:-2} -} - -yesno() -{ - # usage: yesno <text> [<yes_label> <no_label> [<no>]] - # three options: one --default-no and custom labels, one just custom labels, and one basic. - tput civis - if [[ $# -eq 5 && $5 == "no" ]]; then - dialog --cr-wrap --backtitle "$BT" --defaultno --title " $1 " \ - --yes-label "$3" --no-label "$4" --yesno "$2\n" 0 0 - elif [[ $# -eq 4 ]]; then - dialog --cr-wrap --backtitle "$BT" --title " $1 " --yes-label "$3" \ - --no-label "$4" --yesno "$2\n" 0 0 - else - dialog --cr-wrap --backtitle "$BT" --title " $1 " --yesno "$2\n" 0 0 - fi -} - diff --git a/src/lib/mount.sh b/src/lib/mount.sh index 1ae41ee..4023451 100644 --- a/src/lib/mount.sh +++ b/src/lib/mount.sh @@ -103,9 +103,14 @@ select_mount_opts() local part="$1" local fs="$2" local title="${fs^} Mount Options" - local opts - opts="${FS_OPTS[$fs]}" - ssd "$part" && opts=$(sed 's/discard - off/discard - on/' <<< "$opts") + local opts="${FS_OPTS[$fs]}" + + # check for ssd + if [[ $LUKS && ! $LVM && $part == "$ROOT_PART" ]]; then + ssd "$LUKS_PART" && opts=$(sed 's/discard - off/discard - on/' <<< "$opts") + else + ssd "$part" && opts=$(sed 's/discard - off/discard - on/' <<< "$opts") + fi tput civis if ! MNT_OPTS="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " \ @@ -123,10 +128,13 @@ select_mount_opts() select_filesystem() { local part="$1" - local fs + local fs cur_fs + if [[ $LUKS && ! $LVM && $part == "$ROOT_PART" ]]; then + cur_fs="$(lsblk -lno FSTYPE $LUKS_PART)" + else + cur_fs="$(lsblk -lno FSTYPE $part)" + fi - local cur_fs - cur_fs="$(lsblk -lno FSTYPE $part)" local title="\nSelect which filesystem you want to use for $part\n\nPartition Name: " @@ -161,7 +169,11 @@ select_filesystem() "xfs" "${FS_CMDS[xfs]}")" fi - [[ $fs == "$_Skip" ]] && return 0 || { [[ $fs == "" ]] && return 1; } + if ! [[ $fs ]]; then + return 1 + elif [[ $fs == "$_Skip" ]]; then + return 0 + fi if yesno "$_FSTitle" "\nFormat $part as $fs?\n" "Format" "Go Back"; then format $part $fs diff --git a/src/lib/package.sh b/src/lib/package.sh index cdc7394..fe0c723 100644 --- a/src/lib/package.sh +++ b/src/lib/package.sh @@ -1,14 +1,12 @@ #!/usr/bin/bash # vim:ft=sh:fdm=marker:fmr={,} +# shellcheck disable=2154,2153,2046,2034 # archlabs installer library script file # this file is not meant to be run directly # sourcing this file in a non bash shell is not advised -# shellcheck disable=2154,2153,2046,2034 - - # PKG_EXT: if you add a package to $PACKAGES in any dialog # and it uses/requires some additional packages, # you can add them here to keep it simple: [package]="extra" diff --git a/src/lib/utils.sh b/src/lib/utils.sh index 7226ed2..0e2d7b8 100644 --- a/src/lib/utils.sh +++ b/src/lib/utils.sh @@ -242,3 +242,73 @@ umount_dir() fi return 0 } + +msgbox() +{ + tput civis + dialog --cr-wrap --backtitle "$BT" --title " $1 " --msgbox "$2\n" 0 0 +} + +menubox() +{ + local title="$1" + local body="$2" + local h=$3 + local w=$4 + local n=$5 + shift 5 + local response + if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --menu "$body" $h $w $n "$@")"; then + return 1 + fi + printf "%s" "$response" +} + +checkbox() +{ + local title="$1" + local body="$2" + local h=$3 + local w=$4 + local n=$5 + shift 5 + local response + if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --checklist "$body" $h $w $n "$@")"; then + return 1 + fi + printf "%s" "$response" +} + +getinput() +{ + local answer + if ! answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel --backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")" || [[ $answer == '' ]]; then + return 1 + fi + printf "%s" "$answer" +} + +infobox() +{ + local sec="$3" + tput civis + dialog --cr-wrap --backtitle "$BT" --title " $1 " --infobox "$2\n" 0 0 + sleep ${sec:-2} +} + +yesno() +{ + # usage: yesno <title> <text> [<yes_label> <no_label> [<no>]] + # three options: one --default-no and custom labels, one just custom labels, and one basic. + tput civis + if [[ $# -eq 5 && $5 == "no" ]]; then + dialog --cr-wrap --backtitle "$BT" --defaultno --title " $1 " \ + --yes-label "$3" --no-label "$4" --yesno "$2\n" 0 0 + elif [[ $# -eq 4 ]]; then + dialog --cr-wrap --backtitle "$BT" --title " $1 " --yes-label "$3" \ + --no-label "$4" --yesno "$2\n" 0 0 + else + dialog --cr-wrap --backtitle "$BT" --title " $1 " --yesno "$2\n" 0 0 + fi +} +