installer script: work in progress (3)

This commit is contained in:
Daniel Langbein 2021-04-30 22:02:50 +02:00
parent 30dfe15a6e
commit a32bb78c2e
2 changed files with 27 additions and 13 deletions

View File

@ -115,7 +115,7 @@ function get_multi_choice {
# if ptr has no value yet, ask user for input!
local -n MENU_OPTIONS=$3
local tmp=$(dialog --stdout --checklist "$2" 0 0 0 ${MENU_OPTIONS}) || {
TMP1=$(dialog --stdout --checklist "$2" 0 0 0 ${MENU_OPTIONS}) || {
echo "Error during menu selection!"
exit 1
}
@ -123,7 +123,10 @@ function get_multi_choice {
# Result of dialog is space separated list
# Store this as an array
readarray -d " " -t ptr <<<"$tmp"
# Without newline at last array element: https://unix.stackexchange.com/a/519917/315162
# readarray -d " " -t ptr < <(printf '%s' "$TMP1")
#
space_separated_to_array TMP1 "$1"
fi
}
@ -246,21 +249,17 @@ function choose_mount_options() {
esac
get_multi_choice FS_MOUNT_OPTIONS "Select mount options" TMP1 || return $?
# TODO: test FS_MOUNT_OPTIONS
echo "${FS_MOUNT_OPTIONS[@]}"
echo "${#FS_MOUNT_OPTIONS[@]}"
for i in "${FS_MOUNT_OPTIONS[@]}"; do
echo "<<$i>>"
done
}
function main() {
check_network || return $?
get_user_input || return $?
get_cpu_vendor || return $?
get_default_mount_options || return $?
choose_mount_options || return $?
# TODO: use FS_DEFAULT_MOUNT_OPTIONS and FS_MOUNT_OPTIONS in combination
}
main "$@"

View File

@ -6,11 +6,26 @@ function newline_to_space(){
# Replace newlines with spaces
# See bash string substitution: https://gist.github.com/JPvRiel/b279524d3e56229a896477cb8082a72b
echo "removing newlines in str: -->$ptr<--"
# echo "removing newlines in str: -->$ptr<--"
ptr="${ptr//$'\n'/' '}"
echo "new str is: -->$ptr<--"
# echo "new str is: -->$ptr<--"
}
function space_separated_to_array() {
# $1: name of variable with space separated list
# $2: name of array to store values into
local -n ptr=$1
local -n ptr2=$2
# ptr space separated list.
# Store this as array ptr2.
# Without newline at last array element: https://unix.stackexchange.com/a/519917/315162
readarray -d " " -t ptr2 < <(printf '%s' "$ptr")
}
function get_block_devices() {
# return: the following variables:
# BLOCK_DEVICES (array with each block device as one entry)