diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index 2b2c8c8..deecf8f 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -105,11 +105,10 @@ function get_user_input() { # LUKS_PWD get_block_devices_with_size || return $? - get_single_choice TARGET_BLOCK_DEVICE 'Select target device for installation' BLOCK_DEVICE_SIZES || return $? + single_choice_if_empty TARGET_BLOCK_DEVICE 'Select target device for installation' BLOCK_DEVICE_SIZES || return $? - ask_user_if_empty BOOT_FIRMWARE 'Enter desired boot firmware. Valid options are "bios", "uefi" or "autodetect":' || return $? if [ "${BOOT_FIRMWARE}" = 'autodetect' ]; then - # Detect BIOS type: https://askubuntu.com/a/162573 + # Detect boot firmware type: https://askubuntu.com/a/162573 # Check exit code; if 0 EFI, else BIOS. # "-q": tell grep to output nothing @@ -122,14 +121,14 @@ function get_user_input() { fi else - # Let user select BIOS type + # If $BOOT_FIRMWARE is empty: Let user select BIOS type TMP1=('uefi' 'Newer mainboards' 'bios' 'Legacy BIOS on older mainboards') - get_single_choice BOOT_FIRMWARE 'Select your bios type' TMP1 || return $? + single_choice_if_empty BOOT_FIRMWARE 'Select your bios type' TMP1 || return $? fi TMP1=('BTRFS' 'Allows snapshots and dynamic extension of the FS' 'EXT4' 'Default FS of many distributions' 'F2FS' 'Flash-Friendly-FS for SSD or NVMe') - get_single_choice FS 'Select filesystem to use' TMP1 || return $? + single_choice_if_empty FS 'Select filesystem to use' TMP1 || return $? ask_user_if_empty HOSTNAME 'Enter hostname:' || return $? ask_user_if_empty USERNAME 'Enter username:' || return $? @@ -216,7 +215,7 @@ function get_additional_mount_options() { ;; esac - get_multi_choice FS_ADDITIONAL_MOUNT_OPTIONS 'Select mount options' TMP1 || return $? + multi_choice_if_empty FS_ADDITIONAL_MOUNT_OPTIONS 'Select mount options' TMP1 || return $? } function run_pacstrap() { diff --git a/pkg/de-p1st-installer/example-vbox.cfg b/pkg/de-p1st-installer/example-vbox.cfg index 00fc542..8382741 100644 --- a/pkg/de-p1st-installer/example-vbox.cfg +++ b/pkg/de-p1st-installer/example-vbox.cfg @@ -6,11 +6,11 @@ HOSTNAME=yodaTest USERNAME=yoda -# one should rather enter these interactively than saving in this cfg +# One should rather enter these interactively than saving in this cfg. USER_PWD=test LUKS_PWD=test -# if unset, then USER_PWD will be used for ROOT_PWD +# If unset, then USER_PWD will be used for ROOT_PWD # ROOT_PWD=test TARGET_BLOCK_DEVICE=/dev/sda diff --git a/pkg/de-p1st-installer/lib/user-input.sh b/pkg/de-p1st-installer/lib/user-input.sh index 3992f29..85b5dfb 100644 --- a/pkg/de-p1st-installer/lib/user-input.sh +++ b/pkg/de-p1st-installer/lib/user-input.sh @@ -1,7 +1,8 @@ function ask_user_if_empty { - # If variable with name $1 is zero, then ask user for input. - # Only one line user input is allowed. - # User input must not be empty. + # If variable with name $1 is empty, then ask for user input. + # + # Only one line of user input is allowed. + # The input must not be empty. # # arg $1: name of variable to store user input # arg $2: text to display (e.g. "Enter hostname:") @@ -30,19 +31,19 @@ function ask_user_if_empty { fi } -function get_single_choice { - # If variable with name $1 is zero, then ask user to select one option. +function single_choice_if_empty { + # If variable with name $1 is empty, then let user select one of the given options. # # arg $1: name of variable to store the selected option # arg $2: text to display # arg $3: name of variable with array of options to display (for each option there must be two entries in the array: Item and description) if [ "$#" -ne 3 ]; then - echo 'get_single_choice requires three args!'; + echo 'single_choice_if_empty requires three args!'; return 1 fi for i in "$@"; do if [ -z "${i}" ]; then - echo 'get_single_choice: all given args must not be empty'; + echo 'single_choice_if_empty: all given args must not be empty'; return 1; fi done @@ -61,19 +62,19 @@ function get_single_choice { fi } -function get_multi_choice { - # If variable with name $1 is zero, then ask user to select one ore more options. +function multi_choice_if_empty { + # If variable with name $1 is empty, then let user select one or more of the given options. # # arg $1: name of variable to store array of selected options # arg $2: text to display # arg $3: name of variable with array of options to display (for each option there must be three entries in the array: Item, description, on/off) if [ "$#" -ne 3 ]; then - echo 'get_multi_choice requires three args!'; + echo 'multi_choice_if_empty requires three args!'; return 1 fi for i in "$@"; do if [ -z "${i}" ]; then - echo 'get_multi_choice: all given args must not be empty'; + echo 'multi_choice_if_empty: all given args must not be empty'; return 1; fi done