Added a few menues for user to choose timezone and locale

This commit is contained in:
Tristan Ancelet 2023-11-18 14:27:06 -06:00
parent 6b20dba53e
commit 9074cf529d

View File

@ -2,6 +2,20 @@
# BEGIN: Helper Functions # 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 () { get_choices () {
local PROMPT="$1" local PROMPT="$1"
shift shift
@ -26,11 +40,13 @@ get_choices () {
done done
} }
get_choice () { get_choice () {
echo "1: $1"
local PROMPT="$1" local PROMPT="$1"
shift
local -n OUTPUT_VAR="$2" local -n OUTPUT_VAR="$2"
shift shift
shift
local -a OPTIONS=( $@ ) local -a OPTIONS=( $@ )
select item in ${OPTIONS[@]} quit; do 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 # END: Helper Functions
# BEGIN: Variables # BEGIN: Variables
HOSTNAME="" HOSTNAME=""
get_answer "What is the hostname of this machine?" HOSTNAME get_answer "What is the hostname of this machine?: " HOSTNAME
BOOT_METHOD="" 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"}" DISK=""
[[ ! -b $DISK ]] && { declare -a DISKS
echo "Your disk ($DISK) does not exist. Please provide a valid one" get_disks DISKS
exit get_choice "Which disk are you wanting to use? : " DISK "${DISKS[@]}"
}
EFI_PARTITION=${DISK}1 EFI_PARTITION=${DISK}1
SWAP_PARTITION=${DISK}2 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" NEW_PASSWORD="password"
get_answer "What do you want the password for $NEW_USER to be? : " NEW_PASSWORD get_answer "What do you want the password for $NEW_USER to be? : " NEW_PASSWORD
declare -a TIMEZONES
get_timezones TIMEZONES declare -a TIMEZONES=( $( timedatectl list-timezones ) )
echo "${TIMEZONES[@]}" TIMEZONE_INFO=""
exit get_choice "What is your timezone? : " TIMEZONE_INFO ${TIMEZONES[@]}
TIMEZONE_INFO=America/Chicago
LOCALE=en_US.UTF-8 declare -a LOCALES=( $( localectl list-locales ) )
LOCALE=""
get_choice "What is your locale? : " LOCALE ${LOCALES[@]}
## Commands to create disks un-interactively with fdisk ## Commands to create disks un-interactively with fdisk
## will clean up comments later with grep command ## will clean up comments later with grep command