remove trailing space & move "then" and "do"...

parts of if/while/loop statements to be separated from the condition by a colon instead of newline to reduce vertical space
This commit is contained in:
i-c-u-p 2022-04-25 09:06:37 +00:00
parent 62e5ba90b1
commit 742a2dc236
No known key found for this signature in database
GPG Key ID: ABB80C12170FC0D1
6 changed files with 48 additions and 59 deletions

View File

@ -104,8 +104,7 @@ bash_prompt_command() {
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen )) local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
# Generate name # Generate name
if [ ${pwdoffset} -gt "0" ] if [ ${pwdoffset} -gt "0" ]; then
then
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen} NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/} NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
fi fi

View File

@ -10,7 +10,7 @@
#github-action genshdoc #github-action genshdoc
# #
# @file Preinstall # @file Preinstall
# @brief Contains the steps necessary to configure and pacstrap the install to selected drive. # @brief Contains the steps necessary to configure and pacstrap the install to selected drive.
echo " echo "
------------------------------------------------------------------------- -------------------------------------------------------------------------
█████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗
@ -69,7 +69,7 @@ echo "
-------------------------------------------------------------------------" -------------------------------------------------------------------------"
subvols=(home var tmp .snapshots) subvols=(home var tmp .snapshots)
# @description Creates the btrfs subvolumes. # @description Creates the btrfs subvolumes.
createsubvolumes () { createsubvolumes () {
for subvol in '' ${subvols[@]}; do # the '' adds the root subvolume to the loop for subvol in '' ${subvols[@]}; do # the '' adds the root subvolume to the loop
btrfs subvolume create /mnt/@$subvol btrfs subvolume create /mnt/@$subvol
@ -83,11 +83,11 @@ mountallsubvol () {
done done
} }
# @description BTRFS subvolulme creation and mounting. # @description BTRFS subvolulme creation and mounting.
subvolumesetup () { subvolumesetup () {
# create nonroot subvolumes # create nonroot subvolumes
createsubvolumes createsubvolumes
# unmount root to remount with subvolume # unmount root to remount with subvolume
umount /mnt umount /mnt
# mount @ subvolume # mount @ subvolume
mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt
@ -120,7 +120,7 @@ elif [[ "${FS}" == "luks" ]]; then
mkfs.vfat -F32 -n "EFIBOOT" ${partition2} mkfs.vfat -F32 -n "EFIBOOT" ${partition2}
# enter luks password to cryptsetup and format root partition # enter luks password to cryptsetup and format root partition
echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat ${partition3} - echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat ${partition3} -
# open luks container and ROOT will be place holder # open luks container and ROOT will be place holder
echo -n "${LUKS_PASSWORD}" | cryptsetup open ${partition3} ROOT - echo -n "${LUKS_PASSWORD}" | cryptsetup open ${partition3} ROOT -
# now format that container # now format that container
mkfs.btrfs -L ROOT ${partition3} mkfs.btrfs -L ROOT ${partition3}
@ -152,7 +152,7 @@ cp -R ${SCRIPT_DIR} /mnt/root/ArchTitus
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
genfstab -L /mnt >> /mnt/etc/fstab genfstab -L /mnt >> /mnt/etc/fstab
echo " echo "
Generated /etc/fstab: Generated /etc/fstab:
" "
cat /mnt/etc/fstab cat /mnt/etc/fstab

View File

@ -2,7 +2,7 @@
#github-action genshdoc #github-action genshdoc
# #
# @file Setup # @file Setup
# @brief Configures installed system, installs base packages, and creates user. # @brief Configures installed system, installs base packages, and creates user.
echo " echo "
------------------------------------------------------------------------- -------------------------------------------------------------------------
█████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗
@ -18,13 +18,13 @@ echo "
source $HOME/ArchTitus/configs/setup.conf source $HOME/ArchTitus/configs/setup.conf
echo " echo "
------------------------------------------------------------------------- -------------------------------------------------------------------------
Network Setup Network Setup
-------------------------------------------------------------------------" -------------------------------------------------------------------------"
pacman -S --noconfirm --needed networkmanager dhclient pacman -S --noconfirm --needed networkmanager dhclient
systemctl enable --now NetworkManager systemctl enable --now NetworkManager
echo " echo "
------------------------------------------------------------------------- -------------------------------------------------------------------------
Setting up mirrors for optimal download Setting up mirrors for optimal download
-------------------------------------------------------------------------" -------------------------------------------------------------------------"
pacman -S --noconfirm --needed pacman-contrib curl pacman -S --noconfirm --needed pacman-contrib curl
pacman -S --noconfirm --needed reflector rsync grub arch-install-scripts git pacman -S --noconfirm --needed reflector rsync grub arch-install-scripts git
@ -44,7 +44,7 @@ sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg
fi fi
echo " echo "
------------------------------------------------------------------------- -------------------------------------------------------------------------
Setup Language to US and set locale Setup Language to US and set locale
-------------------------------------------------------------------------" -------------------------------------------------------------------------"
sed -i '/en_US.UTF-8 UTF-8/s/^#//' /etc/locale.gen sed -i '/en_US.UTF-8 UTF-8/s/^#//' /etc/locale.gen
locale-gen locale-gen
@ -68,13 +68,12 @@ pacman -Sy --noconfirm --needed
echo " echo "
------------------------------------------------------------------------- -------------------------------------------------------------------------
Installing Base System Installing Base System
-------------------------------------------------------------------------" -------------------------------------------------------------------------"
# sed $INSTALL_TYPE is using install type to check for MINIMAL installation, if it's true, stop # sed $INSTALL_TYPE is using install type to check for MINIMAL installation, if it's true, stop
# stop the script and move on, not installing any more packages below that line # stop the script and move on, not installing any more packages below that line
if [[ ! $DESKTOP_ENV == server ]]; then if [[ ! $DESKTOP_ENV == server ]]; then
sed -n '/'$INSTALL_TYPE'/q;p' $HOME/ArchTitus/pkg-files/pacman-pkgs.txt | while read line sed -n '/'$INSTALL_TYPE'/q;p' $HOME/ArchTitus/pkg-files/pacman-pkgs.txt | while read line; do
do
if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]; then if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]; then
# If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line # If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line
continue continue
@ -116,17 +115,15 @@ fi
#SETUP IS WRONG THIS IS RUN #SETUP IS WRONG THIS IS RUN
if ! source $HOME/ArchTitus/configs/setup.conf; then if ! source $HOME/ArchTitus/configs/setup.conf; then
# Loop through user input until the user gives a valid username # Loop through user input until the user gives a valid username
while true while true; do
do
read -p "Please enter username:" username read -p "Please enter username:" username
# username regex per response here https://unix.stackexchange.com/questions/157426/what-is-the-regex-to-validate-linux-users # username regex per response here https://unix.stackexchange.com/questions/157426/what-is-the-regex-to-validate-linux-users
# lowercase the username to test regex # lowercase the username to test regex
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]] if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]; then
then
break break
fi fi
echo "Incorrect username." echo "Incorrect username."
done done
# convert name to lowercase before saving to setup.conf # convert name to lowercase before saving to setup.conf
echo "username=${username,,}" >> ${HOME}/ArchTitus/configs/setup.conf echo "username=${username,,}" >> ${HOME}/ArchTitus/configs/setup.conf
@ -134,22 +131,19 @@ echo "username=${username,,}" >> ${HOME}/ArchTitus/configs/setup.conf
read -p "Please enter password:" password read -p "Please enter password:" password
echo "password=${password,,}" >> ${HOME}/ArchTitus/configs/setup.conf echo "password=${password,,}" >> ${HOME}/ArchTitus/configs/setup.conf
# Loop through user input until the user gives a valid hostname, but allow the user to force save # Loop through user input until the user gives a valid hostname, but allow the user to force save
while true while true; do
do
read -p "Please name your machine:" name_of_machine read -p "Please name your machine:" name_of_machine
# hostname regex (!!couldn't find spec for computer name!!) # hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]] if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]; then
then break
break fi
fi
# if validation fails allow the user to force saving of the hostname # 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 read -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
if [[ "${force,,}" = "y" ]] if [[ "${force,,}" = "y" ]]; then
then break
break fi
fi done
done
echo "NAME_OF_MACHINE=${name_of_machine,,}" >> ${HOME}/ArchTitus/configs/setup.conf echo "NAME_OF_MACHINE=${name_of_machine,,}" >> ${HOME}/ArchTitus/configs/setup.conf
fi fi
@ -159,7 +153,7 @@ echo "
-------------------------------------------------------------------------" -------------------------------------------------------------------------"
if [ $(whoami) = "root" ]; then if [ $(whoami) = "root" ]; then
groupadd libvirt groupadd libvirt
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash" echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash"
# use chpasswd to enter $USERNAME:$password # use chpasswd to enter $USERNAME:$password

