bash format
This commit is contained in:
parent
99e648635e
commit
6569ceca5b
75
startup.sh
75
startup.sh
|
|
@ -4,7 +4,7 @@
|
||||||
# user name, password, etc.
|
# user name, password, etc.
|
||||||
# shellcheck disable=SC2207,SC2120
|
# shellcheck disable=SC2207,SC2120
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
||||||
|
|
||||||
# Set up a config file
|
# Set up a config file
|
||||||
CONFIG_FILE=$SCRIPT_DIR/setup.conf
|
CONFIG_FILE=$SCRIPT_DIR/setup.conf
|
||||||
|
|
@ -20,7 +20,7 @@ set_option() {
|
||||||
sed -i -e "/^${1}.*/d" "$CONFIG_FILE"
|
sed -i -e "/^${1}.*/d" "$CONFIG_FILE"
|
||||||
fi
|
fi
|
||||||
# Else add option
|
# Else add option
|
||||||
echo "${1}=${2}" >> "$CONFIG_FILE"
|
echo "${1}=${2}" >>"$CONFIG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Adding global functions and variables to use in this script
|
# Adding global functions and variables to use in this script
|
||||||
|
|
@ -47,23 +47,23 @@ connection_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check coutry for mirrorlist
|
# Check coutry for mirrorlist
|
||||||
check_country () {
|
check_country() {
|
||||||
_ISO=$(curl --fail https://ifconfig.co/country-iso)
|
_ISO=$(curl --fail https://ifconfig.co/country-iso)
|
||||||
set_option "ISO" "$_ISO"
|
set_option "ISO" "$_ISO"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install fonts
|
# Install fonts
|
||||||
install_font () {
|
install_font() {
|
||||||
pacman -S --noconfirm --needed terminus-font
|
pacman -S --noconfirm --needed terminus-font
|
||||||
}
|
}
|
||||||
|
|
||||||
# timedatectl set-ntp true
|
# timedatectl set-ntp true
|
||||||
set_ntp () {
|
set_ntp() {
|
||||||
timedatectl set-ntp true
|
timedatectl set-ntp true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for UEFI
|
# Check for UEFI
|
||||||
efi_check () {
|
efi_check() {
|
||||||
if [[ -d "/sys/firmware/efi/" ]]; then
|
if [[ -d "/sys/firmware/efi/" ]]; then
|
||||||
if (mount | grep /sys/firmware/efi/efivars); then
|
if (mount | grep /sys/firmware/efi/efivars); then
|
||||||
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
|
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
|
||||||
|
|
@ -77,7 +77,7 @@ efi_check () {
|
||||||
}
|
}
|
||||||
|
|
||||||
# if btrfs is selected
|
# if btrfs is selected
|
||||||
set_btrfs () {
|
set_btrfs() {
|
||||||
# Used -a to get more than one argument
|
# Used -a to get more than one argument
|
||||||
echo "Please enter your btrfs subvolumes separated by space"
|
echo "Please enter your btrfs subvolumes separated by space"
|
||||||
echo "usualy they start with @ like @home, @temp etc."
|
echo "usualy they start with @ like @home, @temp etc."
|
||||||
|
|
@ -99,7 +99,7 @@ set_btrfs () {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# Check for duplicates
|
# Check for duplicates
|
||||||
IFS=" " read -r -a SUBS <<< "$(tr ' ' '\n' <<< "${NAMES[@]}" | sort -u | tr '\n' ' ')"
|
IFS=" " read -r -a SUBS <<<"$(tr ' ' '\n' <<<"${NAMES[@]}" | sort -u | tr '\n' ' ')"
|
||||||
# Set to config file
|
# Set to config file
|
||||||
set_option "SUBVOLUMES" "${SUBS[*]}"
|
set_option "SUBVOLUMES" "${SUBS[*]}"
|
||||||
fi
|
fi
|
||||||
|
|
@ -131,7 +131,7 @@ set_password() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make a title
|
# Make a title
|
||||||
title () {
|
title() {
|
||||||
echo -ne "\n"
|
echo -ne "\n"
|
||||||
echo -ne "------------------------------------------------------------------------\n"
|
echo -ne "------------------------------------------------------------------------\n"
|
||||||
echo -ne "\t\t\"$1\"\n"
|
echo -ne "\t\t\"$1\"\n"
|
||||||
|
|
@ -140,7 +140,7 @@ title () {
|
||||||
|
|
||||||
# Write shared functions to to setup.conf
|
# Write shared functions to to setup.conf
|
||||||
write_to_config() {
|
write_to_config() {
|
||||||
cat << EOF > "$CONFIG_FILE"
|
cat <<EOF >"$CONFIG_FILE"
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
title () {
|
title () {
|
||||||
|
|
@ -177,13 +177,12 @@ echo -ne "
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Ask user for option
|
# Ask user for option
|
||||||
PROMPT="Please enter your option: "
|
PROMPT="Please enter your option: "
|
||||||
|
|
||||||
# This will be shown on every set as user is progressing
|
# This will be shown on every set as user is progressing
|
||||||
logo () {
|
logo() {
|
||||||
echo -ne "
|
echo -ne "
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
█████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗
|
█████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗
|
||||||
|
|
@ -196,7 +195,7 @@ echo -ne "
|
||||||
}
|
}
|
||||||
|
|
||||||
# Backround checks
|
# Backround checks
|
||||||
background_check () {
|
background_check() {
|
||||||
if connection_test; then
|
if connection_test; then
|
||||||
echo -ne "ERROR! There seems to be no internet connection.\n"
|
echo -ne "ERROR! There seems to be no internet connection.\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -245,20 +244,18 @@ set_partion_layout() {
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
invalid_option
|
invalid_option
|
||||||
setpartionlayout
|
set_partion_layout
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
invalid_option
|
invalid_option
|
||||||
filesystem
|
set_partion_layout
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# This function will handle file systems.
|
# This function will handle file systems.
|
||||||
set_filesystem () {
|
set_filesystem() {
|
||||||
title "Setup File System"
|
title "Setup File System"
|
||||||
FILESYS=("btrfs" "ext2" "ext3" "ext4" "f2fs" "jfs" "nilfs2" "ntfs" "reiserfs" "vfat" "xfs")
|
FILESYS=("btrfs" "ext2" "ext3" "ext4" "f2fs" "jfs" "nilfs2" "ntfs" "reiserfs" "vfat" "xfs")
|
||||||
PS3="$PROMPT"
|
PS3="$PROMPT"
|
||||||
|
|
@ -278,7 +275,7 @@ set_filesystem () {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Added this from arch wiki https://wiki.archlinux.org/title/System_time
|
# Added this from arch wiki https://wiki.archlinux.org/title/System_time
|
||||||
set_timezone () {
|
set_timezone() {
|
||||||
title "Setup Time Zone"
|
title "Setup Time Zone"
|
||||||
_TIMEZONE="$(curl --fail https://ipapi.co/timezone)"
|
_TIMEZONE="$(curl --fail https://ipapi.co/timezone)"
|
||||||
_ZONE=($(timedatectl list-timezones | sed 's/\/.*$//' | uniq))
|
_ZONE=($(timedatectl list-timezones | sed 's/\/.*$//' | uniq))
|
||||||
|
|
@ -286,10 +283,10 @@ set_timezone () {
|
||||||
echo -ne "\n"
|
echo -ne "\n"
|
||||||
read -r -p "Is this correct? yes/no: " ANSWER
|
read -r -p "Is this correct? yes/no: " ANSWER
|
||||||
case "$ANSWER" in
|
case "$ANSWER" in
|
||||||
y|Y|yes|Yes|YES)
|
y | Y | yes | Yes | YES)
|
||||||
set_option TIMEZONE "$_TIMEZONE"
|
set_option TIMEZONE "$_TIMEZONE"
|
||||||
;;
|
;;
|
||||||
n|N|no|NO|No)
|
n | N | no | NO | No)
|
||||||
title "Manually setting timezone"
|
title "Manually setting timezone"
|
||||||
PS3="$PROMPT"
|
PS3="$PROMPT"
|
||||||
echo -ne "Please select your zone: \n"
|
echo -ne "Please select your zone: \n"
|
||||||
|
|
@ -315,12 +312,15 @@ set_timezone () {
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*) echo "Wrong option. Try again";timezone;;
|
*)
|
||||||
|
echo "Wrong option. Try again"
|
||||||
|
set_timezone
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# These are default key maps as presented in official arch repo archinstall
|
# These are default key maps as presented in official arch repo archinstall
|
||||||
set_keymap () {
|
set_keymap() {
|
||||||
title "Setup Keymap"
|
title "Setup Keymap"
|
||||||
KEYMAPS=("by" "ca" "cf" "cz" "de" "dk" "es" "et" "fa" "fi" "fr" "gr" "hu" "il" "it" "lt" "lv" "mk" "nl" "no" "pl" "ro" "ru" "sg" "ua" "uk" "us")
|
KEYMAPS=("by" "ca" "cf" "cz" "de" "dk" "es" "et" "fa" "fi" "fr" "gr" "hu" "il" "it" "lt" "lv" "mk" "nl" "no" "pl" "ro" "ru" "sg" "ua" "uk" "us")
|
||||||
PS3="$PROMPT"
|
PS3="$PROMPT"
|
||||||
|
|
@ -330,30 +330,33 @@ set_keymap () {
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
invalid_option
|
invalid_option
|
||||||
keymap
|
set_keymap
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Confirm if ssd is present
|
# Confirm if ssd is present
|
||||||
ssd_drive () {
|
ssd_drive() {
|
||||||
title "SSD Drive Confirmation"
|
title "SSD Drive Confirmation"
|
||||||
read -r -p "Is this system using an SSD? yes/no: " _SSD
|
read -r -p "Is this system using an SSD? yes/no: " _SSD
|
||||||
case "$_SSD" in
|
case "$_SSD" in
|
||||||
y|Y|yes|Yes|YES)
|
y | Y | yes | Yes | YES)
|
||||||
set_option "SSD" 1
|
set_option "SSD" 1
|
||||||
set_option "MOUNTOPTION" "noatime,compress=zstd,ssd,commit=120"
|
set_option "MOUNTOPTION" "noatime,compress=zstd,ssd,commit=120"
|
||||||
;;
|
;;
|
||||||
n|N|no|NO|No)
|
n | N | no | NO | No)
|
||||||
set_option "SSD" 0
|
set_option "SSD" 0
|
||||||
set_option "MOUNTOPTION" "noatime,compress=zstd,commit=120"
|
set_option "MOUNTOPTION" "noatime,compress=zstd,commit=120"
|
||||||
;;
|
;;
|
||||||
*) echo "Wrong option. Try again";ssddrive;;
|
*)
|
||||||
|
echo "Wrong option. Try again"
|
||||||
|
ssd_drive
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Selection for disk type
|
# Selection for disk type
|
||||||
disk_selection () {
|
disk_selection() {
|
||||||
# show disks present on system
|
# show disks present on system
|
||||||
title "Disk Selection"
|
title "Disk Selection"
|
||||||
DISKLIST="$(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2" - "$3}')" # show disks with /dev/ prefix and size
|
DISKLIST="$(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2" - "$3}')" # show disks with /dev/ prefix and size
|
||||||
|
|
@ -371,7 +374,7 @@ disk_selection () {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
user_info () {
|
user_info() {
|
||||||
title "Add Your Information"
|
title "Add Your Information"
|
||||||
read -r -p "Please enter your username: " USERNAME
|
read -r -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
|
||||||
|
|
@ -381,7 +384,7 @@ user_info () {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set locale
|
# Set locale
|
||||||
set_locale (){
|
set_locale() {
|
||||||
title "Setup Locale"
|
title "Setup Locale"
|
||||||
LOCALES=($(grep UTF-8 /etc/locale.gen | sed 's/\..*$//' | sed '/@/d' | awk '{print $1}' | uniq | sed 's/#//g'))
|
LOCALES=($(grep UTF-8 /etc/locale.gen | sed 's/\..*$//' | sed '/@/d' | awk '{print $1}' | uniq | sed 's/#//g'))
|
||||||
PS3="$PROMPT"
|
PS3="$PROMPT"
|
||||||
|
|
@ -455,7 +458,8 @@ set_desktop() {
|
||||||
set_option "WM" "i3-gaps"
|
set_option "WM" "i3-gaps"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*) echo "Wrong option. Try again"
|
*)
|
||||||
|
echo "Wrong option. Try again"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -468,7 +472,7 @@ set_desktop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make choice for installation
|
# Make choice for installation
|
||||||
make_choice () {
|
make_choice() {
|
||||||
title "Your system choice"
|
title "Your system choice"
|
||||||
CHOICE=("Default Install" "Custom Install")
|
CHOICE=("Default Install" "Custom Install")
|
||||||
PS3="$PROMPT"
|
PS3="$PROMPT"
|
||||||
|
|
@ -520,7 +524,8 @@ make_choice () {
|
||||||
set_desktop
|
set_desktop
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*) echo "Wrong option. Try again"
|
*)
|
||||||
|
echo "Wrong option. Try again"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue