mirror of
https://github.com/classy-giraffe/easy-arch.git
synced 2025-11-17 19:40:55 +00:00
Better input.
This commit is contained in:
parent
550a74e5d7
commit
97a740ce76
1 changed files with 76 additions and 77 deletions
153
easy-arch.sh
153
easy-arch.sh
|
|
@ -12,11 +12,11 @@ BYELLOW='\e[93m'
|
||||||
RESET='\e[0m'
|
RESET='\e[0m'
|
||||||
|
|
||||||
# Pretty print (function).
|
# Pretty print (function).
|
||||||
print () {
|
info_print () {
|
||||||
echo -e "${BOLD}${BYELLOW}[ ${BGREEN}•${BYELLOW} ] $1${RESET}"
|
echo -e "${BOLD}${BYELLOW}[ ${BGREEN}•${BYELLOW} ] $1${RESET}"
|
||||||
}
|
}
|
||||||
# Alert user of bad input (function).
|
# Alert user of bad input (function).
|
||||||
incEcho () {
|
error_print () {
|
||||||
echo -e "${BOLD}${BRED}[ ${BBLUE}•${BRED} ] $1${RESET}"
|
echo -e "${BOLD}${BRED}[ ${BBLUE}•${BRED} ] $1${RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,20 +24,20 @@ incEcho () {
|
||||||
virt_check () {
|
virt_check () {
|
||||||
hypervisor=$(systemd-detect-virt)
|
hypervisor=$(systemd-detect-virt)
|
||||||
case $hypervisor in
|
case $hypervisor in
|
||||||
kvm ) print "KVM has been detected, setting up guest tools."
|
kvm ) info_print "KVM has been detected, setting up guest tools."
|
||||||
pacstrap /mnt qemu-guest-agent &>/dev/null
|
pacstrap /mnt qemu-guest-agent &>/dev/null
|
||||||
systemctl enable qemu-guest-agent --root=/mnt &>/dev/null
|
systemctl enable qemu-guest-agent --root=/mnt &>/dev/null
|
||||||
;;
|
;;
|
||||||
vmware ) print "VMWare Workstation/ESXi has been detected, setting up guest tools."
|
vmware ) info_print "VMWare Workstation/ESXi has been detected, setting up guest tools."
|
||||||
pacstrap /mnt open-vm-tools >/dev/null
|
pacstrap /mnt open-vm-tools >/dev/null
|
||||||
systemctl enable vmtoolsd --root=/mnt &>/dev/null
|
systemctl enable vmtoolsd --root=/mnt &>/dev/null
|
||||||
systemctl enable vmware-vmblock-fuse --root=/mnt &>/dev/null
|
systemctl enable vmware-vmblock-fuse --root=/mnt &>/dev/null
|
||||||
;;
|
;;
|
||||||
oracle ) print "VirtualBox has been detected, setting up guest tools."
|
oracle ) info_print "VirtualBox has been detected, setting up guest tools."
|
||||||
pacstrap /mnt virtualbox-guest-utils &>/dev/null
|
pacstrap /mnt virtualbox-guest-utils &>/dev/null
|
||||||
systemctl enable vboxservice --root=/mnt &>/dev/null
|
systemctl enable vboxservice --root=/mnt &>/dev/null
|
||||||
;;
|
;;
|
||||||
microsoft ) print "Hyper-V has been detected, setting up guest tools."
|
microsoft ) info_print "Hyper-V has been detected, setting up guest tools."
|
||||||
pacstrap /mnt hyperv &>/dev/null
|
pacstrap /mnt hyperv &>/dev/null
|
||||||
systemctl enable hv_fcopy_daemon --root=/mnt &>/dev/null
|
systemctl enable hv_fcopy_daemon --root=/mnt &>/dev/null
|
||||||
systemctl enable hv_kvp_daemon --root=/mnt &>/dev/null
|
systemctl enable hv_kvp_daemon --root=/mnt &>/dev/null
|
||||||
|
|
@ -48,11 +48,11 @@ virt_check () {
|
||||||
|
|
||||||
# Selecting a kernel to install (function).
|
# Selecting a kernel to install (function).
|
||||||
kernel_selector () {
|
kernel_selector () {
|
||||||
print "List of kernels:"
|
info_print "List of kernels:"
|
||||||
print "1) Stable: Vanilla Linux kernel with a few specific Arch Linux patches applied"
|
info_print "1) Stable: Vanilla Linux kernel with a few specific Arch Linux patches applied"
|
||||||
print "2) Hardened: A security-focused Linux kernel"
|
info_print "2) Hardened: A security-focused Linux kernel"
|
||||||
print "3) Longterm: Long-term support (LTS) Linux kernel"
|
info_print "3) Longterm: Long-term support (LTS) Linux kernel"
|
||||||
print "4) Zen Kernel: A Linux kernel optimized for desktop usage"
|
info_print "4) Zen Kernel: A Linux kernel optimized for desktop usage"
|
||||||
read -r -p "Please select the number of the corresponding kernel (e.g. 1): " kernel_choice
|
read -r -p "Please select the number of the corresponding kernel (e.g. 1): " kernel_choice
|
||||||
case $kernel_choice in
|
case $kernel_choice in
|
||||||
1 ) kernel="linux"
|
1 ) kernel="linux"
|
||||||
|
|
@ -63,22 +63,22 @@ kernel_selector () {
|
||||||
return 0;;
|
return 0;;
|
||||||
4 ) kernel="linux-zen"
|
4 ) kernel="linux-zen"
|
||||||
return 0;;
|
return 0;;
|
||||||
* ) incEcho "You did not enter a valid selection."
|
* ) error_print "You did not enter a valid selection."
|
||||||
return 1
|
return 1
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Selecting a way to handle internet connection (function).
|
# Selecting a way to handle internet connection (function).
|
||||||
network_selector () {
|
network_selector () {
|
||||||
print "Network utilities:"
|
info_print "Network utilities:"
|
||||||
print "1) IWD: Utility to connect to networks written by Intel (WiFi-only, built-in DHCP client)"
|
info_print "1) IWD: Utility to connect to networks written by Intel (WiFi-only, built-in DHCP client)"
|
||||||
print "2) NetworkManager: Universal network utility (both WiFi and Ethernet, highly recommended)"
|
info_print "2) NetworkManager: Universal network utility (both WiFi and Ethernet, highly recommended)"
|
||||||
print "3) wpa_supplicant: Utility with support for WEP and WPA/WPA2 (WiFi-only, DHCPCD will be automatically installed)"
|
info_print "3) wpa_supplicant: Utility with support for WEP and WPA/WPA2 (WiFi-only, DHCPCD will be automatically installed)"
|
||||||
print "4) dhcpcd: Basic DHCP client (Ethernet connections or VMs)"
|
info_print "4) dhcpcd: Basic DHCP client (Ethernet connections or VMs)"
|
||||||
print "5) I will do this on my own (only advanced users)"
|
info_print "5) I will do this on my own (only advanced users)"
|
||||||
read -r -p "Please select the number of the corresponding networking utility (e.g. 1): " network_choice
|
read -r -p "Please select the number of the corresponding networking utility (e.g. 1): " network_choice
|
||||||
if ! ((1 <= network_choice <= 5)); then
|
if ! ((1 <= network_choice <= 5)); then
|
||||||
incEcho "You did not enter a valid selection."
|
error_print "You did not enter a valid selection."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -87,25 +87,25 @@ network_selector () {
|
||||||
# Installing the chosen networking method to the system (function).
|
# Installing the chosen networking method to the system (function).
|
||||||
network_installer () {
|
network_installer () {
|
||||||
case $network_choice in
|
case $network_choice in
|
||||||
1 ) print "Installing IWD."
|
1 ) info_print "Installing IWD."
|
||||||
pacstrap /mnt iwd >/dev/null
|
pacstrap /mnt iwd >/dev/null
|
||||||
print "Enabling IWD."
|
info_print "Enabling IWD."
|
||||||
systemctl enable iwd --root=/mnt &>/dev/null
|
systemctl enable iwd --root=/mnt &>/dev/null
|
||||||
;;
|
;;
|
||||||
2 ) print "Installing NetworkManager."
|
2 ) info_print "Installing NetworkManager."
|
||||||
pacstrap /mnt networkmanager >/dev/null
|
pacstrap /mnt networkmanager >/dev/null
|
||||||
print "Enabling NetworkManager."
|
info_print "Enabling NetworkManager."
|
||||||
systemctl enable NetworkManager --root=/mnt &>/dev/null
|
systemctl enable NetworkManager --root=/mnt &>/dev/null
|
||||||
;;
|
;;
|
||||||
3 ) print "Installing wpa_supplicant and dhcpcd."
|
3 ) info_print "Installing wpa_supplicant and dhcpcd."
|
||||||
pacstrap /mnt wpa_supplicant dhcpcd >/dev/null
|
pacstrap /mnt wpa_supplicant dhcpcd >/dev/null
|
||||||
print "Enabling wpa_supplicant and dhcpcd."
|
info_print "Enabling wpa_supplicant and dhcpcd."
|
||||||
systemctl enable wpa_supplicant --root=/mnt &>/dev/null
|
systemctl enable wpa_supplicant --root=/mnt &>/dev/null
|
||||||
systemctl enable dhcpcd --root=/mnt &>/dev/null
|
systemctl enable dhcpcd --root=/mnt &>/dev/null
|
||||||
;;
|
;;
|
||||||
4 ) print "Installing dhcpcd."
|
4 ) info_print "Installing dhcpcd."
|
||||||
pacstrap /mnt dhcpcd >/dev/null
|
pacstrap /mnt dhcpcd >/dev/null
|
||||||
print "Enabling dhcpcd."
|
info_print "Enabling dhcpcd."
|
||||||
systemctl enable dhcpcd --root=/mnt &>/dev/null
|
systemctl enable dhcpcd --root=/mnt &>/dev/null
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
@ -114,12 +114,12 @@ network_installer () {
|
||||||
lukspass_selector () {
|
lukspass_selector () {
|
||||||
read -r -s -p "Insert the password for the LUKS container (you're not going to see the password): " password
|
read -r -s -p "Insert the password for the LUKS container (you're not going to see the password): " password
|
||||||
if [[ -z "$password" ]]; then
|
if [[ -z "$password" ]]; then
|
||||||
incEcho "You need to enter a password for the LUKS Container in order to continue."
|
error_print "\nYou need to enter a password for the LUKS Container in order to continue."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
read -r -s -p "Insert the password for the LUKS container again (you're not going to see the password): " password2
|
read -r -s -p "Insert the password for the LUKS container again (you're not going to see the password): " password2
|
||||||
if [[ "$password" != "$password2" ]]; then
|
if [[ "$password" != "$password2" ]]; then
|
||||||
incEcho "Passwords don't match, please try again."
|
error_print "Passwords don't match, please try again."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -133,12 +133,12 @@ userpass_selector () {
|
||||||
fi
|
fi
|
||||||
read -r -s -p "Insert a user password for $username (you're not going to see the password): " userpass
|
read -r -s -p "Insert a user password for $username (you're not going to see the password): " userpass
|
||||||
if [[ -z "$userpass" ]]; then
|
if [[ -z "$userpass" ]]; then
|
||||||
incEcho "You need to enter a password for $username in order to continue."
|
error_print "You need to enter a password for $username in order to continue."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
read -r -s -p "Insert the password again (you're not going to see the password): " userpass2
|
read -r -s -p "Insert the password again (you're not going to see the password): " userpass2
|
||||||
if [[ "$userpass" != "$userpass2" ]]; then
|
if [[ "$userpass" != "$userpass2" ]]; then
|
||||||
incEcho "Passwords don't match, please try again."
|
error_print "Passwords don't match, please try again."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -148,12 +148,12 @@ userpass_selector () {
|
||||||
rootpass_selector () {
|
rootpass_selector () {
|
||||||
read -r -s -p "Insert a user password for the root user (you're not going to see it): " rootpass
|
read -r -s -p "Insert a user password for the root user (you're not going to see it): " rootpass
|
||||||
if [[ -z "$rootpass" ]]; then
|
if [[ -z "$rootpass" ]]; then
|
||||||
incEcho "You need to enter a root password."
|
error_print "You need to enter a root password."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
read -r -s -p "Insert the password again (for double checking): " rootpass2
|
read -r -s -p "Insert the password again (for double checking): " rootpass2
|
||||||
if [[ "$rootpass" != "$rootpass2" ]]; then
|
if [[ "$rootpass" != "$rootpass2" ]]; then
|
||||||
incEcho "Passwords don't match, try again."
|
error_print "Passwords don't match, try again."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -163,10 +163,10 @@ rootpass_selector () {
|
||||||
microcode_detector () {
|
microcode_detector () {
|
||||||
CPU=$(grep vendor_id /proc/cpuinfo)
|
CPU=$(grep vendor_id /proc/cpuinfo)
|
||||||
if [[ "$CPU" == *"AuthenticAMD"* ]]; then
|
if [[ "$CPU" == *"AuthenticAMD"* ]]; then
|
||||||
print "An AMD CPU has been detected, the AMD microcode will be installed."
|
info_print "An AMD CPU has been detected, the AMD microcode will be installed."
|
||||||
microcode="amd-ucode"
|
microcode="amd-ucode"
|
||||||
else
|
else
|
||||||
print "An Intel CPU has been detected, the Intel microcode will be installed."
|
info_print "An Intel CPU has been detected, the Intel microcode will be installed."
|
||||||
microcode="intel-ucode"
|
microcode="intel-ucode"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +175,7 @@ microcode_detector () {
|
||||||
hostname_selector () {
|
hostname_selector () {
|
||||||
read -r -p "Please enter the hostname: " hostname
|
read -r -p "Please enter the hostname: " hostname
|
||||||
if [[ -z "$hostname" ]]; then
|
if [[ -z "$hostname" ]]; then
|
||||||
incEcho "You need to enter a hostname in order to continue."
|
error_print "You need to enter a hostname in order to continue."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -183,16 +183,17 @@ hostname_selector () {
|
||||||
|
|
||||||
# User chooses the locale (function).
|
# User chooses the locale (function).
|
||||||
locale_selector () {
|
locale_selector () {
|
||||||
read -r -p "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or \"/\" to search locales): " locale
|
info_print "Please insert the locale you use (format: xx_XX. Enter empty to use en_US, or \"/\" to search locales): " locale
|
||||||
case $locale in
|
read -r locale
|
||||||
|
case "$locale" in
|
||||||
'') locale="en_US.UTF-8"
|
'') locale="en_US.UTF-8"
|
||||||
print "$locale will be the default locale."
|
info_print "$locale will be the default locale."
|
||||||
return 0;;
|
return 0;;
|
||||||
'/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M
|
'/') sed -E '/^# +|^#$/d;s/^#| *$//g;s/ .*/ (Charset:&)/' /etc/locale.gen | less -M
|
||||||
clear
|
clear
|
||||||
return 1;;
|
return 1;;
|
||||||
*) if ! grep -q "^#\?$(sed 's/[].*[]/\\&/g' <<< $locale) " /etc/locale.gen; then
|
*) if ! grep -q "^#\?$(sed 's/[].*[]/\\&/g' <<< $locale) " /etc/locale.gen; then
|
||||||
incEcho "The specified locale doesn't exist or isn't supported."
|
error_print "The specified locale doesn't exist or isn't supported."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -204,16 +205,16 @@ keyboard_selector () {
|
||||||
read -r -p "Please insert the keyboard layout to use in console (enter empty to use US, or \"/\" to look up for keyboard layouts): " kblayout
|
read -r -p "Please insert the keyboard layout to use in console (enter empty to use US, or \"/\" to look up for keyboard layouts): " kblayout
|
||||||
case "$kblayout" in
|
case "$kblayout" in
|
||||||
'') kblayout="us"
|
'') kblayout="us"
|
||||||
print "The standard US keyboard layout will be used."
|
info_print "The standard US keyboard layout will be used."
|
||||||
return 0;;
|
return 0;;
|
||||||
'/') localectl list-keymaps
|
'/') localectl list-keymaps
|
||||||
clear
|
clear
|
||||||
return 1;;
|
return 1;;
|
||||||
*) if ! localectl list-keymaps | grep -Fxq "$kblayout"; then
|
*) if ! localectl list-keymaps | grep -Fxq "$kblayout"; then
|
||||||
incEcho "The specified keymap doesn't exist."
|
error_print "The specified keymap doesn't exist."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
print "Changing console layout to $kblayout."
|
info_print "Changing console layout to $kblayout."
|
||||||
loadkeys "$kblayout"
|
loadkeys "$kblayout"
|
||||||
return 0
|
return 0
|
||||||
esac
|
esac
|
||||||
|
|
@ -231,29 +232,21 @@ echo -ne "${BOLD}${BYELLOW}
|
||||||
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
|
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
|
||||||
======================================================================
|
======================================================================
|
||||||
${RESET}"
|
${RESET}"
|
||||||
print "Welcome to easy-arch, a script made in order to simplify the process of installing Arch Linux."
|
info_print "Welcome to easy-arch, a script made in order to simplify the process of installing Arch Linux."
|
||||||
|
|
||||||
# Setting up keyboard layout.
|
# Setting up keyboard layout.
|
||||||
until keyboard_selector; do : ; done
|
until keyboard_selector; do : ; done
|
||||||
|
|
||||||
# Choosing the target for the installation.
|
# Choosing the target for the installation.
|
||||||
print "Available disks for the installation (this is the disk where Arch Linux is going to be installed on):"
|
info_print "Available disks for the installation (this is the disk where Arch Linux is going to be installed on)"
|
||||||
PS3="Please select the number of the corresponding disk (e.g. 1): "
|
PS3="Please select the number of the corresponding disk (e.g. 1): "
|
||||||
select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd");
|
select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd");
|
||||||
do
|
do
|
||||||
DISK="$ENTRY"
|
DISK="$ENTRY"
|
||||||
print "Arch Linux will be installed to $DISK."
|
info_print "Arch Linux will be installed to $DISK."
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
# Warn user about deletion of old partition scheme.
|
|
||||||
echo -en "${BOLD}${BRED}This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?:${RESET} "
|
|
||||||
read -r disk_response
|
|
||||||
if ! [[ "${disk_response,,}" =~ ^(yes|y)$ ]]; then
|
|
||||||
print "Quitting."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setting up LUKS password.
|
# Setting up LUKS password.
|
||||||
until lukspass_selector; do : ; done
|
until lukspass_selector; do : ; done
|
||||||
|
|
||||||
|
|
@ -273,13 +266,19 @@ until hostname_selector; do : ; done
|
||||||
until userpass_selector; do : ; done
|
until userpass_selector; do : ; done
|
||||||
until rootpass_selector; do : ; done
|
until rootpass_selector; do : ; done
|
||||||
|
|
||||||
# Deleting old partition scheme.
|
# Warn user about deletion of old partition scheme.
|
||||||
print "Wiping $DISK."
|
error_print "This will delete the current partition table on $DISK once installation starts. Do you agree [y/N]?: "
|
||||||
|
read -r disk_response
|
||||||
|
if ! [[ "${disk_response,,}" =~ ^(yes|y)$ ]]; then
|
||||||
|
info_print "Quitting."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
info_print "Wiping $DISK."
|
||||||
wipefs -af "$DISK" &>/dev/null
|
wipefs -af "$DISK" &>/dev/null
|
||||||
sgdisk -Zo "$DISK" &>/dev/null
|
sgdisk -Zo "$DISK" &>/dev/null
|
||||||
|
|
||||||
# Creating a new partition scheme.
|
# Creating a new partition scheme.
|
||||||
print "Creating the partitions on $DISK."
|
info_print "Creating the partitions on $DISK."
|
||||||
parted -s "$DISK" \
|
parted -s "$DISK" \
|
||||||
mklabel gpt \
|
mklabel gpt \
|
||||||
mkpart ESP fat32 1MiB 513MiB \
|
mkpart ESP fat32 1MiB 513MiB \
|
||||||
|
|
@ -290,26 +289,26 @@ ESP="/dev/disk/by-partlabel/ESP"
|
||||||
CRYPTROOT="/dev/disk/by-partlabel/CRYPTROOT"
|
CRYPTROOT="/dev/disk/by-partlabel/CRYPTROOT"
|
||||||
|
|
||||||
# Informing the Kernel of the changes.
|
# Informing the Kernel of the changes.
|
||||||
print "Informing the Kernel about the disk changes."
|
info_print "Informing the Kernel about the disk changes."
|
||||||
partprobe "$DISK"
|
partprobe "$DISK"
|
||||||
|
|
||||||
# Formatting the ESP as FAT32.
|
# Formatting the ESP as FAT32.
|
||||||
print "Formatting the EFI Partition as FAT32."
|
info_print "Formatting the EFI Partition as FAT32."
|
||||||
mkfs.fat -F 32 "$ESP" &>/dev/null
|
mkfs.fat -F 32 "$ESP" &>/dev/null
|
||||||
|
|
||||||
# Creating a LUKS Container for the root partition.
|
# Creating a LUKS Container for the root partition.
|
||||||
print "Creating LUKS Container for the root partition."
|
info_print "Creating LUKS Container for the root partition."
|
||||||
echo -n "$password" | cryptsetup luksFormat "$CRYPTROOT" -d - &>/dev/null
|
echo -n "$password" | cryptsetup luksFormat "$CRYPTROOT" -d - &>/dev/null
|
||||||
echo -n "$password" | cryptsetup open "$CRYPTROOT" cryptroot -d -
|
echo -n "$password" | cryptsetup open "$CRYPTROOT" cryptroot -d -
|
||||||
BTRFS="/dev/mapper/cryptroot"
|
BTRFS="/dev/mapper/cryptroot"
|
||||||
|
|
||||||
# Formatting the LUKS Container as BTRFS.
|
# Formatting the LUKS Container as BTRFS.
|
||||||
print "Formatting the LUKS container as BTRFS."
|
info_print "Formatting the LUKS container as BTRFS."
|
||||||
mkfs.btrfs "$BTRFS" &>/dev/null
|
mkfs.btrfs "$BTRFS" &>/dev/null
|
||||||
mount "$BTRFS" /mnt
|
mount "$BTRFS" /mnt
|
||||||
|
|
||||||
# Creating BTRFS subvolumes.
|
# Creating BTRFS subvolumes.
|
||||||
print "Creating BTRFS subvolumes."
|
info_print "Creating BTRFS subvolumes."
|
||||||
subvols=(snapshots var_pkgs var_log home root srv)
|
subvols=(snapshots var_pkgs var_log home root srv)
|
||||||
for subvol in '' "${subvols[@]}"; do
|
for subvol in '' "${subvols[@]}"; do
|
||||||
btrfs su cr /mnt/@"$subvol" &>/dev/null
|
btrfs su cr /mnt/@"$subvol" &>/dev/null
|
||||||
|
|
@ -317,7 +316,7 @@ done
|
||||||
|
|
||||||
# Mounting the newly created subvolumes.
|
# Mounting the newly created subvolumes.
|
||||||
umount /mnt
|
umount /mnt
|
||||||
print "Mounting the newly created subvolumes."
|
info_print "Mounting the newly created subvolumes."
|
||||||
mountopts="ssd,noatime,compress-force=zstd:3,discard=async"
|
mountopts="ssd,noatime,compress-force=zstd:3,discard=async"
|
||||||
mount -o "$mountopts",subvol=@ "$BTRFS" /mnt
|
mount -o "$mountopts",subvol=@ "$BTRFS" /mnt
|
||||||
mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot}
|
mkdir -p /mnt/{home,root,srv,.snapshots,var/{log,cache/pacman/pkg},boot}
|
||||||
|
|
@ -331,14 +330,14 @@ chattr +C /mnt/var/log
|
||||||
mount "$ESP" /mnt/boot/
|
mount "$ESP" /mnt/boot/
|
||||||
|
|
||||||
# Pacstrap (setting up a base sytem onto the new root).
|
# Pacstrap (setting up a base sytem onto the new root).
|
||||||
print "Installing the base system (it may take a while)."
|
info_print "Installing the base system (it may take a while)."
|
||||||
pacstrap /mnt --needed base $kernel $microcode linux-firmware $kernel-headers btrfs-progs grub grub-btrfs rsync efibootmgr snapper reflector base-devel snap-pac zram-generator &>/dev/null
|
pacstrap /mnt --needed base $kernel $microcode linux-firmware $kernel-headers btrfs-progs grub grub-btrfs rsync efibootmgr snapper reflector base-devel snap-pac zram-generator &>/dev/null
|
||||||
|
|
||||||
# Setting up the hostname.
|
# Setting up the hostname.
|
||||||
echo "$hostname" > /mnt/etc/hostname
|
echo "$hostname" > /mnt/etc/hostname
|
||||||
|
|
||||||
# Generating /etc/fstab.
|
# Generating /etc/fstab.
|
||||||
print "Generating a new fstab."
|
info_print "Generating a new fstab."
|
||||||
genfstab -U /mnt >> /mnt/etc/fstab
|
genfstab -U /mnt >> /mnt/etc/fstab
|
||||||
|
|
||||||
# Configure selected locale and console keymap
|
# Configure selected locale and console keymap
|
||||||
|
|
@ -347,7 +346,7 @@ echo "LANG=$locale" > /mnt/etc/locale.conf
|
||||||
echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf
|
echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf
|
||||||
|
|
||||||
# Setting hosts file.
|
# Setting hosts file.
|
||||||
print "Setting hosts file."
|
info_print "Setting hosts file."
|
||||||
cat > /mnt/etc/hosts <<EOF
|
cat > /mnt/etc/hosts <<EOF
|
||||||
127.0.0.1 localhost
|
127.0.0.1 localhost
|
||||||
::1 localhost
|
::1 localhost
|
||||||
|
|
@ -364,18 +363,18 @@ virt_check
|
||||||
network_installer
|
network_installer
|
||||||
|
|
||||||
# Configuring /etc/mkinitcpio.conf.
|
# Configuring /etc/mkinitcpio.conf.
|
||||||
print "Configuring /etc/mkinitcpio.conf."
|
info_print "Configuring /etc/mkinitcpio.conf."
|
||||||
cat > /mnt/etc/mkinitcpio.conf <<EOF
|
cat > /mnt/etc/mkinitcpio.conf <<EOF
|
||||||
HOOKS=(systemd autodetect keyboard sd-vconsole modconf block sd-encrypt filesystems)
|
HOOKS=(systemd autodetect keyboard sd-vconsole modconf block sd-encrypt filesystems)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Setting up LUKS2 encryption in grub.
|
# Setting up LUKS2 encryption in grub.
|
||||||
print "Setting up grub config."
|
info_print "Setting up grub config."
|
||||||
UUID=$(blkid -s UUID -o value $CRYPTROOT)
|
UUID=$(blkid -s UUID -o value $CRYPTROOT)
|
||||||
sed -i "\,^GRUB_CMDLINE_LINUX=\"\",s,\",&rd.luks.name=$UUID=cryptroot root=$BTRFS," /mnt/etc/default/grub
|
sed -i "\,^GRUB_CMDLINE_LINUX=\"\",s,\",&rd.luks.name=$UUID=cryptroot root=$BTRFS," /mnt/etc/default/grub
|
||||||
|
|
||||||
# Configuring the system.
|
# Configuring the system.
|
||||||
print "Configuring the system (timezone, system clock, initramfs, Snapper, GRUB)."
|
info_print "Configuring the system (timezone, system clock, initramfs, Snapper, GRUB)."
|
||||||
arch-chroot /mnt /bin/bash -e <<EOF
|
arch-chroot /mnt /bin/bash -e <<EOF
|
||||||
|
|
||||||
# Setting up timezone.
|
# Setting up timezone.
|
||||||
|
|
@ -408,20 +407,20 @@ arch-chroot /mnt /bin/bash -e <<EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Setting root password.
|
# Setting root password.
|
||||||
print "Setting root password."
|
info_print "Setting root password."
|
||||||
echo "root:$rootpass" | arch-chroot /mnt chpasswd
|
echo "root:$rootpass" | arch-chroot /mnt chpasswd
|
||||||
|
|
||||||
# Setting user password.
|
# Setting user password.
|
||||||
if [[ -n "$username" ]]; then
|
if [[ -n "$username" ]]; then
|
||||||
echo "%wheel ALL=(ALL:ALL) ALL" > /mnt/etc/sudoers.d/wheel
|
echo "%wheel ALL=(ALL:ALL) ALL" > /mnt/etc/sudoers.d/wheel
|
||||||
print "Adding the user $username to the system with root privilege."
|
info_print "Adding the user $username to the system with root privilege."
|
||||||
arch-chroot /mnt useradd -m -G wheel -s /bin/bash "$username"
|
arch-chroot /mnt useradd -m -G wheel -s /bin/bash "$username"
|
||||||
print "Setting user password for $username."
|
info_print "Setting user password for $username."
|
||||||
echo "$username:$userpass" | arch-chroot /mnt chpasswd
|
echo "$username:$userpass" | arch-chroot /mnt chpasswd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Boot backup hook.
|
# Boot backup hook.
|
||||||
print "Configuring /boot backup when pacman transactions are made."
|
info_print "Configuring /boot backup when pacman transactions are made."
|
||||||
mkdir /mnt/etc/pacman.d/hooks
|
mkdir /mnt/etc/pacman.d/hooks
|
||||||
cat > /mnt/etc/pacman.d/hooks/50-bootbackup.hook <<EOF
|
cat > /mnt/etc/pacman.d/hooks/50-bootbackup.hook <<EOF
|
||||||
[Trigger]
|
[Trigger]
|
||||||
|
|
@ -439,23 +438,23 @@ Exec = /usr/bin/rsync -a --delete /boot /.bootbackup
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# ZRAM configuration.
|
# ZRAM configuration.
|
||||||
print "Configuring ZRAM."
|
info_print "Configuring ZRAM."
|
||||||
cat > /mnt/etc/systemd/zram-generator.conf <<EOF
|
cat > /mnt/etc/systemd/zram-generator.conf <<EOF
|
||||||
[zram0]
|
[zram0]
|
||||||
zram-size = min(ram, 8192)
|
zram-size = min(ram, 8192)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Pacman eye-candy features.
|
# Pacman eye-candy features.
|
||||||
print "Enabling colours, animations, and parallel downloads for pacman."
|
info_print "Enabling colours, animations, and parallel downloads for pacman."
|
||||||
sed -Ei 's/^#(Color)$/\1\nILoveCandy/;s/^#(ParallelDownloads).*/\1 = 10/' /mnt/etc/pacman.conf
|
sed -Ei 's/^#(Color)$/\1\nILoveCandy/;s/^#(ParallelDownloads).*/\1 = 10/' /mnt/etc/pacman.conf
|
||||||
|
|
||||||
# Enabling various services.
|
# Enabling various services.
|
||||||
print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd."
|
info_print "Enabling Reflector, automatic snapshots, BTRFS scrubbing and systemd-oomd."
|
||||||
services=(reflector.timer snapper-timeline.timer snapper-cleanup.timer btrfs-scrub@-.timer btrfs-scrub@home.timer btrfs-scrub@var-log.timer btrfs-scrub@\\x2esnapshots.timer grub-btrfs.path systemd-oomd)
|
services=(reflector.timer snapper-timeline.timer snapper-cleanup.timer btrfs-scrub@-.timer btrfs-scrub@home.timer btrfs-scrub@var-log.timer btrfs-scrub@\\x2esnapshots.timer grub-btrfs.path systemd-oomd)
|
||||||
for service in '' "${services[@]}"; do
|
for service in '' "${services[@]}"; do
|
||||||
systemctl enable "$service" --root=/mnt &>/dev/null
|
systemctl enable "$service" --root=/mnt &>/dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
# Finishing up.
|
# Finishing up.
|
||||||
print "Done, you may now wish to reboot (further changes can be done by chrooting into /mnt)."
|
info_print "Done, you may now wish to reboot (further changes can be done by chrooting into /mnt)."
|
||||||
exit
|
exit
|
||||||
Loading…
Add table
Add a link
Reference in a new issue