update archtitus

This commit is contained in:
Chris Titus 2024-08-22 19:54:40 -05:00
parent bb74ded264
commit bf0ce751e7

View File

@ -72,19 +72,12 @@ background_checks() {
docker_check docker_check
} }
# Renders a text based list of options that can be selected by the
# user using up, down and enter keys and returns the chosen option.
#
# Arguments : list of options, maximum of 256
# "opt1" "opt2" ...
# Return value: selected index (0 for opt1, 1 for opt2 ...)
select_option() { select_option() {
local options=("$@") local options=("$@")
local num_options=${#options[@]} local num_options=${#options[@]}
local selected=0 local selected=0
while true; do while true; do
clear
echo "Please select an option using the arrow keys and Enter:" echo "Please select an option using the arrow keys and Enter:"
for i in "${!options[@]}"; do for i in "${!options[@]}"; do
if [ $i -eq $selected ]; then if [ $i -eq $selected ]; then
@ -143,45 +136,45 @@ echo -ne "
# @description This function will handle file systems. At this movement we are handling only # @description This function will handle file systems. At this movement we are handling only
# btrfs and ext4. Others will be added in future. # btrfs and ext4. Others will be added in future.
filesystem () { filesystem () {
echo -ne " echo -ne "
Please Select your file system for both boot and root Please Select your file system for both boot and root
" "
options=("btrfs" "ext4" "luks" "exit") options=("btrfs" "ext4" "luks" "exit")
select_option "${options[@]}" select_option "${options[@]}"
case $? in case $? in
0) export FS=btrfs;; 0) export FS=btrfs;;
1) export FS=ext4;; 1) export FS=ext4;;
2) 2)
set_password "LUKS_PASSWORD" set_password "LUKS_PASSWORD"
export FS=luks export FS=luks
;; ;;
3) exit ;; 3) exit ;;
*) echo "Wrong option please select again"; filesystem;; *) echo "Wrong option please select again"; filesystem;;
esac esac
} }
# @description Detects and sets timezone. # @description Detects and sets timezone.
timezone () { timezone () {
# Added this from arch wiki https://wiki.archlinux.org/title/System_time # Added this from arch wiki https://wiki.archlinux.org/title/System_time
time_zone="$(curl --fail https://ipapi.co/timezone)" time_zone="$(curl --fail https://ipapi.co/timezone)"
echo -ne " echo -ne "
System detected your timezone to be '$time_zone' \n" System detected your timezone to be '$time_zone' \n"
echo -ne "Is this correct? echo -ne "Is this correct?
" "
options=("Yes" "No") options=("Yes" "No")
select_option "${options[@]}" select_option "${options[@]}"
case ${options[$?]} in case ${options[$?]} in
y|Y|yes|Yes|YES) y|Y|yes|Yes|YES)
echo "${time_zone} set as timezone" echo "${time_zone} set as timezone"
export TIMEZONE=$time_zone;; export TIMEZONE=$time_zone;;
n|N|no|NO|No) n|N|no|NO|No)
echo "Please enter your desired timezone e.g. Europe/London :" echo "Please enter your desired timezone e.g. Europe/London :"
read new_timezone read new_timezone
echo "${new_timezone} set as timezone" echo "${new_timezone} set as timezone"
export TIMEZONE=$new_timezone;; export TIMEZONE=$new_timezone;;
*) echo "Wrong option. Try again";timezone;; *) echo "Wrong option. Try again";timezone;;
esac esac
} }
# @description Set user's keyboard mapping. # @description Set user's keyboard mapping.
keymap () { keymap () {
@ -243,11 +236,34 @@ drivessd
# @description Gather username and password to be used for installation. # @description Gather username and password to be used for installation.
userinfo () { userinfo () {
read -p "Please enter your username: " username # Loop through user input until the user gives a valid username
export USERNAME=${username,,} # convert to lower case as in issue #109 while true
set_password "PASSWORD" do
read -rep "Please enter your hostname: " nameofmachine read -p "Please enter username:" username
export NAME_OF_MACHINE=$nameofmachine if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
then
break
fi
echo "Incorrect username."
done
export USERNAME=$username
# Loop through user input until the user gives a valid hostname, but allow the user to force save
while true
do
read -p "Please name your machine:" name_of_machine
# hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
then
break
fi
# if validation fails allow the user to force saving of the hostname
read -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
if [[ "${force,,}" = "y" ]]
then
break
fi
done
export NAME_OF_MACHINE=$name_of_machine
} }
# Starting functions # Starting functions
@ -273,7 +289,7 @@ iso=$(curl -4 ifconfig.co/country-iso)
timedatectl set-ntp true timedatectl set-ntp true
pacman -S --noconfirm archlinux-keyring #update keyrings to latest to prevent packages failing to install pacman -S --noconfirm archlinux-keyring #update keyrings to latest to prevent packages failing to install
pacman -S --noconfirm --needed pacman-contrib terminus-font pacman -S --noconfirm --needed pacman-contrib terminus-font
setfont ter-v22b setfont ter-v18b
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
pacman -S --noconfirm --needed reflector rsync grub pacman -S --noconfirm --needed reflector rsync grub
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
@ -519,35 +535,6 @@ elif grep -E "Integrated Graphics Controller" <<< ${gpu_type}; then
elif grep -E "Intel Corporation UHD" <<< ${gpu_type}; then elif grep -E "Intel Corporation UHD" <<< ${gpu_type}; then
pacman -S --needed --noconfirm libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa pacman -S --needed --noconfirm libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa
fi fi
# Loop through user input until the user gives a valid username
while true
do
read -p "Please enter username:" USERNAME
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
then
break
fi
echo "Incorrect username."
done
read -p "Please enter password:" PASSWORD
# Loop through user input until the user gives a valid hostname, but allow the user to force save
while true
do
read -p "Please name your machine:" name_of_machine
# hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
then
break
fi
# if validation fails allow the user to force saving of the hostname
read -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
if [[ "${force,,}" = "y" ]]
then
break
fi
done
echo -ne " echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------