View File

@ -26,10 +26,8 @@ source $HOME/ArchTitus/configs/setup.conf
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
ln -s "~/zsh/.zshrc" ~/.zshrc ln -s "~/zsh/.zshrc" ~/.zshrc
sed -n '/'$INSTALL_TYPE'/q;p' ~/ArchTitus/pkg-files/${DESKTOP_ENV}.txt | while read line sed -n '/'$INSTALL_TYPE'/q;p' ~/ArchTitus/pkg-files/${DESKTOP_ENV}.txt | while read line; do
do if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]; then
if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]
then
# If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line # If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line
continue continue
fi fi
@ -45,8 +43,7 @@ if [[ ! $AUR_HELPER == none ]]; then
makepkg -si --noconfirm makepkg -si --noconfirm
# sed $INSTALL_TYPE is using install type to check for MINIMAL installation, if it's true, stop # sed $INSTALL_TYPE is using install type to check for MINIMAL installation, if it's true, stop
# stop the script and move on, not installing any more packages below that line # stop the script and move on, not installing any more packages below that line
sed -n '/'$INSTALL_TYPE'/q;p' ~/ArchTitus/pkg-files/aur-pkgs.txt | while read line sed -n '/'$INSTALL_TYPE'/q;p' ~/ArchTitus/pkg-files/aur-pkgs.txt | while read line; do
do
if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]; then if [[ ${line} == '--END OF MINIMAL INSTALL--' ]]; then
# If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line # If selected installation type is FULL, skip the --END OF THE MINIMAL INSTALLATION-- line
continue continue

