From 9074cf529db6cf300571d7071ade44041349dc4a Mon Sep 17 00:00:00 2001 From: Tristan Ancelet Date: Sat, 18 Nov 2023 14:27:06 -0600 Subject: [PATCH] Added a few menues for user to choose timezone and locale --- bare-arch-install.sh | 59 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/bare-arch-install.sh b/bare-arch-install.sh index 36847d1..90dfb7d 100755 --- a/bare-arch-install.sh +++ b/bare-arch-install.sh @@ -2,6 +2,20 @@ # BEGIN: Helper Functions +get_disks () { + local -a FOUND_DISKS + local -n OUTPUT_VAR="${1:?"get_disks: No variable was passed through"}" + + if ls /dev/?d? >/dev/null 2>&1; then + FOUND_DISKS+=( /dev/?d? ) + fi + + if ls /dev/nvmen? >/dev/null 2>&1 ; then + FOUND_DISKS+=( /dev/nvmen? ) + fi + OUTPUT_VAR=( ${FOUND_DISKS[@]} ) +} + get_choices () { local PROMPT="$1" shift @@ -26,11 +40,13 @@ get_choices () { done } + get_choice () { + echo "1: $1" local PROMPT="$1" - shift local -n OUTPUT_VAR="$2" shift + shift local -a OPTIONS=( $@ ) select item in ${OPTIONS[@]} quit; do @@ -92,35 +108,20 @@ get_answer () { } -get_timezones () { - local -n OUTPUT_VAR="${1:?"get_timezones: Output variable not provied"}" - local -a OPTIONS=( $( - cd /usr/share/zoneinfo - for DIR in $( ls -1 ); do - for ITEM in $DIR/*; do - echo "$DIR/$ITEM" - done - done - ) - ) - OUTER_VAR=$OPTIONS -} - # END: Helper Functions # BEGIN: Variables HOSTNAME="" -get_answer "What is the hostname of this machine?" HOSTNAME +get_answer "What is the hostname of this machine?: " HOSTNAME BOOT_METHOD="" -get_choice "What is your boot method?" BOOT_METHOD BIOS EFI +get_choice "What is your boot method?: " BOOT_METHOD BIOS EFI -DISK="${2:?"Disk was not provided"}" -[[ ! -b $DISK ]] && { - echo "Your disk ($DISK) does not exist. Please provide a valid one" - exit -} +DISK="" +declare -a DISKS +get_disks DISKS +get_choice "Which disk are you wanting to use? : " DISK "${DISKS[@]}" EFI_PARTITION=${DISK}1 SWAP_PARTITION=${DISK}2 @@ -136,12 +137,14 @@ get_answer "What other user do you want to configure on the system? : " NEW_USER NEW_PASSWORD="password" get_answer "What do you want the password for $NEW_USER to be? : " NEW_PASSWORD -declare -a TIMEZONES -get_timezones TIMEZONES -echo "${TIMEZONES[@]}" -exit -TIMEZONE_INFO=America/Chicago -LOCALE=en_US.UTF-8 + +declare -a TIMEZONES=( $( timedatectl list-timezones ) ) +TIMEZONE_INFO="" +get_choice "What is your timezone? : " TIMEZONE_INFO ${TIMEZONES[@]} + +declare -a LOCALES=( $( localectl list-locales ) ) +LOCALE="" +get_choice "What is your locale? : " LOCALE ${LOCALES[@]} ## Commands to create disks un-interactively with fdisk ## will clean up comments later with grep command