View File

@ -150,8 +150,7 @@ sed -i 's/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# &/' /etc/sudoers
sed -i '/%wheel ALL=(ALL) ALL/s/^# //' /etc/sudoers sed -i '/%wheel ALL=(ALL) ALL/s/^# //' /etc/sudoers
sed -i '/%wheel ALL=(ALL:ALL) ALL/s/^# //' /etc/sudoers sed -i '/%wheel ALL=(ALL:ALL) ALL/s/^# //' /etc/sudoers
rm -r $HOME/ArchTitus rm -r $HOME/ArchTitus /home/$USERNAME/ArchTitus
rm -r /home/$USERNAME/ArchTitus
# Replace in the same state # Replace in the same state
cd $pwd cd $pwd

View File

@ -7,7 +7,7 @@
# @stderror Output routed to startup.log # @stderror Output routed to startup.log
# @setting-header General Settings # @setting-header General Settings
# @setting CONFIG_FILE string[$CONFIGS_DIR/setup.conf] Location of setup.conf to be used by set_option and all subsequent scripts. # @setting CONFIG_FILE string[$CONFIGS_DIR/setup.conf] Location of setup.conf to be used by set_option and all subsequent scripts.
CONFIG_FILE=$CONFIGS_DIR/setup.conf CONFIG_FILE=$CONFIGS_DIR/setup.conf
if [ ! -f $CONFIG_FILE ]; then # check if file exists if [ ! -f $CONFIG_FILE ]; then # check if file exists
touch -f $CONFIG_FILE # create file if not exists touch -f $CONFIG_FILE # create file if not exists
@ -56,7 +56,7 @@ select_option() {
if [[ $key = [B || $key = j ]]; then echo down; fi; if [[ $key = [B || $key = j ]]; then echo down; fi;
if [[ $key = [C || $key = l ]]; then echo right; fi; if [[ $key = [C || $key = l ]]; then echo right; fi;
if [[ $key = [D || $key = h ]]; then echo left; fi; if [[ $key = [D || $key = h ]]; then echo left; fi;
fi fi
} }
print_options_multicol() { print_options_multicol() {
# print options by overwriting the last lines # print options by overwriting the last lines
@ -67,9 +67,9 @@ select_option() {
local idx=0 local idx=0
local row=0 local row=0
local col=0 local col=0
curr_idx=$(( $curr_col + $curr_row * $colmax )) curr_idx=$(( $curr_col + $curr_row * $colmax ))
for option in "${options[@]}"; do for option in "${options[@]}"; do
row=$(( $idx/$colmax )) row=$(( $idx/$colmax ))
@ -95,7 +95,7 @@ select_option() {
local startrow=$(($lastrow - $#)) local startrow=$(($lastrow - $#))
local startcol=1 local startcol=1
local lines=$( tput lines ) local lines=$( tput lines )
local cols=$( tput cols ) local cols=$( tput cols )
local colmax=$2 local colmax=$2
local offset=$(( $cols / $colmax )) local offset=$(( $cols / $colmax ))
@ -109,7 +109,7 @@ select_option() {
local active_row=0 local active_row=0
local active_col=0 local active_col=0
while true; do while true; do
print_options_multicol $active_col $active_row print_options_multicol $active_col $active_row
# user key control # user key control
case `key_input` in case `key_input` in
enter) break;; enter) break;;
@ -144,7 +144,7 @@ echo "
██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
------------------------------------------------------------------------ ------------------------------------------------------------------------
Please select presetup settings for your system Please select presetup settings for your system
------------------------------------------------------------------------" ------------------------------------------------------------------------"
} }
# @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
@ -158,7 +158,7 @@ select_option $? 1 "${options[@]}"
case $? in case $? in
0) set_option FS btrfs;; 0) set_option FS btrfs;;
1) set_option FS ext4;; 1) set_option FS ext4;;
2) 2)
while true; do while true; do
read -r -s -p "Please enter your luks password: " luks_password # read password without echo read -r -s -p "Please enter your luks password: " luks_password # read password without echo
echo echo
@ -178,13 +178,13 @@ done
*) 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 " echo "
System detected your timezone to be '$time_zone' " System detected your timezone to be '$time_zone' "
echo "Is this correct?" echo "Is this correct?"
options=("Yes" "No") options=("Yes" "No")
select_option $? 1 "${options[@]}" select_option $? 1 "${options[@]}"
@ -199,7 +199,7 @@ case ${options[$?]} in
*) 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 () {
echo -n " echo -n "
Please select a keyboard layout from this list:" Please select a keyboard layout from this list:"
@ -253,10 +253,10 @@ echo -e "\n${disk%|*} selected \n"
drivessd 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 read -p "Please enter your username: " username
set_option USERNAME ${username,,} # convert to lower case as in issue #109 set_option USERNAME ${username,,} # convert to lower case as in issue #109
while true; do while true; do
read -r -s -p "Please enter your password: " password # read password without echo read -r -s -p "Please enter your password: " password # read password without echo
echo echo
@ -274,7 +274,7 @@ read -rep "Please enter your hostname: " nameofmachine
set_option NAME_OF_MACHINE $nameofmachine set_option NAME_OF_MACHINE $nameofmachine
} }
# @description Choose AUR helper. # @description Choose AUR helper.
aurhelper () { aurhelper () {
# Let the user choose AUR helper from predefined list # Let the user choose AUR helper from predefined list
echo "Please enter your desired AUR helper:" echo "Please enter your desired AUR helper:"
@ -294,7 +294,7 @@ desktopenv () {
set_option DESKTOP_ENV $desktop_env set_option DESKTOP_ENV $desktop_env
} }
# @description Choose whether to do full or minimal installation. # @description Choose whether to do full or minimal installation.
installtype () { installtype () {
echo -e "Please select type of installation:\n\n echo -e "Please select type of installation:\n\n
Full install: Installs full featured desktop enviroment, with added apps and themes needed for everyday use\n Full install: Installs full featured desktop enviroment, with added apps and themes needed for everyday use\n