archery/Amelia.sh
Jane Doe 158f224ccd Reduce visual prompts loading time
Hide <command> stdout/stderr for improved aesthetics
Greatly improve aesthetics in 'Filesystem Overview' prompt
Delete some visual prompts for clarity reasons
Add 'Warning' prompts when selecting NOT to format partitions, when in 'Manual Mode' > 'Format Partitions' stage
Revert 'Reflector's' output to 'verbose' for clarity reasons
Code indentation
2024-05-24 20:05:58 +00:00

4624 lines
129 KiB
Bash

#!/bin/bash
# Amelia Installer
# Version: 4.8
set -euo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
###########################################################################################
# ### COLOR FUNCTIONS ###
red="\e[31m"
redbg="\e[5;1;41m"
green="\e[32m"
yellow="\e[33m"
blue="\e[94m"
cyan="\e[36m"
purple="\e[35m"
nc="\e[0m"
bwhite="\e[0;97m"
RED (){
echo -e "${red} $1${nc}"
}
REDBG (){
echo -e "${redbg} $1${nc}"
}
GREEN (){
echo -e "${green} $1${nc}"
}
YELLOW (){
echo -e "${yellow} $1${nc}"
}
BLUE (){
echo -e "${blue} $1${nc}"
}
CYAN (){
echo -e "${cyan} $1${nc}"
}
PURPLE (){
echo -e "${purple} $1${nc}"
}
NC (){
echo -e "${nc} $1${nc}"
}
WHITEB (){
echo -e "${bwhite} $1${nc}"
}
# ### END COLOR FUNCTIONS ###
###########################################################################################
###########################################################################################
# ### PROMPT FUNCTIONS ###
skip (){
sleep 0.3
YELLOW "
--> Skipping.. "
}
#----------------------------------------------------------
reload (){
sleep 0.3
NC "
--> [${green}Reloading${nc}] "
}
#----------------------------------------------------------
invalid (){
sleep 0.3
RED "
[!] Invalid response "
reload
}
#----------------------------------------------------------
err_try (){
sleep 0.3
RED "
[!] Errors occured. Please try again.. "
reload
}
#----------------------------------------------------------
abort (){
sleep 0.3
RED "
[!] Aborting..
"
exit
}
#----------------------------------------------------------
err_abort (){
sleep 0.3
RED "
[!] Errors occured "
abort
}
#----------------------------------------------------------
umount_abort (){
sleep 0.3
RED "
[!] Errors occured
[!] Unmounting and Retrying.. "
reload
sleep 0.3
NC "
___________________________
${purple}###${nc} Unmount Filesystems ${purple}###${nc}
"
if umount -R /mnt; then
sleep 0.3
NC "
==> [${green}Unmount OK${nc}]"
else
sleep 0.3
RED "
[!] Unmounting failed "
abort
fi
reload
}
#----------------------------------------------------------
umount_manual (){
sleep 0.3
RED "
[!] Errors occured
[!] Unmounting and Retrying.. "
reload
sleep 0.3
NC "
___________________________
${purple}###${nc} Unmount Filesystems ${purple}###${nc}
"
if umount -R /mnt; then
sleep 0.3
NC "
==> [${green}Unmount OK${nc}]"
else
sleep 0.3
RED "
[!] Unmounting failed "
abort
fi
sleep 0.3
NC "
--> [Switching to ${green}Manual Mode${nc}]"
}
#----------------------------------------------------------
err_swapfile (){
sleep 0.3
RED "
[!] Swapfile creation error "
abort
}
#----------------------------------------------------------
err_reload (){
sleep 0.3
RED "
[!] Errors occured "
reload
}
#----------------------------------------------------------
choice (){
sleep 0.3
RED "
[!] Please make a choice to continue "
reload
}
#----------------------------------------------------------
ok (){
sleep 0.3
NC "
==> [${green}${prompt} OK${nc}] "
}
#----------------------------------------------------------
stage_ok (){
sleep 0.3
NC "
==> [${green}${stage_prompt} configuration OK${nc}]
"
sleep 1
}
#----------------------------------------------------------
stage_fail (){
sleep 0.3
RED "
[!] ${stage_prompt} configuration failed "
sleep 2
abort
}
#----------------------------------------------------------
completion (){
sleep 0.3
CYAN "
*******************************
### Installation Complete ###
$(date)
*******************************
"
}
# ### END PROMPT FUNCTIONS ###
###########################################################################################
###########################################################################################
# ### FUNCTIONS ###
first_check (){
if [[ -f /usr/share/kbd/consolefonts/ter-v20b.psf.gz && -f /usr/share/kbd/consolefonts/ter-v32b.psf.gz && "${tty}" == *"tty"* ]]; then
until slct_font; do : ; done
elif [[ -f /usr/share/kbd/consolefonts/ter-v20b.psf.gz && -f /usr/share/kbd/consolefonts/ter-v32b.psf.gz && "${tty}" == *"pts"* ]]; then
YELLOW "
### Supported 'Terminus Font' detected. Switch to console (tty) and re-run the installer to activate "
fi
if [[ "${run_as}" == "root" ]]; then
BLUE "
### The installer runs in [Root Mode]
"
REDBG " ----------------------------------------
### WARNING: High Risk Of Data Loss ###
----------------------------------------"
echo
else
PURPLE "
### The installer must be run as Root (Not 'wheel' group user) "
BLUE "
### Currently running with Limited Privileges [Test Mode]
"
fi
}
###########################################################################################
slct_font (){
sleep 0.3
NC "
______________________
${purple}###${nc} Font Selection ${purple}###${nc}
"
YELLOW "
> Select a Font: "
NC "
[1] Terminus Font
[2] HiDPI Terminus Font "
BLUE "
Enter a number: "
read -r -p "
==> " fontselect
if [[ "${fontselect}" == "1" ]]; then
setfont ter-v18b
elif [[ "${fontselect}" == "2" ]]; then
setfont ter-v32b
else
invalid
return 1
fi
clear
}
###########################################################################################
uefi_check (){
bootmode=$(cat /sys/firmware/efi/fw_platform_size)
local prompt="UEFI ${bootmode}-bit Mode"
sleep 0.3
NC "
______________________________
${purple}###${nc} UEFI Mode Verification ${purple}###${nc}
"
if [[ "${bootmode}" == "64" || "${bootmode}" == "32" ]]; then
ok
else
RED "
[!] Not in UEFI Mode "
abort
fi
}
###########################################################################################
connection_check (){
local prompt="Internet Connection"
sleep 0.3
NC "
_________________________________
${purple}###${nc} Internet Connection Check ${purple}###${nc}
"
if ping -c 3 archlinux.org > /dev/null 2>&1; then
ok
else
RED "
[!] An active internet connection is mandatory to continue "
abort
fi
}
###########################################################################################
upd_clock (){
local prompt="System Clock"
sleep 0.3
NC "
___________________________
${purple}###${nc} System Clock Update ${purple}###${nc}
"
sleep 0.3
timedatectl
ok
}
###########################################################################################
dtct_microcode (){
local prompt="Microcode"
sleep 0.3
NC "
___________________________
${purple}###${nc} Microcode Detection ${purple}###${nc}
"
CPU="$(grep vendor_id /proc/cpuinfo)"
if [[ "${CPU}" == *"GenuineIntel"* ]]; then
microcode="intel-ucode"
nrg_plc="x86_energy_perf_policy"
microname="'Intel'"
else
microcode="amd-ucode"
microname="'AMD'"
fi
sleep 0.3
YELLOW "
### Detection completed, the ""${microname}"" microcode will be installed
"
ok
}
###########################################################################################
main_menu (){
sleep 0.3
NC "
_________________
${purple}###${nc} Main Menu ${purple}###${nc}
"
YELLOW "
> Make a selection:
### Select ${nc}[4] ${yellow}for${bwhite} ${yellow}guided${nc} ${yellow}navigation
"
NC "
[1] Personalization
[2] System Configuration
[3] Disk Management
[4] Start Installation "
BLUE "
Enter a number: "
read -r -p "
==> " menu
case "${menu}" in
1)
until persnl_submn; do : ; done ;;
2)
until sys_submn; do : ; done ;;
3)
until dsks_submn; do : ; done ;;
4)
instl ;;
"")
sleep 0.3
RED "
[!] Please select a Submenu "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
}
###########################################################################################
persnl_submn (){
sleep 0.3
NC "
_______________________
${purple}###${nc} Personalization ${purple}###${nc}
"
YELLOW "
> Select a Submenu: "
NC "
[1] Locale & Keyboard Layout Setup
[2] User, Root User & Hostname Setup
[ ] Return to Main Menu "
BLUE "
Enter a number: "
read -r -p "
==> " persmenu
case "${persmenu}" in
1)
until slct_locale; do : ; done
until slct_kbd; do : ; done
return 1 ;;
2)
until user_setup; do : ; done
until rootuser_setup; do : ; done
until slct_hostname; do : ; done
return 1 ;;
"")
until main_menu; do : ; done ;;
*)
invalid
return 1 ;;
esac
}
###########################################################################################
slct_locale (){
local prompt="Locale"
sleep 0.3
NC "
________________________
${purple}###${nc} Locale Selection ${purple}###${nc}
"
YELLOW "
> Select your Locale (e.g. ${nc}en_US.UTF-8${yellow})
### [Hit ${nc}'l'${yellow} to list locales, then ${nc}'enter'${yellow} to search or ${nc}'q'${yellow} to quit] "
BLUE "
Enter your Locale ${bwhite}(empty for '${cyan}en_US.UTF-8${bwhite}')${blue}: "
read -r -p "
==> " SETLOCALE
if [[ -z "${SETLOCALE}" ]]; then
SETLOCALE="en_US.UTF-8"
sleep 0.3
YELLOW "
### 'en_US.UTF-8' Locale has been selected
"
elif [[ "${SETLOCALE}" == "l" ]]; then
more /usr/share/i18n/SUPPORTED
return 1
elif ! grep -q "^#\?$(sed 's/[].*[]/\\&/g' <<< "${SETLOCALE}") " /usr/share/i18n/SUPPORTED; then
invalid
return 1
else
sleep 0.3
YELLOW "
### '${SETLOCALE}' Locale has been selected
"
fi
ok
}
###########################################################################################
slct_kbd (){
local prompt="Keyboard Layout"
sleep 0.3
NC "
_________________________________
${purple}###${nc} Keyboard Layout Selection ${purple}###${nc}
"
YELLOW "
> Select your Keyboard Layout
### [Hit ${nc}'l'${yellow} to list layouts, then ${nc}'enter'${yellow} to search or ${nc}'q'${yellow} to quit] "
BLUE "
Enter your keyboard layout ${bwhite}(empty for '${cyan}us${bwhite}')${blue}: "
read -r -p "
==> " SETKBD
if [[ -z "${SETKBD}" ]]; then
SETKBD="us"
sleep 0.3
YELLOW "
### 'us' Keyboard Layout has been selected
"
elif [[ "${SETKBD}" == "l" ]]; then
localectl list-keymaps | more
return 1
elif ! localectl list-keymaps | grep -Fxq "${SETKBD}"; then
invalid
return 1
else
sleep 0.3
YELLOW "
### '${SETKBD}' Keyboard Layout has been selected
"
loadkeys "${SETKBD}" > /dev/null 2>&1
fi
ok
}
###########################################################################################
user_setup (){
local prompt="User"
sleep 0.3
NC "
__________________
${purple}###${nc} User Setup ${purple}###${nc}
"
BLUE "
Enter a username: "
read -r -p "
==> " USERNAME
echo
if [[ -z "${USERNAME}" ]]; then
sleep 0.3
RED "
[!] Please enter a username to continue "
reload
return 1
elif [[ "${USERNAME}" =~ [[:upper:]] ]]; then
sleep 0.3
RED "
[!] Uppercase is not allowed. Please try again.. "
reload
return 1
fi
BLUE "
Enter a password for${nc} ${cyan}${USERNAME}${blue}: "
read -r -p "
==> " USERPASSWD
echo
if [[ -z "${USERPASSWD}" ]]; then
sleep 0.3
RED "
[!] Please enter a password for ${USERNAME} to continue "
reload
return 1
fi
BLUE "
Re-enter${nc} ${cyan}${USERNAME}'s ${blue}password: "
read -r -p "
==> " USERPASSWD2
echo
if [[ "${USERPASSWD}" != "${USERPASSWD2}" ]]; then
sleep 0.3
RED "
[!] Passwords don't match. Please try again.. "
reload
return 1
fi
ok
}
###########################################################################################
rootuser_setup (){
local prompt="Root User"
sleep 0.3
NC "
_______________________
${purple}###${nc} Root User Setup ${purple}###${nc}
"
BLUE "
Enter a password for the${nc}${cyan} Root ${blue}user: "
read -r -p "
==> " ROOTPASSWD
if [[ -z "${ROOTPASSWD}" ]]; then
sleep 0.3
RED "
[!] Please enter a password for the Root user to continue "
reload
return 1
fi
BLUE "
Re-enter${nc} ${cyan}Root ${blue}user's password: "
read -r -p "
==> " ROOTPASSWD2
echo
if [[ "${ROOTPASSWD}" != "${ROOTPASSWD2}" ]]; then
sleep 0.3
RED "
[!] Passwords don't match. Please try again.. "
reload
return 1
fi
ok
}
###########################################################################################
slct_hostname (){
local prompt="Hostname"
sleep 0.3
NC "
______________________
${purple}###${nc} Hostname Setup ${purple}###${nc}
"
BLUE "
Enter a hostname: "
read -r -p "
==> " HOSTNAME
echo
if [[ -z "${HOSTNAME}" ]]; then
sleep 0.3
RED "
[!] Please enter a hostname to continue "
reload
return 1
elif [[ "${HOSTNAME}" =~ [[:upper:]] ]]; then
sleep 0.3
RED "
[!] Lowercase is preferred. Please try again.. "
reload
return 1
fi
ok
}
###########################################################################################
sys_submn (){
sleep 0.3
NC "
____________________________
${purple}###${nc} System Configuration ${purple}###${nc}
"
YELLOW "
> Select a Submenu: "
NC "
[1] Kernel & Bootloader Setup
[2] Filesystem & Swap Setup
[3] Graphics Setup
[4] Desktop Setup
[5] EFI Boot Entries Deletion
[6] Wireless Regulatory Domain Setup
[ ] Return to Main Menu "
BLUE "
Enter a number: "
read -r -p "
==> " sysmenu
case "${sysmenu}" in
1)
until slct_krnl; do : ; done
until ask_bootldr; do : ; done
return 1 ;;
2)
until ask_fs; do : ; done
until ask_swap; do : ; done
return 1 ;;
3)
until dtct_vga; do : ; done
return 1 ;;
4)
until slct_dsktp; do : ; done
return 1 ;;
5)
until boot_entr; do : ; done
return 1 ;;
6)
until wireless_rgd; do : ; done
return 1 ;;
"")
until main_menu; do : ; done ;;
*)
invalid
return 1 ;;
esac
}
###########################################################################################
slct_krnl (){
local prompt="Kernel"
sleep 0.3
NC "
________________________
${purple}###${nc} Kernel Selection ${purple}###${nc}
"
YELLOW "
> Select a Kernel: "
NC "
[1] Linux
[2] Linux LTS
[3] Linux Hardened
[4] Linux Zen "
BLUE "
Enter a number: "
read -r -p "
==> " kernelnmbr
case "${kernelnmbr}" in
1)
kernel="linux"
kernelname="Linux"
entrname="Arch Linux" ;;
2)
kernel="linux-lts"
kernelname="Linux LTS"
entrname="Arch Linux LTS" ;;
3)
kernel="linux-hardened"
kernelname="Linux Hardened"
entrname="Arch Linux Hardened" ;;
4)
kernel="linux-zen"
kernelname="Linux Zen"
entrname="Arch Linux Zen" ;;
"")
sleep 0.3
RED "
[!] Please select a Kernel "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
sleep 0.3
YELLOW "
### The ${kernelname} kernel has been selected
"
if [[ "${kernelnmbr}" == "3" ]]; then
CYAN "
[!] Swapping is not supported
"
fi
ok
}
###########################################################################################
ask_bootldr (){
local prompt="Bootloader"
sleep 0.3
NC "
____________________________
${purple}###${nc} Bootloader Selection ${purple}###${nc}
"
YELLOW "
> Select a Bootloader: "
NC "
[1] Systemd-boot
[2] Grub "
BLUE "
Enter a number: "
read -r -p "
==> " bootloader
case "${bootloader}" in
1)
sleep 0.3
YELLOW "
### Systemd-boot has been selected
" ;;
2)
sleep 0.3
YELLOW "
### Grub has been selected
" ;;
"")
sleep 0.3
RED "
[!] Please select a Bootloader "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
ok
}
###########################################################################################
ask_fs (){
local prompt="Filesystem Setup"
sleep 0.3
NC "
____________________________
${purple}###${nc} Filesystem Selection ${purple}###${nc}
"
YELLOW "
> Select Filesystem to be used: "
NC "
[1] Ext4
[2] Btrfs "
BLUE "
Enter a number: "
read -r -p "
==> " fs
echo
case "${fs}" in
1)
fsname="Ext4"
fs_mod="ext4"
fstools="e2fsprogs"
roottype="/ROOT"
sleep 0.3
YELLOW "
### ${fsname} has been selected
" ;;
2)
fsname="Btrfs"
fs_mod="btrfs"
fstools="btrfs-progs"
roottype="/@"
btrfs_bootopts="rootflags=subvol=@ "
sleep 0.3
YELLOW "
### ${fsname} has been selected
"
sleep 0.3
YELLOW "
> Label your Btrfs snapshot directory: "
BLUE "
Enter a name: "
read -r -p "
==> " snapname
if [[ -z "${snapname}" ]]; then
invalid
return 1
fi ;;
"")
sleep 0.3
RED "
[!] Please select a Filesystem "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
ok
}
###########################################################################################
ask_swap (){
local prompt="Swap Setup"
sleep 0.3
NC "
______________________
${purple}###${nc} Swap Selection ${purple}###${nc}
"
YELLOW "
> Select Swap type: "
NC "
[1] Swap Partition
[2] Swapfile
[3] None "
BLUE "
Enter a number: "
read -r -p "
==> " swapmode
case "${swapmode}" in
1)
swaptype="swappart"
sleep 0.3
YELLOW "
### Swap Partition has been selected
" ;;
2)
if [[ "${fs}" == "1" ]]; then
swaptype="swapfile"
elif [[ "${fs}" == "2" ]]; then
swaptype="swapfile_btrfs"
fi
sleep 0.3
YELLOW "
### Swapfile has been selected
"
until set_swapsize; do : ; done ;;
3)
sleep 0.3
YELLOW "
### No Swap will be used
"
skip ;;
"")
sleep 0.3
RED "
[!] Please make a selection to continue "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
ok
}
###########################################################################################
set_swapsize (){
local prompt="Swapsize"
BLUE "
Enter Swapfile size ${bwhite}(in GiB)${blue}: "
read -r -p "
==> " swapsize
echo
if [[ -z "${swapsize}" ]]; then
sleep 0.3
RED "
[!] Please enter a value to continue "
reload
NC "
"
return 1
elif [[ "${swapsize}" =~ [[:digit:]] ]]; then
ok
else
sleep 0.3
RED "
[!] Please use only digits as a value "
reload
NC "
"
return 1
fi
}
###########################################################################################
dtct_vga (){
local prompt="Graphics"
sleep 0.3
NC "
______________________
${purple}###${nc} Graphics Setup ${purple}###${nc}
"
vgacount="$(lspci | grep -E -c 'VGA|Display|3D')"
vgacard="$(lspci | grep -E 'VGA|Display|3D' | sed 's/^.*: //g')"
intelcount="$(lspci | grep -E 'VGA|Display|3D' | grep -E -c 'Intel Corporation')"
intelcards="$(lspci | grep -E 'VGA|Display|3D' | grep -E 'Intel Corporation'| sed 's/.*Corporation //g' | cat --number | sed 's/.[0-9]//')"
amdcount="$(lspci | grep -E 'VGA|Display|3D' | grep -E -c 'Advanced Micro Devices')"
amdcards="$(lspci | grep -E 'VGA|Display|3D' | grep -E 'Advanced Micro Devices' | sed 's/.*\[AMD\/ATI\] //g' | cat --number | sed 's/.[0-9]//')"
nvidiacount="$(lspci | grep -E 'VGA|Display|3D' | grep -E -c 'NVIDIA Corporation')"
nvidiacards="$(lspci | grep -E 'VGA|Display|3D' | grep -E 'NVIDIA Corporation'| sed 's/.*Corporation //g' | cat --number | sed 's/.[0-9]//')"
hypervisor="$(systemd-detect-virt)"
if [[ "${vgacount}" == "1" ]]; then
if [[ "${intelcount}" -ge "1" ]]; then
vendor="Intel"
sourcetype="Open-source"
perf_stream="dev.i915.perf_stream_paranoid = 0"
vgapkgs="intel-media-driver intel-media-sdk libva-intel-driver vpl-gpu-rt vulkan-intel vulkan-mesa-layers"
elif [[ "${amdcount}" -ge "1" ]]; then
vendor="AMD"
sourcetype="Open-source"
vgapkgs="libva-mesa-driver mesa-vdpau vulkan-mesa-layers vulkan-radeon"
elif [[ "${nvidiacount}" -ge "1" ]]; then
vendor="Nvidia"
sourcetype="Proprietary"
elif [[ "${hypervisor}" != "none" ]]; then
vendor="Virtual Machine"
case "${hypervisor}" in
kvm)
vmpkgs="spice spice-vdagent spice-protocol spice-gtk qemu-guest-agent"
vm_services="qemu-guest-agent" ;;
vmware)
vmpkgs="open-vm-tools"
vm_services="vmtoolsd vmware-vmblock-fuse" ;;
oracle)
vmpkgs="virtualbox-guest-utils"
vm_services="vboxservice" ;;
microsoft)
vmpkgs="hyperv"
vm_services="hv_fcopy_daemon hv_kvp_daemon hv_vss_daemon" ;;
esac
fi
sleep 0.3
YELLOW "
### ${vendor} Graphics detected : ${nc}${vgacard}"
if [[ "${vendor}" == "Virtual Machine" ]]; then
vgaconf="n"
echo
skip
ok
return 0
fi
YELLOW "
### ${sourcetype} drivers will be used
> Enable HW acceleration and auto-configure the graphics subsystem ? [y/n]
"
if [[ "${vendor}" == "Nvidia" ]]; then
RED "
[!] Supported architectures: NV110 (Maxwell) Graphics or newer "
fi
BLUE "
Enter [y/n]: "
read -r -p "
==> " vgaconf
if [[ "${vgaconf}" == "y" ]]; then
if [[ "${vendor}" == "AMD" ]]; then
sleep 0.3
YELLOW "
> Enable 'amdgpu' driver support for: "
NC "
[1] 'Southern Islands' Graphics
[2] 'Sea Islands' Graphics "
BLUE "
Enter a number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " islands
if [[ -z "${islands}" ]]; then
skip
echo
elif [[ "${islands}" == "1" ]]; then
NC "
==> [${green}Southern Islands OK${nc}]
"
elif [[ "${islands}" == "2" ]]; then
NC "
==> [${green}Sea Islands OK${nc}]
"
else
invalid
return 1
fi
elif [[ "${vendor}" == "Nvidia" ]]; then
sleep 0.3
YELLOW "
> Select Nvidia architecture: "
NC "
[1] NV110 (Maxwell) Graphics or newer
[2] NV160 (Turing) Graphics or newer "
BLUE "
Enter a number: "
read -r -p "
==> " family
if [[ "${family}" == "1" ]]; then
NC "
==> [${green}Maxwell+ OK${nc}]
"
elif [[ "${family}" == "2" ]]; then
sleep 0.3
YELLOW "
> Select Nvidia driver: "
NC "
[1] 'Nvidia-Open' driver
[2] 'Nvidia' driver "
BLUE "
Enter a number: "
read -r -p "
==> " nvdriver
if [[ "${nvdriver}" == "1" ]]; then
NC "
==> [${green}Turing+ OK${nc}]
"
elif [[ "${nvdriver}" == "2" ]]; then
NC "
==> [${green}Turing+ OK${nc}]
"
else
echo
invalid
return 1
fi
else
echo
invalid
return 1
fi
if [[ "${kernelnmbr}" == "1" ]]; then
if [[ "${family}" == "1" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia nvidia-settings nvidia-utils opencl-nvidia"
nvname="nvidia"
elif [[ "${family}" == "2" ]]; then
if [[ "${nvdriver}" == "1" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-open nvidia-settings nvidia-utils opencl-nvidia"
nvname="nvidia-open"
elif [[ "${nvdriver}" == "2" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia nvidia-settings nvidia-utils opencl-nvidia"
nvname="nvidia"
fi
fi
elif [[ "${kernelnmbr}" == "2" ]]; then
if [[ "${family}" == "1" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-lts nvidia-settings nvidia-utils opencl-nvidia"
nvname="nvidia-lts"
elif [[ "${family}" == "2" ]]; then
if [[ "${nvdriver}" == "1" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-open-dkms nvidia-settings nvidia-utils opencl-nvidia"
elif [[ "${nvdriver}" == "2" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-lts nvidia-settings nvidia-utils opencl-nvidia"
nvname="nvidia-lts"
fi
fi
else
if [[ "${family}" == "1" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-dkms nvidia-settings nvidia-utils opencl-nvidia"
elif [[ "${family}" == "2" ]]; then
if [[ "${nvdriver}" == "1" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-open-dkms nvidia-settings nvidia-utils opencl-nvidia"
elif [[ "${nvdriver}" == "2" ]]; then
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-dkms nvidia-settings nvidia-utils opencl-nvidia"
fi
fi
fi
fi
sleep 0.3
YELLOW "
### ${vendor} Graphics will be automatically configured
"
elif [[ "${vgaconf}" == "n" ]]; then
vgapkgs=""
echo
skip
else
invalid
return 1
fi
else
if [[ "${vgacount}" == "2" ]]; then
vendor="Dual"
elif [[ "${vgacount}" == "3" ]]; then
vendor="Triple"
fi
sleep 0.3
YELLOW "
### ${vendor} Graphics setup detected, consisting of: "
NC "
_______________________________"
if [[ "${intelcount}" -ge "1" ]]; then
perf_stream="dev.i915.perf_stream_paranoid = 0"
NC "
[${intelcount}] Intel Graphics device(s)
${intelcards}
_______________________________"
fi
if [[ "${amdcount}" -ge "1" ]]; then
NC "
[${amdcount}] AMD Graphics device(s)
${amdcards}
_______________________________"
fi
if [[ "${nvidiacount}" -ge "1" ]]; then
NC "
[${nvidiacount}] Nvidia Graphics device(s)
${nvidiacards}
_______________________________"
fi
YELLOW "
> Please configure the graphics subsystem after installation has finished
"
vgaconf="n"
echo
skip
ok
return 0
fi
ok
}
###########################################################################################
slct_dsktp (){
local prompt="Desktop Setup"
custompkgs=""
sleep 0.3
NC "
_____________________
${purple}###${nc} Desktop Setup ${purple}###${nc}
"
YELLOW "
> Make a selection: "
NC "
[1] Plasma
[2] Custom Plasma & Systemd-boot & System Optimizations
[3] Gnome
[4] Custom Gnome & Systemd-boot & System Optimizations
[5] Xfce
[6] Cinnamon
[7] Deepin
[8] Budgie
[9] Lxqt
[10] Mate
[11] Basic Arch Linux (No GUI)
[12] Custom Arch Linux ${red}[!] EXPERTS ONLY [!] ${nc}"
BLUE "
Enter a number: "
read -r -p "
==> " packages
case "${packages}" in
1)
desktopname="Plasma" ;;
2)
desktopname="Custom Plasma (System Optimized)" ;;
3)
desktopname="Gnome" ;;
4)
desktopname="Custom Gnome (System Optimized)" ;;
5)
desktopname="Xfce" ;;
6)
desktopname="Cinnamon"
sleep 0.3
YELLOW "
### NOTE: Cinnamon desktop lacks a native Terminal emulator by design
### You can use linux console (ctrl+alt+F3) for shell access
> Install 'gnome-terminal' for convenience ? [y/n] "
BLUE "
Enter [y/n]: "
read -r -p "
==> " console
case "${console}" in
y)
terminal="gnome-terminal"
sleep 0.3
NC "
==> [${green}Terminal OK${nc}] " ;;
n)
echo
skip ;;
"")
sleep 0.3
echo
RED "
[!] Please type 'y' or 'n' to continue "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac ;;
7)
desktopname="Deepin" ;;
8)
desktopname="Budgie"
sleep 0.3
YELLOW "
### NOTE: Budgie desktop lacks a native Terminal emulator by design
### You can use linux console (ctrl+alt+F3) for shell access
> Install 'gnome-terminal' for convenience ? [y/n] "
BLUE "
Enter [y/n]: "
read -r -p "
==> " console
case "${console}" in
y)
terminal="gnome-terminal"
sleep 0.3
NC "
==> [${green}Terminal OK${nc}] " ;;
n)
echo
skip ;;
"")
sleep 0.3
echo
RED "
[!] Please type 'y' or 'n' to continue "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac ;;
9)
desktopname="Lxqt" ;;
10)
desktopname="Mate" ;;
11)
desktopname="Basic Arch Linux" ;;
12)
desktopname="Custom Arch Linux"
until cust_sys; do :; done
return 0 ;;
"")
sleep 0.3
RED "
[!] Please make a selection.. "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
sleep 0.3
YELLOW "
### ${desktopname} has been selected
### NOTE: 'base' meta-package does not include the tools needed for building packages
> Install 'base-devel' meta-package ? [y/n] "
BLUE "
Enter [y/n]: "
read -r -p "
==> " dev
case "${dev}" in
y)
devel="base-devel"
sleep 0.3
NC "
==> [${green}base-devel OK${nc}] " ;;
n)
echo
skip ;;
"")
sleep 0.3
echo
RED "
[!] Please type 'y' or 'n' to continue "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
sleep 0.3
YELLOW "
### NOTE: Custom Kernel Parameters can be set at boot time
> Enter your own Kernel Parameters ? [y/n] "
BLUE "
Enter [y/n]: "
read -r -p "
==> " ask_param
case "${ask_param}" in
y)
add_prmtrs ;;
n)
echo
skip ;;
"")
sleep 0.3
echo
RED "
[!] Please type 'y' or 'n' to continue "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
ok
}
###########################################################################################
cust_sys (){
local prompt="Custom Arch Linux"
until add_pkgs; do : ; done
until add_services; do : ; done
until add_prmtrs; do : ; done
ok
}
###########################################################################################
add_pkgs (){
local prompt="Add Packages"
sleep 0.3
NC "
_________________________
${purple}###${nc} Add Your Packages ${purple}###${nc}
"
YELLOW "
### base, linux-firmware (if on bare-metal), sudo & your current choices are already included "
BLUE "
Enter any additional packages ${bwhite}(space-seperated)${blue}: "
read -r -p "
==> " custompkgs
if [[ -z "${custompkgs}" ]]; then
sleep 0.3
RED "
[!] Please enter package(s) to continue "
reload
return 1
elif [[ "${custompkgs}" =~ "lightdm" ]]; then
echo
sleep 0.3
NC "
_________________________________
${purple}###${nc} Lightdm Greeter Selection ${purple}###${nc}
"
YELLOW "
> Select a Greeter: "
NC "
[1] Gtk
[2] Slick "
BLUE "
Enter a number: "
read -r -p "
==> " greeternmbr
case "${greeternmbr}" in
1)
greeter="lightdm-gtk-greeter"
sleep 0.3
NC "
==> [${green}Lightdm Gtk Greeter OK${nc}] " ;;
2)
greeter="lightdm-slick-greeter"
sleep 0.3
NC "
==> [${green}Lightdm Slick Greeter OK${nc}] " ;;
"")
sleep 0.3
echo
RED "
[!] Please make a selection.. "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
else
ok
fi
}
###########################################################################################
add_services (){
local prompt="Add Services"
sleep 0.3
NC "
_________________________
${purple}###${nc} Add Your Services ${purple}###${nc}
"
YELLOW "
### Empty to skip "
BLUE "
Enter services to be enabled ${bwhite}(space-seperated)${blue}: "
read -r -p "
==> " customservices
if [[ -z "${customservices}" ]]; then
echo
skip
else
ok
fi
}
###########################################################################################
add_prmtrs (){
local prompt="Kernel Parameters"
sleep 0.3
NC "
__________________________________
${purple}###${nc} Add Your Kernel Parameters ${purple}###${nc}
"
YELLOW "
### Empty to skip "
BLUE "
Enter your Kernel parameters to be set at boot ${bwhite}(space-seperated)${blue}: "
read -r -p "
==> " cust_bootopts
if [[ -z "${cust_bootopts}" ]]; then
echo
skip
else
ok
fi
}
###########################################################################################
boot_entr (){
local prompt="Boot Entries"
efi_entr_del="1"
hypervisor="$(systemd-detect-virt)"
sleep 0.3
NC "
_________________________________
${purple}###${nc} EFI Boot Entries Deletion ${purple}###${nc}
"
if [[ "${hypervisor}" != "none" ]]; then
sleep 0.3
YELLOW "
### Virtual Machine detected
"
skip
ok
echo
return 0
fi
YELLOW "
> Select an EFI Boot Entry to Delete ${red}[!] (CAUTION) [!]${yellow}
"
sleep 0.3
efibootmgr
boot_entry=" "
while [[ -n "${boot_entry}" ]]; do
BLUE "
Enter a${nc} ${cyan}BootOrder${blue} number for Deletion ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " boot_entry
echo
if [[ -n "${boot_entry}" ]]; then
if [[ "${run_as}" != "root" ]]; then
sleep 0.3
RED "
[!] Root Privileges Missing.. "
reload
until sys_submn; do : ; done
fi
if efibootmgr -b "${boot_entry}" -B; then
sleep 0.3
NC "
==> [${green}Entry ${boot_entry} Deleted${nc}] "
else
err_try
return 1
fi
else
skip
ok
fi
done
}
###########################################################################################
wireless_rgd (){
local prompt="Wireless Regdom Setup"
wrlss_rgd="1"
hypervisor="$(systemd-detect-virt)"
sleep 0.3
NC "
________________________________________
${purple}###${nc} Wireless Regulatory Domain Setup ${purple}###${nc}
"
if [[ "${hypervisor}" != "none" ]]; then
sleep 0.3
YELLOW "
### Virtual Machine detected
"
skip
ok
echo
return 0
fi
BLUE "
Enter your Country Code, ie:${nc} ${cyan}US ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " REGDOM
if [[ -z "${REGDOM}" ]]; then
echo
skip
elif [[ "${REGDOM}" =~ [[:lower:]] ]]; then
sleep 0.3
RED "
[!] Lowercase is not allowed. Please try again.. "
reload
return 1
elif ! [[ "${REGDOM}" =~ ^(00|AD|AE|AF|AI|AL|AM|AN|AR|AS|AT|AU|AW|AZ|BA|BB|BD|BE|BF|BG|BH|BL|BM|BN|BO|BR|BS|BT|BY|BZ|CA|CF|CH|CI|CL|CN|CO|CR|CU|CX|CY|CZ|DE|DK|DM|DO|DZ|EC|EE|EG|ES|ET|FI|FM|FR|GB|GD|GE|GF|GH|GL|GP|GR|GT|GU|GY|HK|HN|HR|HT|HU|ID|IE|IL|IN|IR|IS|IT|JM|JO|JP|KE|KH|KN|KP|KR|KW|KY|KZ|LB|LC|LI|LK|LS|LT|LU|LV|MA|MC|MD|MF|MH|MK|MN|MO|MP|MQ|MR|MT|MU|MV|MW|MX|MY|NG|NI|NL|NO|NP|NZ|OM|PA|PE|PF|PG|PH|PK|PL|PM|PR|PT|PY|PY|QA|RE|RO|RS|RU|RW|SA|SE|SG|SI|SK|SN|SR|SV|SY|TC|TD|TG|TH|TN|TR|TT|TW|TZ|UA|UG|US|UY|UZ|VC|VE|VI|VN|VU|WF|WS|YE|YT|ZA|ZW)$ ]]; then
invalid
return 1
else
wireless_reg="wireless-regdb"
sleep 0.3
YELLOW "
### '${REGDOM}' Country Code has been selected
"
fi
ok
}
###########################################################################################
dsks_submn (){
sleep 0.3
NC "
_______________________
${purple}###${nc} Disk Management ${purple}###${nc}
"
YELLOW "
> Select a Submenu: "
NC "
[1] Disk GPT Manager
[2] Partition Manager
[3] Installation Disk & Encryption
[ ] Return to Main Menu "
BLUE "
Enter a number: "
read -r -p "
==> " diskmenu
case ${diskmenu} in
1)
until gpt_mngr; do : ; done ;;
2)
until disk_mngr; do : ; done ;;
3)
until instl_dsk; do : ; done
if [[ -z "${fs}" ]]; then
sleep 0.3
RED "
[!] Please complete 'Filesystem Setup' to continue
"
until ask_fs; do : ; done
fi
until ask_crypt; do : ; done
return 1 ;;
"")
until main_menu; do : ; done ;;
*)
invalid
return 1 ;;
esac
}
###########################################################################################
gpt_mngr (){
local prompt="Disk GPT"
sleep 0.3
NC "
________________________
${purple}###${nc} Disk GPT Manager ${purple}###${nc}
"
gpt_dsk_nmbr=" "
while [[ -n "${gpt_dsk_nmbr}" ]]; do
YELLOW "
> Select a disk to manage its GPT: "
NC "
${disks} "
BLUE "
Enter a disk number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " gpt_dsk_nmbr
if [[ -n "${gpt_dsk_nmbr}" ]]; then
gptdrive="$(echo "${disks}" | awk "\$1 == ${gpt_dsk_nmbr} { print \$2}")"
if [[ -e "${gptdrive}" ]]; then
if [[ "${run_as}" != "root" ]]; then
sleep 0.3
RED "
[!] Root Privileges Missing.. "
reload
until dsks_submn; do : ; done
fi
NC "
______________________________________________
"
gdisk "${gptdrive}"
sleep 0.3
NC "
==> [${green}${gptdrive} OK${nc}] "
else
invalid
return 1
fi
else
skip
ok
if [[ "${install}" == "yes" ]]; then
until instl_dsk; do : ; done
else
until dsks_submn; do : ; done
fi
fi
done
}
###########################################################################################
disk_mngr (){
local prompt="Disks"
sleep 0.3
NC "
_________________________
${purple}###${nc} Partition Manager ${purple}###${nc}
"
cgdsk_nmbr=" "
while [[ -n "${cgdsk_nmbr}" ]]; do
NC "
- - - - - - - - - - - - - - - - - -
Discoverable Partitions GUID Codes:
${cyan}EFI${nc} system partition > ${cyan}ef00${nc}
Linux x86-64 ${cyan}root (/)${nc} > ${cyan}8304${nc}
Linux ${cyan}/home${nc} > ${cyan}8302${nc}
Linux ${cyan}swap${nc} > ${cyan}8200${nc}
- - - - - - - - - - - - - - - - - -
"
YELLOW "
> Select a disk to Manage: "
NC "
${disks}"
BLUE "
Enter a disk number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " cgdsk_nmbr
if [[ -n "${cgdsk_nmbr}" ]]; then
drive="$(echo "${disks}" | awk "\$1 == ${cgdsk_nmbr} {print \$2}")"
if [[ -e "${drive}" ]]; then
if [[ "${run_as}" != "root" ]]; then
sleep 0.3
RED "
[!] Root Privileges Missing.. "
reload
until dsks_submn; do : ; done
fi
cgdisk "${drive}"
clear
sleep 0.3
NC "
==> [${green}Disk ${drive} OK${nc}] "
return 1
else
invalid
return 1
fi
else
skip
ok
if [[ -z "${sanity}" ]]; then
until dsks_submn; do : ; done
elif [[ "${sanity}" == "no" ]]; then
until instl_dsk; do : ; done
elif [[ "${revision}" == "yes" ]]; then
return 0
elif [[ "${sanity}" == "ok" ]]; then
if [[ "${install}" == "yes" ]]; then
return 0
fi
until dsks_submn; do : ; done
fi
fi
done
}
###########################################################################################
instl_dsk (){
sleep 0.3
NC "
___________________________________
${purple}###${nc} Installation Disk Selection ${purple}###${nc}
"
YELLOW "
> Select a disk to Install to: "
NC "
${disks} "
BLUE "
Enter a disk number: "
read -r -p "
==> " instl_dsk_nmbr
echo
if [[ -n "${instl_dsk_nmbr}" ]]; then
instl_drive="$(echo "${disks}" | awk "\$1 == ${instl_dsk_nmbr} {print \$2}")"
if [[ -e "${instl_drive}" ]]; then
if [[ "${run_as}" != "root" ]]; then
sleep 0.3
RED "
[!] Root Privileges Missing.. "
reload
until dsks_submn; do : ; done
fi
volumes="$(fdisk -l | grep '^/dev' | cat --number)"
rota="$(lsblk "${instl_drive}" --nodeps --noheadings --output=rota | awk "{print \$1}")"
if [[ "${rota}" == "0" ]]; then
sbvl_mnt_opts="rw,noatime,compress=zstd:1"
trim="fstrim.timer"
else
sbvl_mnt_opts="rw,compress=zstd"
fi
parttable="$(fdisk -l "${instl_drive}" | grep '^Disklabel type' | awk "{print \$3}")"
if [[ "${parttable}" != "gpt" ]]; then
sleep 0.3
RED "
[!] No GPT found on selected disk "
reload
until gpt_mngr; do : ; done
return 0
fi
until sanity_check; do : ; done
else
invalid
return 1
fi
else
choice
return 1
fi
}
###########################################################################################
sanity_check (){
local prompt="Installation Disk"
sleep 0.3
NC "
____________________
${purple}###${nc} Sanity Check ${purple}###${nc}
"
root_dev="$(fdisk -l "${instl_drive}" | grep 'root' | awk "{print \$1}")"
boot_dev="$(fdisk -l "${instl_drive}" | grep 'EFI' | awk "{print \$1}")"
home_dev="$(fdisk -l "${instl_drive}" | grep 'home' | awk "{print \$1}")"
swap_dev="$(fdisk -l "${instl_drive}" | grep 'swap' | awk "{print \$1}")"
if [[ ! -e "${root_dev}" && ! -e "${boot_dev}" ]]; then
sanity="no"
sleep 0.3
RED "
[!] Linux x86-64 Root (/) Partition not detected "
sleep 0.3
RED "
[!] EFI System Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that a Linux x86-64 Root (/) Partition with a valid GUID code ${nc}(8304)${yellow} is present on disk
### Ensure that an EFI System Partition with a valid GUID code ${nc}(ef00)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
elif [[ ! -e "${root_dev}" && -e "${boot_dev}" ]]; then
sanity="no"
sleep 0.3
NC "
==> [EFI System Partition ${green}OK${nc}] "
sleep 0.3
RED "
[!] Linux x86-64 Root (/) Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that a Linux x86-64 Root (/) Partition with a valid GUID code ${nc}(8304)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
elif [[ -e "${root_dev}" && ! -e "${boot_dev}" ]]; then
sanity="no"
sleep 0.3
NC "
==> [Linux x86-64 Root (/) ${green}OK${nc}] "
sleep 0.3
RED "
[!] EFI Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that an EFI System Partition with a valid GUID code ${nc}(ef00)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
elif [[ -e "${root_dev}" && -e "${boot_dev}" ]]; then
sleep 0.3
NC "
==> [Linux x86-64 Root (/) ${green}OK${nc}] "
sleep 0.3
NC "
==> [EFI System Partition ${green}OK${nc}] "
if [[ -e "${home_dev}" ]]; then
sleep 0.3
NC "
==> [Linux (/Home) ${green}OK${nc}] "
fi
if [[ "${swapmode}" == "1" ]]; then
if [[ -e "${swap_dev}" ]]; then
sanity="ok"
sleep 0.3
NC "
==> [Linux Swap ${green}OK${nc}] "
else
sanity="no"
sleep 0.3
RED "
[!] Linux Swap Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that a Linux Swap Partition with a valid GUID code ${nc}(8200)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
fi
fi
sanity="ok"
fi
[[ "${sanity}" == "ok" ]] && ok
}
###########################################################################################
ask_crypt (){
local prompt="Encryption Setup"
sleep 0.3
NC "
________________________
${purple}###${nc} Encryption Setup ${purple}###${nc}
"
BLUE "
> Enable ${roottype} Encryption? [LUKS] "
NC "
* Type '${cyan}no${nc}' to proceed without encryption
* Type '${cyan}yes${nc}' to encrypt your ${roottype}
"
read -r -p "
==> " encrypt
echo
if [[ "${encrypt}" == "no" ]]; then
skip
ok
return 0
elif [[ "${encrypt}" == "yes" ]]; then
sleep 0.3
YELLOW "
> Enter a name for your Encrypted ${roottype} Partition: "
BLUE "
Enter a name: "
read -r -p "
==> " ENCROOT
echo
if [[ -z "${ENCROOT}" ]]; then
sleep 0.3
RED "
[!] Please enter a name to continue "
reload
return 1
elif [[ "${ENCROOT}" =~ [[:upper:]] ]]; then
sleep 0.3
RED "
[!] Uppercase is not allowed. Please try again.. "
reload
return 1
elif [[ -n "${ENCROOT}" ]]; then
sleep 0.3
NC "
==> [${green}Encrypted ${roottype} Label OK${nc}] "
fi
if [[ -e "${home_dev}" ]]; then
if [[ "${fs}" == "1" ]]; then
sleep 0.3
YELLOW "
### A /HOME Partition has been detected "
sleep 0.3
BLUE "
> Encrypt /HOME partition? [LUKS] "
NC "
* Type '${cyan}no${nc}' to proceed without encryption
* Type '${cyan}yes${nc}' to encrypt your /HOME
"
read -r -p "
==> " homecrypt
echo
if [[ "${homecrypt}" == "no" ]]; then
skip
ok
elif [[ "${homecrypt}" == "yes" ]]; then
sleep 0.3
YELLOW "
> Enter a name for your Encrypted Home Partition: "
BLUE "
Enter a name: "
read -r -p "
==> " ENCRHOME
echo
if [[ -z "${ENCRHOME}" ]]; then
sleep 0.3
RED "
[!] Please enter a name to continue "
reload
return 1
elif [[ "${ENCRHOME}" =~ [[:upper:]] ]]; then
sleep 0.3
RED "
[!] Uppercase is not allowed. Please try again.. "
reload
return 1
elif [[ -n "${ENCRHOME}" ]]; then
sleep 0.3
NC "
==> [${green}Encrypted /HOME Label OK${nc}] "
fi
else
sleep 0.3
RED "
[!] Please type 'yes' or 'no' to continue "
reload
return 1
fi
fi
fi
ok
else
sleep 0.3
RED "
[!] Please type 'yes' or 'no' to continue "
reload
return 1
fi
}
###########################################################################################
instl (){
install="yes"
if [[ -z "${SETLOCALE}" ]]; then
sleep 0.3
RED "
[!] Please complete 'Locale & Keyboard Layout Selection' to continue
"
until slct_locale; do : ; done
until slct_kbd; do : ; done
fi
if [[ -z "${USERNAME}" ]]; then
sleep 0.3
RED "
[!] Please complete 'User, Root User & Hostname Setup' to continue
"
until user_setup; do : ; done
until rootuser_setup; do : ; done
until slct_hostname; do : ; done
fi
if [[ -z "${kernelnmbr}" ]]; then
sleep 0.3
RED "
[!] Please complete 'Kernel & Bootloader Selection' to continue
"
until slct_krnl; do : ; done
until ask_bootldr; do : ; done
fi
if [[ -z "${fs}" ]]; then
sleep 0.3
RED "
[!] Please complete 'Filesystem & Swap Selection' to continue
"
until ask_fs; do : ; done
until ask_swap; do : ; done
fi
if [[ -z "${vgaconf}" ]]; then
sleep 0.3
RED "
[!] Please complete 'Graphics Setup' to continue
"
until dtct_vga; do : ; done
fi
if [[ -z "${packages}" ]]; then
sleep 0.3
RED "
[!] Please complete 'Desktop Setup' to continue
"
until slct_dsktp; do : ; done
fi
if [[ -z "${efi_entr_del}" ]]; then
sleep 0.3
RED "
[!] Please complete 'EFI Boot Entries Deletion' to continue
"
until boot_entr; do : ; done
fi
if [[ -z "${wrlss_rgd}" ]]; then
sleep 0.3
RED "
[!] Please complete 'Wireless Regulatory Domain Setup' to continue
"
until wireless_rgd; do : ; done
fi
if [[ "${sanity}" != "ok" ]]; then
sleep 0.3
RED "
[!] Please complete 'Installation Disk' & 'Encryption' to continue
"
until instl_dsk; do : ; done
until ask_crypt; do : ; done
fi
#------------------------------------------------------------------------------------------
if [[ "${swapmode}" == "1" ]]; then
until "${swaptype}"; do : ; done
fi
if [[ "${encrypt}" == "no" ]]; then
until set_mode; do : ; done
until confirm_status; do : ; done
elif [[ "${encrypt}" == "yes" ]]; then
until sec_erase; do : ; done
until luks; do : ; done
until opt_pcmn; do : ; done
until pacstrap_system; do : ; done
if [[ "${swapmode}" == "2" ]]; then
until "${swaptype}"; do : ; done
fi
if [[ -n "${REGDOM}" ]]; then
until wireless_regdom; do : ; done
fi
chroot_conf
fi
}
###########################################################################################
swappart (){
local prompt="Swap Partition"
sleep 0.3
NC "
____________________________
${purple}###${nc} Swap Partition Setup ${purple}###${nc}
"
if mkswap "${swap_dev}" > /dev/null 2>&1 ; then
ok
else
err_reload
until disk_mngr; do : ; done
until swappart; do : ; done
fi
}
###########################################################################################
set_mode (){
sleep 0.3
NC "
______________________
${purple}###${nc} Mode Selection ${purple}###${nc}
"
YELLOW "
> Select a Mode to continue: "
NC "
[1] Auto (Automatically Format, Label & Mount partitions)
[2] Manual (Manually Format, Label & Mount partitions) "
BLUE "
Enter a Mode number: "
read -r -p "
==> " setmode
echo
case "${setmode}" in
1)
until auto_mode; do : ; done ;;
2)
until manual_mode; do : ; done ;;
"")
RED "
[!] Please select a Mode to continue "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
sleep 0.3
NC "
-------------------------------------------------------------------------------------------------------------
==> [${green}Filesystems OK${nc}]
"
sleep 0.3
YELLOW "
###---------------------------------------[ FILESYSTEM OVERVIEW ]---------------------------------------###
"
lsblk -f |GREP_COLORS='mt=01;36' grep -E --color=always 'vfat|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'ext4|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'btrfs|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'ntfs|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'swap|$'
YELLOW "
###-------------------------------------------------------------------------------------------------------###"
echo
sleep 1
}
###########################################################################################
auto_mode (){
sleep 0.3
YELLOW "
> Auto Mode Selected
"
sleep 1
if [[ "${fs}" == "1" ]]; then
if mkfs.ext4 -F -L Root "${root_dev}" > /dev/null 2>&1 ; then
if mount "${root_dev}" /mnt; then
sleep 0.3
NC "
==> [${green}/ROOT OK${nc}]
"
else
umount_manual
until disk_mngr; do : ; done
until form_root; do : ; done
until mount_mnt; do : ; done
fi
else
umount_manual
until disk_mngr; do : ; done
until form_root; do : ; done
until mount_mnt; do : ; done
fi
#------------------------------------------------------------------------------------------
elif [[ "${fs}" == "2" ]]; then
mkfs.btrfs -f -L Root "${root_dev}" > /dev/null 2>&1 &&
mount "${root_dev}" /mnt &&
btrfs subvolume create /mnt/@ &&
btrfs subvolume create /mnt/@home &&
btrfs subvolume create /mnt/@cache &&
btrfs subvolume create /mnt/@log &&
btrfs subvolume create /mnt/@tmp &&
btrfs subvolume create /mnt/@snapshots &&
if [[ "${swapmode}" == "2" ]]; then
btrfs subvolume create /mnt/@swap
fi
if umount /mnt; then
mount -o "${sbvl_mnt_opts}",subvol=@ "${root_dev}" /mnt &&
if [[ "${swapmode}" == "2" ]]; then
mkdir -p /mnt/swap > /dev/null 2>&1 &&
mount -o rw,nodatacow,subvol=@swap "${root_dev}" /mnt/swap
fi
mkdir -p /mnt/{var/cache,home,var/log,var/tmp,"${snapname}"} > /dev/null 2>&1 &&
mount -o "${sbvl_mnt_opts}",subvol=@cache "${root_dev}" /mnt/var/cache &&
mount -o "${sbvl_mnt_opts}",subvol=@home "${root_dev}" /mnt/home &&
mount -o "${sbvl_mnt_opts}",subvol=@log "${root_dev}" /mnt/var/log &&
mount -o "${sbvl_mnt_opts}",subvol=@snapshots "${root_dev}" /mnt/"${snapname}" &&
if mount -o "${sbvl_mnt_opts}",subvol=@tmp "${root_dev}" /mnt/var/tmp; then
sleep 0.3
NC "
==> [${green}/@ OK${nc}]
"
else
umount_manual
until disk_mngr; do : ; done
until form_root; do : ; done
until mount_mnt; do : ; done
fi
else
err_abort
fi
fi
sleep 0.3
#------------------------------------------------------------------------------------------
if mkdir -pv /mnt/boot > /dev/null 2>&1 ; then
if mkfs.fat -F 32 -n Boot "${boot_dev}" > /dev/null 2>&1 ; then
if mount "${boot_dev}" /mnt/boot; then
sleep 0.3
NC "
==> [${green}/BOOT OK${nc}]
"
else
umount_manual
until disk_mngr; do : ; done
until form_efi; do : ; done
until mount_mnt; do : ; done
until mount_boot; do : ; done
fi
else
umount_manual
until disk_mngr; do : ; done
until form_efi; do : ; done
until mount_mnt; do : ; done
until mount_boot; do : ; done
fi
else
sleep 0.3
RED "
[!] Failed creating /mnt/boot directory "
abort
fi
sleep 0.3
#------------------------------------------------------------------------------------------
if [[ -e "${home_dev}" && "${fs}" == "1" ]]; then
BLUE "
> A /Home partition has been detected. Format as ${fsname}? [y/n]
"
read -r -p "
==> " homeform
if [[ "${homeform}" == "y" ]]; then
if mkdir -pv /mnt/home > /dev/null 2>&1 ; then
if mkfs.ext4 -F -L Home "${home_dev}" > /dev/null 2>&1 ; then
if mount "${home_dev}" /mnt/home; then
sleep 0.3
NC "
==> [${green}/HOME OK${nc}]
"
else
umount_manual
until disk_mngr; do : ; done
until form_home; do : ; done
until mount_mnt; do : ; done
until mount_boot; do : ; done
until mount_home; do : ; done
fi
else
umount_manual
until disk_mngr; do : ; done
until form_home; do : ; done
until mount_mnt; do : ; done
until mount_boot; do : ; done
until mount_home; do : ; done
fi
else
sleep 0.3
RED "
[!] Failed creating /mnt/home directory "
abort
fi
elif [[ "${homeform}" == "n" ]]; then
skip
else
invalid
ask_homepart_form
fi
fi
}
###########################################################################################
manual_mode (){
if [[ -e "${home_dev}" ]]; then
if [[ "${fs}" == "1" ]]; then
until form_efi; do : ; done
until form_root; do : ; done
until form_home; do : ; done
until mount_mnt; do : ; done
mkdir -pv /mnt/{boot,home} > /dev/null 2>&1
until mount_boot; do : ; done
until mount_home; do : ; done
elif [[ "${fs}" == "2" ]]; then
until form_efi; do : ; done
until form_root; do : ; done
until mount_mnt; do : ; done
mkdir -pv /mnt/boot > /dev/null 2>&1
until mount_boot; do : ; done
fi
else
until form_efi; do : ; done
until form_root; do : ; done
until mount_mnt; do : ; done
mkdir -pv /mnt/boot > /dev/null 2>&1
until mount_boot; do : ; done
fi
}
###########################################################################################
form_efi (){
sleep 0.3
NC "
_____________________________
${purple}###${nc} Format Boot Partition ${purple}###${nc}
"
form_boot_nmbr=" "
while [[ -n "${form_boot_nmbr}" ]]; do
YELLOW "
> Select a partition to format as EFI [/BOOT] "
NC "
${volumes} "
BLUE "
Enter a partition number ${bwhite}(empty to skip and proceed)${blue}: "
read -r -p "
==> " form_boot_nmbr
if [[ -n "${form_boot_nmbr}" ]]; then
bootpart="$(echo "${volumes}" | awk "\$1 == ${form_boot_nmbr} { print \$2}")"
if [[ -e "${bootpart}" ]]; then
if mkfs.fat -F 32 -n Boot "${bootpart}" > /dev/null 2>&1 ; then
sleep 0.3
NC "
==> [${green}Format & Label /BOOT OK${nc}] "
return 0
else
umount_abort
until disk_mngr; do : ; done
until form_efi; do : ; done
return 0
fi
else
invalid
return 1
fi
fi
RED "
[!] Warning: Partition NOT Formatted !
"
skip
done
}
###########################################################################################
form_root (){
sleep 0.3
NC "
_____________________________
${purple}###${nc} Format Root Partition ${purple}###${nc}
"
form_root_nmbr=" "
while [[ -n "${form_root_nmbr}" ]]; do
YELLOW "
> Select a partition to format as ${fsname} [${roottype}] "
NC "
${volumes} "
BLUE "
Enter a partition number ${bwhite}(empty to skip and proceed)${blue}: "
read -r -p "
==> " form_root_nmbr
if [[ -n "${form_root_nmbr}" ]]; then
rootpart="$(echo "${volumes}" | awk "\$1 == ${form_root_nmbr} { print \$2}")"
if [[ -e "${rootpart}" ]]; then
#------------------------------------------------------------------------------------------
if [[ "${fs}" == "1" ]]; then
if mkfs.ext4 -F "${rootpart}" > /dev/null 2>&1 ; then
sleep 0.3
NC "
==> [${green}Format ${roottype} OK${nc}] "
else
umount_abort
until disk_mngr; do : ; done
until form_root; do : ; done
return 0
fi
#------------------------------------------------------------------------------------------
elif [[ "${fs}" == "2" ]]; then
if mkfs.btrfs -f "${rootpart}" > /dev/null 2>&1 ; then
mount "${rootpart}" /mnt &&
btrfs subvolume create /mnt/@ &&
btrfs subvolume create /mnt/@home &&
btrfs subvolume create /mnt/@cache &&
btrfs subvolume create /mnt/@log &&
btrfs subvolume create /mnt/@tmp &&
btrfs subvolume create /mnt/@snapshots &&
if [[ "${swapmode}" == "2" ]]; then
btrfs subvolume create /mnt/@swap
fi
if umount /mnt; then
sleep 0.3
NC "
==> [${green}Format ${roottype} OK${nc}] "
else
sleep 0.3
RED "
[!] Unmounting failed "
abort
fi
else
reload
until disk_mngr; do : ; done
until form_root; do : ; done
return 0
fi
fi
else
invalid
return 1
fi
YELLOW "
> Label the ${roottype} partition "
BLUE "
Enter a name ${bwhite}(empty to skip and proceed)${blue}: "
read -r -p "
==> " rootpartname
if [[ -n "${rootpartname}" ]]; then
if [[ "${fs}" == "1" ]]; then
if e2label "${rootpart}" "${rootpartname}" > /dev/null 2>&1 ; then
sleep 0.3
NC "
==> [${green}Label ${roottype} OK${nc}] "
return 0
else
err_try
until disk_mngr; do : ; done
until form_root; do : ; done
return 0
fi
elif [[ "${fs}" == "2" ]]; then
mount "${rootpart}" /mnt &&
btrfs filesystem label /mnt "${rootpartname}" > /dev/null 2>&1 &&
if umount /mnt; then
sleep 0.3
NC "
==> [${green}Label ${roottype} OK${nc}] "
return 0
else
err_try
until disk_mngr; do : ; done
until form_root; do : ; done
return 0
fi
fi
fi
skip
return 0
else
RED "
[!] Warning: Partition NOT Formatted !
"
skip
return 0
fi
done
}
###########################################################################################
ask_homepart_form (){
if [[ -e "${home_dev}" && "${fs}" == "1" ]]; then
BLUE "
> A /Home partition has been detected. Format as ${fsname}? [y/n]
"
read -r -p "
==> " homeform
echo
if [[ "${homeform}" == "y" ]]; then
if mkdir -pv /mnt/home > /dev/null 2>&1 ; then
if mkfs.ext4 -F -L Home "${home_dev}" > /dev/null 2>&1 ; then
if mount "${home_dev}" /mnt/home; then
sleep 0.3
NC "
==> [${green}/HOME OK${nc}]
"
else
umount_manual
until disk_mngr; do : ; done
until form_home; do : ; done
until mount_mnt; do : ; done
until mount_boot; do : ; done
until mount_home; do : ; done
fi
else
umount_manual
until disk_mngr; do : ; done
until form_home; do : ; done
until mount_mnt; do : ; done
until mount_boot; do : ; done
until mount_home; do : ; done
fi
else
sleep 0.3
RED "
[!] Failed creating /mnt/home directory "
abort
fi
elif [[ "${homeform}" == "n" ]]; then
skip
return 0
else
invalid
ask_homepart_form
fi
fi
}
###########################################################################################
form_home (){
sleep 0.3
NC "
_____________________________
${purple}###${nc} Format Home Partition ${purple}###${nc}
"
form_home_nmbr=" "
while [[ -n "${form_home_nmbr}" ]]; do
YELLOW "
> Select a partition to format as 'Ext4' [/HOME] "
NC "
${volumes} "
BLUE "
Enter a partition number ${bwhite}(empty to skip and proceed)${blue}: "
read -r -p "
==> " form_home_nmbr
if [[ -n "${form_home_nmbr}" ]]; then
homepart="$(echo "${volumes}" | awk "\$1 == ${form_home_nmbr} { print \$2}")"
if [[ -e "${homepart}" ]]; then
if mkfs.ext4 -F "${homepart}" > /dev/null 2>&1 ; then
sleep 0.3
NC "
==> [${green}Format /HOME OK${nc}] "
else
umount_abort
until disk_mngr; do : ; done
until form_home; do : ; done
return 0
fi
else
invalid
return 1
fi
YELLOW "
> Label the /HOME partition "
BLUE "
Enter a name ${bwhite}(empty to skip and proceed)${blue}: "
read -r -p "
==> " homepartname
if [[ -n "${homepartname}" ]]; then
if e2label "${homepart}" "${homepartname}"; then
sleep 0.3
NC "
==> [${green}Label /HOME OK${nc}] "
return 0
else
err_try
until disk_mngr; do : ; done
until form_home; do : ; done
return 0
fi
fi
skip
return 0
else
skip
return 0
fi
done
}
###########################################################################################
mount_mnt (){
local prompt="Mount ${roottype} "
sleep 0.3
NC "
____________________________
${purple}###${nc} Mount Root Partition ${purple}###${nc}
"
YELLOW "
> Select a partition to mount to /mnt "
NC "
${volumes} "
BLUE "
Enter your${nc} ${cyan}${roottype}${blue} partition number: "
read -r -p "
==> " mntroot_nmbr
echo
if [[ -n "${mntroot_nmbr}" ]]; then
rootpart="$(echo "${volumes}" | awk "\$1 == ${mntroot_nmbr} { print \$2}")"
if [[ -e "${rootpart}" ]]; then
#------------------------------------------------------------------------------------------
if [[ "${fs}" == "1" ]]; then
if mount "${rootpart}" /mnt; then
sleep 0.3
ok
return 0
else
umount_abort
until mount_mnt; do : ; done
fi
#------------------------------------------------------------------------------------------
elif [[ "${fs}" == "2" ]]; then
mount -o "${sbvl_mnt_opts}",subvol=@ "${rootpart}" /mnt &&
if [[ "${swapmode}" == "2" ]]; then
mkdir -p /mnt/swap > /dev/null 2>&1 &&
mount -o rw,nodatacow,subvol=@swap "${rootpart}" /mnt/swap
fi
mkdir -p /mnt/{var/cache,home,var/log,var/tmp,"${snapname}"} > /dev/null 2>&1 &&
mount -o "${sbvl_mnt_opts}",subvol=@cache "${rootpart}" /mnt/var/cache &&
mount -o "${sbvl_mnt_opts}",subvol=@home "${rootpart}" /mnt/home &&
mount -o "${sbvl_mnt_opts}",subvol=@log "${rootpart}" /mnt/var/log &&
mount -o "${sbvl_mnt_opts}",subvol=@snapshots "${rootpart}" /mnt/"${snapname}" &&
if mount -o "${sbvl_mnt_opts}",subvol=@tmp "${rootpart}" /mnt/var/tmp; then
sleep 0.3
ok
return 0
else
umount_abort
until mount_mnt; do : ; done
fi
fi
#------------------------------------------------------------------------------------------
else
invalid
return 1
fi
else
choice
return 1
fi
}
###########################################################################################
mount_boot (){
local prompt="Mount /BOOT"
sleep 0.3
NC "
____________________________
${purple}###${nc} Mount Boot Partition ${purple}###${nc}
"
YELLOW "
> Select a partition to mount to /mnt/boot "
NC "
${volumes} "
BLUE "
Enter your${nc} ${cyan}/BOOT${blue} partition number: "
read -r -p "
==> " mntboot_nmbr
echo
if [[ -n "${mntboot_nmbr}" ]]; then
bootpart="$(echo "${volumes}" | awk "\$1 == ${mntboot_nmbr} { print \$2}")"
if [[ -e "${bootpart}" ]]; then
if mount "${bootpart}" /mnt/boot; then
ok
return 0
else
umount_abort
until mount_mnt; do : ; done
until mount_boot; do : ; done
fi
else
invalid
return 1
fi
else
choice
return 1
fi
}
###########################################################################################
mount_home (){
local prompt="Mount /HOME"
sleep 0.3
NC "
____________________________
${purple}###${nc} Mount Home Partition ${purple}###${nc}
"
YELLOW "
> Select a partition to mount to /mnt/home "
NC "
${volumes} "
BLUE "
Enter your${nc} ${cyan}/HOME${blue} partition number: "
read -r -p "
==> " mnthome_nmbr
echo
if [[ -n "${mnthome_nmbr}" ]]; then
homepart="$(echo "${volumes}" | awk "\$1 == ${mnthome_nmbr} { print \$2}")"
if [[ -e "${homepart}" ]]; then
if mount "${homepart}" /mnt/home; then
ok
return 0
else
umount_abort
until mount_mnt; do : ; done
until mount_boot; do : ; done
until mount_home; do : ; done
fi
else
invalid
return 1
fi
else
choice
return 1
fi
}
###########################################################################################
confirm_status (){
local prompt="System Ready"
sleep 0.3
NC "
___________________________________
${purple}###${nc} Confirm Installation Status ${purple}###${nc}
"
BLUE "
> Proceed ? "
NC "
* Type '${cyan}yes${nc}' to continue installation
* Type '${cyan}no${nc}' to revise installation
"
read -r -p "
==> " agree
if [[ "${agree}" == "yes" ]]; then
ok
until opt_pcmn; do : ; done
until pacstrap_system; do : ; done
if [[ "${swapmode}" == "2" ]]; then
until "${swaptype}"; do : ; done
fi
if [[ -n "${REGDOM}" ]]; then
until wireless_regdom; do : ; done
fi
chroot_conf
elif [[ "${agree}" == "no" ]]; then
reload
sleep 0.3
NC "
___________________________
${purple}###${nc} Unmount Filesystems ${purple}###${nc}
"
if umount -R /mnt; then
sleep 0.3
NC "
==> [${green}Unmount OK${nc}]"
else
sleep 0.3
RED "
[!] Unmounting failed "
abort
fi
revise
else
sleep 0.3
RED "
[!] Please type 'yes' or 'no' to continue.. "
reload
return 1
fi
}
###########################################################################################
revise (){
revision="yes"
until slct_krnl; do : ; done
until ask_bootldr; do : ; done
until ask_fs; do : ; done
until ask_swap; do : ; done
until dtct_vga; do : ; done
until slct_dsktp; do : ; done
until boot_entr; do : ; done
until wireless_rgd; do : ; done
until disk_mngr; do : ; done
until instl_dsk; do : ; done
until ask_crypt; do : ; done
if [[ "${swapmode}" == "1" ]]; then
until "${swaptype}"; do : ; done
fi
until set_mode; do : ; done
until confirm_status; do : ; done
}
###########################################################################################
sec_erase (){
local prompt="Secure Erasure"
sleep 0.3
NC "
___________________________
${purple}###${nc} Secure Disk Erasure ${purple}###${nc}
"
erase_dsk_nmbr=" "
while [[ -n "${erase_dsk_nmbr}" ]]; do
YELLOW "
> Select a disk for Secure Erasure ${red}[!] (CAUTION) [!]${yellow}
### A ${nc}reboot${yellow} is mandatory and will take effect immediately when done "
NC "
${disks}"
BLUE "
Enter a disk number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " erase_dsk_nmbr
echo
if [[ -n "${erase_dsk_nmbr}" ]]; then
erasedrive="$(echo "${disks}" | awk "\$1 == ${erase_dsk_nmbr} {print \$2}")"
if [[ -e "${erasedrive}" ]]; then
cryptsetup open --type plain -d /dev/urandom "${erasedrive}" temp &&
dd if=/dev/zero of=/dev/mapper/temp status=progress bs=1M oflag=direct &&
cryptsetup close temp
sleep 0.3
NC "
==> [${green}Drive ${erasedrive} Erased OK${nc}] "
sleep 1
NC "
==> [${green}Rebooting${nc}] "
sleep 3
reboot
else
invalid
return 1
fi
else
skip
ok
fi
done
}
###########################################################################################
luks (){
sleep 0.3
NC "
_______________________
${purple}###${nc} LUKS Encryption ${purple}###${nc}
"
if cryptsetup -y -v luksFormat --label CRYPTROOT "${root_dev}"; then
if [[ "${rota}" == "0" ]]; then
cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --persistent luksOpen "${root_dev}" "${ENCROOT}"
else
cryptsetup luksOpen "${root_dev}" "${ENCROOT}"
fi
#------------------------------------------------------------------------------------------
if [[ "${fs}" == "1" ]]; then
if mkfs.ext4 -F -L Root /dev/mapper/"${ENCROOT}" > /dev/null 2>&1 ; then
if mount /dev/mapper/"${ENCROOT}" /mnt; then
sleep 0.3
NC "
==> [${green}Encrypted Root OK${nc}]
"
else
err_abort
fi
else
err_abort
fi
#------------------------------------------------------------------------------------------
elif [[ "${fs}" == "2" ]]; then
if mkfs.btrfs -L Root /dev/mapper/"${ENCROOT}" > /dev/null 2>&1 ; then
mount /dev/mapper/"${ENCROOT}" /mnt &&
btrfs subvolume create /mnt/@ &&
btrfs subvolume create /mnt/@home &&
btrfs subvolume create /mnt/@cache &&
btrfs subvolume create /mnt/@log &&
btrfs subvolume create /mnt/@snapshots &&
btrfs subvolume create /mnt/@tmp &&
if [[ "${swapmode}" == "2" ]]; then
btrfs subvolume create /mnt/@swap
fi
umount /mnt &&
mount -o "${sbvl_mnt_opts}",subvol=@ /dev/mapper/"${ENCROOT}" /mnt &&
if [[ "${swapmode}" == "2" ]]; then
mkdir -p /mnt/swap > /dev/null 2>&1 &&
mount -o rw,nodatacow,subvol=@swap /dev/mapper/"${ENCROOT}" /mnt/swap
fi
mkdir -p /mnt/{var/cache,home,var/log,var/tmp,"${snapname}"} > /dev/null 2>&1 &&
mount -o "${sbvl_mnt_opts}",subvol=@cache /dev/mapper/"${ENCROOT}" /mnt/var/cache &&
mount -o "${sbvl_mnt_opts}",subvol=@home /dev/mapper/"${ENCROOT}" /mnt/home &&
mount -o "${sbvl_mnt_opts}",subvol=@log /dev/mapper/"${ENCROOT}" /mnt/var/log &&
mount -o "${sbvl_mnt_opts}",subvol=@snapshots /dev/mapper/"${ENCROOT}" /mnt/"${snapname}" &&
mount -o "${sbvl_mnt_opts}",subvol=@tmp /dev/mapper/"${ENCROOT}" /mnt/var/tmp &&
sleep 0.3
NC "
==> [${green}Encrypted /@ OK${nc}]
"
else
err_abort
fi
fi
else
umount_abort
until luks; do : ; done
fi
#------------------------------------------------------------------------------------------
NC "
"
if [[ -e "${swap_dev}" ]]; then
if cryptsetup -y -v luksFormat --label CRYPTSWAP "${swap_dev}"; then
if [[ "${rota}" == "0" ]]; then
cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --persistent luksOpen "${swap_dev}" swap
else
cryptsetup luksOpen "${swap_dev}" swap
fi
if mkswap /dev/mapper/swap > /dev/null 2>&1 ; then
sleep 0.3
NC "
==> [${green}Encrypted Swap OK${nc}]
"
else
err_abort
fi
else
umount_abort
until luks; do : ; done
fi
fi
#------------------------------------------------------------------------------------------
NC "
"
if [[ "${homecrypt}" == "yes" ]]; then
if cryptsetup -y -v luksFormat --label CRYPTHOME "${home_dev}"; then
if [[ "${rota}" == "0" ]]; then
cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --persistent luksOpen "${home_dev}" "${ENCRHOME}"
else
cryptsetup luksOpen "${home_dev}" "${ENCRHOME}"
fi
mkfs.ext4 -F -L Home /dev/mapper/"${ENCRHOME}" > /dev/null 2>&1 &&
mkdir -p /mnt/home > /dev/null 2>&1 &&
if mount /dev/mapper/"${ENCRHOME}" /mnt/home; then
sleep 0.3
NC "
==> [${green}Encrypted Home OK${nc}]
"
else
err_abort
fi
else
umount_abort
until luks; do : ; done
fi
elif [[ "${homecrypt}" == "no" ]]; then
BLUE "
> A /Home partition has been detected. Format as ${fsname}? [y/n]
"
read -r -p "
==> " homeform
echo
if [[ "${homeform}" == "y" ]]; then
if mkfs.ext4 -F -L Home "${home_dev}" > /dev/null 2>&1 ; then
mkdir -p /mnt/home > /dev/null 2>&1 &&
if mount "${home_dev}" /mnt/home; then
sleep 0.3
NC "
==> [${green}/Home OK${nc}]
"
else
err_abort
fi
else
umount_abort
until luks; do : ; done
fi
elif [[ "${homeform}" == "n" ]]; then
skip
else
invalid
return 1
fi
fi
#------------------------------------------------------------------------------------------
if mkfs.fat -F 32 -n Boot "${boot_dev}" > /dev/null 2>&1 ; then
mkdir -pv /mnt/boot > /dev/null 2>&1 &&
if mount "${boot_dev}" /mnt/boot; then
sleep 0.3
NC "
==> [${green}/BOOT OK${nc}]
"
else
umount_abort
until luks; do : ; done
fi
else
umount_abort
until luks; do : ; done
fi
sleep 0.3
NC "
==> [${green}Encryption OK${nc}]"
sleep 0.3
NC "
------------------------------------------------------------------------------------------------------------------
==> [${green}Filesystems OK${nc}]
"
sleep 0.3
YELLOW "
###---------------------------------------[ FILESYSTEM OVERVIEW ]---------------------------------------###
"
lsblk -f |GREP_COLORS='mt=01;36' grep -E --color=always 'vfat|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'ext4|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'btrfs|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'ntfs|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'swap|$'
YELLOW "
###-------------------------------------------------------------------------------------------------------###"
echo
sleep 1
}
###########################################################################################
opt_pcmn (){
local prompt="PacMan"
sleep 0.3
NC "
_______________________
${purple}###${nc} Optimize PacMan ${purple}###${nc}
"
YELLOW "
> Select a Country for your Arch Mirrors:
### [Hit ${nc}'l'${yellow} to list Countries, then ${nc}'enter'${yellow} to search or ${nc}'q'${yellow} to quit] "
BLUE "
Enter country name or country code ${bwhite}(Empty for Defaults)${blue}: "
read -r -p "
==> " COUNTRY
echo
if [[ -z "${COUNTRY}" ]] ; then
sleep 0.3
NC "
==> [${green}Default Mirrors OK${nc}] "
elif [[ "${COUNTRY}" == "l" ]]; then
reflector --list-countries | more
return 1
elif [[ -n "${COUNTRY}" ]] ; then
NC "
"
if reflector --verbose -c "${COUNTRY}" -l 10 -p https -f 10 --sort rate --save /etc/pacman.d/mirrorlist ; then
sleep 0.3
NC "
==> [${green}${COUNTRY}'s Mirrors OK${nc}] "
else
err_try
return 1
fi
fi
#------------------------------------------------------------------------------------------
YELLOW "
> Enable Pacman's 'Parallel Downloads' feature? [y/n] "
BLUE "
Enter [y/n]: "
read -r -p "
==> " parallel
echo
if [[ "${parallel}" == "y" ]]; then
sleep 0.3
YELLOW "
> Select number of Parallel Downloads [2-5] "
NC "
${green}**${nc} [2]
${cyan}***${nc} [3]
${yellow}****${nc} [4]
${red}*****${nc} [5] "
BLUE "
Enter a number: "
read -r -p "
==> " parallelnmbr
echo
if [[ "${parallelnmbr}" =~ ^(2|3|4|5)$ ]]; then
sed -i "s|#ParallelDownloads = 5|ParallelDownloads = ${parallelnmbr}|g" /etc/pacman.conf
else
invalid
return 1
fi
sleep 0.3
NC "
==> [${green}${parallelnmbr} Parallel Downloads OK${nc}]"
elif [[ "${parallel}" == "n" ]]; then
skip
elif [[ -z "${parallel}" ]]; then
sleep 0.3
RED "
[!] Please make a selection to continue "
reload
return 1
else
invalid
return 1
fi
ok
}
###########################################################################################
pacstrap_system (){
local prompt="${desktopname}"
sleep 0.3
NC "
_______________________
${purple}###${nc} Pacstrap System ${purple}###${nc}
"
if [[ "${bootloader}" == "2" ]]; then
if [[ "${fs}" == "1" ]]; then
bootldr_pkgs="efibootmgr grub os-prober"
elif [[ "${fs}" == "2" ]]; then
bootldr_pkgs="efibootmgr grub-btrfs os-prober"
fi
fi
if [[ "${vendor}" == "Virtual Machine" ]]; then
basepkgs="base nano sudo vim ${bootldr_pkgs} ${fstools} ${kernel} ${microcode} ${vmpkgs} ${devel}"
elif [[ "${vendor}" == "Nvidia" ]]; then
basepkgs="base linux-firmware nano sudo vim ${bootldr_pkgs} ${fstools} ${kernel} ${kernel}-headers ${microcode} ${vgapkgs} ${wireless_reg} ${devel}"
else
basepkgs="base linux-firmware nano sudo vim ${bootldr_pkgs} ${fstools} ${kernel} ${microcode} ${vgapkgs} ${wireless_reg} ${devel}"
fi
case "${packages}" in
1) # NOTE: Plasma Desktop:
deskpkgs="${basepkgs} plasma konsole"
displaymanager="sddm"
bluetooth="bluetooth"
network="NetworkManager" ;;
2) # NOTE: Custom Plasma & Systemd-boot & Optimized System:
deskpkgs="${basepkgs} alsa-firmware alsa-utils arj ark bluedevil breeze-gtk ccache cups-pdf cups-pk-helper dolphin-plugins e2fsprogs efibootmgr exfatprogs fdkaac ffmpegthumbs firefox git glibc-locales gst-libav gst-plugin-libcamera gst-plugin-msdk gst-plugin-opencv gst-plugin-pipewire gst-plugin-qmlgl gst-plugin-va gst-plugin-wpe gst-plugins-ugly gstreamer-vaapi htop icoutils ipp-usb kamera kamoso kate kcalc kde-gtk-config kdegraphics-mobipocket kdegraphics-thumbnailers kdenetwork-filesharing kdeplasma-addons kdesdk-kio kdesdk-thumbnailers kdialog keditbookmarks kget kimageformats kinit kio-admin kio-gdrive kio-zeroconf kompare konsole kscreen kvantum kwrited libappimage libfido2 libktorrent libmms libnfs libva-utils lirc lrzip lua52-socket lzop mac man-db man-pages mesa-demos mesa-utils mold nano-syntax-highlighting nss-mdns ntfs-3g okular opus-tools p7zip packagekit-qt6 pacman-contrib partitionmanager pbzip2 pdfmixtool pigz pipewire-alsa pipewire-pulse pkgstats plasma-browser-integration plasma-desktop plasma-disks plasma-firewall plasma-nm plasma-pa plasma-wayland-protocols power-profiles-daemon powerdevil powerline powerline-fonts print-manager python-pyqt6 python-reportlab qbittorrent qt6-imageformats qt6-scxml qt6-virtualkeyboard realtime-privileges reflector rng-tools sddm-kcm skanlite sof-firmware sox spectacle sshfs system-config-printer terminus-font timidity++ ttf-ubuntu-font-family unarchiver unrar unzip usb_modeswitch usbutils vdpauinfo vlc vorbis-tools vorbisgain wget xdg-desktop-portal xdg-desktop-portal-gtk xdg-desktop-portal-kde xsane zip zsh zsh-autosuggestions zsh-completions zsh-syntax-highlighting ${nrg_plc}" ;;
3) # NOTE: Gnome Desktop:
deskpkgs="${basepkgs} gnome networkmanager"
displaymanager="gdm"
bluetooth="bluetooth"
network="NetworkManager" ;;
4) # NOTE: Custom Gnome & Systemd-boot & Optimized System:
deskpkgs="${basepkgs} evince file-roller gdm gnome-calculator gnome-clocks gnome-console gnome-control-center gnome-disk-utility gnome-keyring gnome-menus gnome-session gnome-shell-extensions gnome-system-monitor gnome-text-editor gnome-tweaks gvfs gvfs-afc gvfs-mtp loupe malcontent nautilus networkmanager power-profiles-daemon simple-scan sushi system-config-printer xdg-desktop-portal-gnome xdg-user-dirs-gtk alsa-firmware alsa-utils ccache cups-pdf e2fsprogs efibootmgr exfatprogs fdkaac git glibc-locales gnome-browser-connector gparted gst-libav gst-plugin-libcamera gst-plugin-msdk gst-plugin-opencv gst-plugin-pipewire gst-plugin-qmlgl gst-plugin-va gst-plugin-wpe gst-plugins-ugly gstreamer-vaapi htop icoutils ipp-usb libfido2 libva-utils lrzip mac man-db man-pages meld mesa-utils mold nano-syntax-highlighting nss-mdns ntfs-3g p7zip pacman-contrib pbzip2 pdfmixtool pigz pipewire-alsa pipewire-pulse pkgstats powerline powerline-fonts qbittorrent realtime-privileges reflector rng-tools sof-firmware terminus-font ttf-ubuntu-font-family unrar unzip usb_modeswitch usbutils vdpauinfo vlc wget zip zsh zsh-autosuggestions zsh-completions zsh-syntax-highlighting ${nrg_plc}" ;;
5) # NOTE: Xfce Desktop:
deskpkgs="${basepkgs} xfce4 lightdm-slick-greeter network-manager-applet"
displaymanager="lightdm"
network="NetworkManager" ;;
6) # NOTE: Cinnamon Desktop:
deskpkgs="${basepkgs} cinnamon blueberry lightdm-slick-greeter system-config-printer gnome-keyring ${terminal}"
displaymanager="lightdm"
bluetooth="bluetooth"
network="NetworkManager" ;;
7) # NOTE: Deepin Desktop:
deskpkgs="${basepkgs} deepin deepin-terminal deepin-kwin networkmanager"
displaymanager="lightdm"
network="NetworkManager" ;;
8) # NOTE: Budgie Desktop:
deskpkgs="${basepkgs} budgie lightdm-gtk-greeter arc-gtk-theme papirus-icon-theme network-manager-applet ${terminal}"
displaymanager="lightdm"
network="NetworkManager" ;;
9) # NOTE: Lxqt Desktop:
deskpkgs="${basepkgs} lxqt breeze-icons network-manager-applet sddm xscreensaver"
displaymanager="sddm"
network="NetworkManager" ;;
10) # NOTE: Mate Desktop:
deskpkgs="${basepkgs} mate mate-terminal mate-media blueman network-manager-applet mate-power-manager system-config-printer lightdm-slick-greeter"
displaymanager="lightdm"
bluetooth="bluetooth"
network="NetworkManager" ;;
11) # NOTE: Base System:
deskpkgs="${basepkgs} networkmanager"
network="NetworkManager" ;;
12) # NOTE: Custom System:
if [[ "${vendor}" == "Virtual Machine" ]]; then
deskpkgs="base sudo ${bootldr_pkgs} ${custompkgs} ${fstools} ${kernel} ${microcode} ${vmpkgs} ${greeter}"
else
deskpkgs="base linux-firmware sudo ${bootldr_pkgs} ${custompkgs} ${fstools} ${kernel} ${microcode} ${vgapkgs} ${wireless_reg} ${greeter}"
fi ;;
esac
if pacstrap -K -i /mnt ${deskpkgs}; then
if [[ "${fs}" == "2" ]]; then
if genfstab -t PARTUUID /mnt >> /mnt/etc/fstab ; then
sleep 0.3
NC "
==> [${green}Fstab OK${nc}] "
else
err_try
fi
fi
ok
else
err_reload
sleep 5
return 1
fi
}
###########################################################################################
swapfile (){
local prompt="Swapfile"
sleep 0.3
NC "
___________________________
${purple}###${nc} Swapfile Activation ${purple}###${nc}
"
if arch-chroot /mnt <<-SWAP ; then
mkswap -U clear --size ${swapsize}G --file /swapfile > /dev/null 2>&1
SWAP
if cat >> /mnt/etc/fstab <<-FSTAB ; then
/swapfile none swap defaults 0 0
FSTAB
ok
else
sleep 0.3
RED "
[!] Populating the 'fstab' file has failed "
abort
fi
else
err_swapfile
fi
}
###########################################################################################
swapfile_btrfs (){
local prompt="Btfrs Swapfile"
sleep 0.3
NC "
_________________________________
${purple}###${nc} Btrfs Swapfile Activation ${purple}###${nc}
"
if arch-chroot /mnt <<-SWAP ; then
btrfs filesystem mkswapfile --size ${swapsize}g --uuid clear /swap/swapfile > /dev/null 2>&1
SWAP
if cat >> /mnt/etc/fstab <<-FSTAB ; then
/swap/swapfile none swap defaults 0 0
FSTAB
ok
else
sleep 0.3
RED "
[!] Populating the 'fstab' file has failed "
abort
fi
else
err_swapfile
fi
}
###########################################################################################
wireless_regdom (){
local prompt="Wireless-Regdom"
sleep 0.3
NC "
__________________________________
${purple}###${nc} Setting Up Wireless-Regdom ${purple}###${nc}
"
if cat >> /mnt/etc/conf.d/wireless-regdom <<-REGDOM ; then
WIRELESS_REGDOM="${REGDOM}"
REGDOM
ok
else
err_reload
return 1
fi
}
###########################################################################################
chroot_conf (){
sleep 0.3
NC "
_________________________________
${purple}###${nc} Chroot & Configure System ${purple}###${nc}
"
# Linux-Hardened = No Swap
[[ "${kernelnmbr}" == "3" ]] && swapmode="3"
#### Encrypted Setup
if [[ "${encrypt}" == "yes" ]]; then
# Encrypted Root Device
encr_root_dev="/dev/mapper/${ENCROOT}"
# Encrypted Root Options
encr_root_opts="rd.luks.name=$(blkid -s UUID -o value "${root_dev}")=${ENCROOT}"
# Encrypted Kernel Boot Options
encr_root_bootopts="root=${encr_root_dev} ${encr_root_opts} "
### Swap Setup
## Swap Partition (Encryption)
if [[ "${swapmode}" == "1" ]]; then
# Swap Partition Options (Encryption)
encr_swap_opts="rd.luks.name=$(blkid -s UUID -o value "${swap_dev}")=swap"
# Swap Partition Kernel Main Boot Options (Encryption)
encr_swap_bootopts="resume=/dev/mapper/swap ${encr_swap_opts} "
## Swapfile (Encryption)
elif [[ "${swapmode}" == "2" ]]; then
# Ext4 Offset
if [[ "${fs}" == "1" ]]; then
offst="$(filefrag -v /mnt/swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}')"
# Btrfs Offset
elif [[ "${fs}" == "2" ]]; then
offst="$(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile)"
fi
# Swapfile Kernel Boot Options (Encryption)
encr_swap_bootopts="resume=${encr_root_dev} resume_offset=${offst} "
## No Swap
elif [[ "${swapmode}" == "3" ]]; then
# No Swap Kernel Boot Options (Encryption)
encr_swap_bootopts=""
fi
### Graphics Setup
## Configuration = 'Yes'
if [[ "${vgaconf}" == "y" ]]; then
# Intel
if [[ "${vendor}" == "Intel" ]]; then
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(i915 ${fs_mod})"
# Mkinitcpio Hooks (Encryption)
mkinitcpio_hooks="HOOKS=(systemd keyboard autodetect microcode modconf kms keymap consolefont block sd-encrypt filesystems fsck)"
elif [[ "${vendor}" == "Nvidia" ]]; then
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm ${fs_mod})"
# Mkinitcpio Hooks (Encryption)
mkinitcpio_hooks="HOOKS=(systemd keyboard autodetect microcode modconf keymap consolefont block sd-encrypt filesystems fsck)"
# Graphics Kernel Boot Options
vga_bootopts="modeset=1 "
elif [[ "${vendor}" == "AMD" ]]; then
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(amdgpu radeon ${fs_mod})"
# Mkinitcpio Hooks (Encryption)
mkinitcpio_hooks="HOOKS=(systemd keyboard autodetect microcode modconf kms keymap consolefont block sd-encrypt filesystems fsck)"
# 'Southern Islands' support
if [[ "${islands}" == "1" ]]; then
# Graphics Kernel Boot Options
vga_bootopts="radeon.si_support=0 amdgpu.si_support=1 amdgpu.dc=1 "
# 'Sea Islands' support
elif [[ "${islands}" == "2" ]]; then
# Graphics Kernel Boot Options
vga_bootopts="radeon.cik_support=0 amdgpu.cik_support=1 amdgpu.dc=1 "
elif [[ -z "${islands}" ]]; then
# Graphics Kernel Boot Options
vga_bootopts="amdgpu.dc=1 "
fi
fi
## Configuration = 'No'
elif [[ "${vgaconf}" == "n" ]]; then
# Mkinitcpio Hooks (Encryption)
mkinitcpio_hooks="HOOKS=(systemd keyboard autodetect microcode modconf kms keymap consolefont block sd-encrypt filesystems fsck)"
# Nvidia
if [[ "${vendor}" == "Nvidia" ]]; then
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(${fs_mod} nouveau)"
# Other Vendors
else
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(${fs_mod})"
fi
fi
### Kernel Boot Options (Encryption)
boot_opts="${encr_root_bootopts}${encr_swap_bootopts}${vga_bootopts}${cust_bootopts}${btrfs_bootopts}"
#------------------------------------------------------------------------------------------
#### Unencrypted Setup
elif [[ "${encrypt}" == "no" ]]; then
### Swap Setup
## Swap Partition
if [[ "${swapmode}" == "1" ]]; then
# Swap Partition Kernel Boot Options
swap_bootopts="resume=UUID=$(blkid -s UUID -o value "${swap_dev}") "
## Swapfile
elif [[ "${swapmode}" == "2" ]]; then
# Ext4 Offset
if [[ "${fs}" == "1" ]]; then
offst="$(filefrag -v /mnt/swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}')"
# Btrfs Offset
elif [[ "${fs}" == "2" ]]; then
offst="$(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile)"
fi
# Swapfile Kernel Boot Options
swap_bootopts="resume=UUID=$(blkid -s UUID -o value "${root_dev}") resume_offset=${offst} "
## No Swap
elif [[ "${swapmode}" == "3" ]]; then
# No Swap Kernel Boot Options
swap_bootopts=""
fi
### Graphics Setup
## Configuration = 'Yes'
if [[ "${vgaconf}" == "y" ]]; then
# Intel
if [[ "${vendor}" == "Intel" ]]; then
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=(i915)"
# Mkinitcpio Hooks
mkinitcpio_hooks="HOOKS=(systemd autodetect microcode modconf kms keyboard keymap consolefont block filesystems fsck)"
# Nvidia
elif [[ "${vendor}" == "Nvidia" ]]; then
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)"
# Mkinitcpio Hooks
mkinitcpio_hooks="HOOKS=(systemd autodetect microcode modconf keyboard keymap consolefont block filesystems fsck)"
# Graphics Kernel Boot Options
vga_bootopts="modeset=1 "
# Amd
elif [[ "${vendor}" == "AMD" ]]; then
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=(amdgpu radeon)"
# Mkinitcpio Hooks
mkinitcpio_hooks="HOOKS=(systemd autodetect microcode modconf kms keyboard keymap consolefont block filesystems fsck)"
# 'Southern Islands' support
if [[ "${islands}" == "1" ]]; then
# Graphics Kernel Boot Options
vga_bootopts="radeon.si_support=0 amdgpu.si_support=1 amdgpu.dc=1 "
# 'Sea Islands' support
elif [[ "${islands}" == "2" ]]; then
# Graphics Kernel Boot Options
vga_bootopts="radeon.cik_support=0 amdgpu.cik_support=1 amdgpu.dc=1 "
elif [[ -z "${islands}" ]]; then
# Graphics Kernel Boot Options
vga_bootopts="amdgpu.dc=1 "
fi
fi
## Configuration = 'No'
elif [[ "${vgaconf}" == "n" ]]; then
# Mkinitcpio Hooks
mkinitcpio_hooks="HOOKS=(systemd autodetect microcode modconf kms keyboard keymap consolefont block filesystems fsck)"
# Nvidia
if [[ "${vendor}" == "Nvidia" ]]; then
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=(nouveau)"
# Other Vendors
else
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=()"
fi
fi
### Kernel Boot Options (No Encryption)
boot_opts="${swap_bootopts}${vga_bootopts}${cust_bootopts}${btrfs_bootopts}"
fi
#------------------------------------------------------------------------------------------
# NOTE: All Vanilla Desktops Basic Configuration:
if [[ "${packages}" =~ ^(1|3|5|6|7|8|9|10|11)$ ]]; then
stage_prompt="Base System"
if arch-chroot /mnt <<-VANILLA_CONF ; then
sed -i "/^#${SETLOCALE}/s/^#//" /etc/locale.gen &&
locale-gen &&
echo LANG=${SETLOCALE} > /etc/locale.conf &&
export LANG=${SETLOCALE} &&
echo KEYMAP=${SETKBD} > /etc/vconsole.conf &&
echo "
${mkinitcpio_mods}
${mkinitcpio_hooks}" | tee /etc/mkinitcpio.conf.d/mkinitcpiod.conf &&
mkinitcpio -P &&
ln -sf /usr/share/zoneinfo/$(curl -s http://ip-api.com/line?fields=timezone) /etc/localtime &&
hwclock --systohc &&
echo ${HOSTNAME} > /etc/hostname &&
echo "
127.0.0.1 localhost
::1 localhost
127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}" >> /etc/hosts &&
echo root:${ROOTPASSWD2} | chpasswd &&
useradd -m -G wheel -s /bin/bash ${USERNAME} &&
echo ${USERNAME}:${USERPASSWD2} | chpasswd &&
echo "
%wheel ALL=(ALL) ALL" | tee /etc/sudoers.d/sudoersd &&
visudo -c /etc/sudoers.d/sudoersd
VANILLA_CONF
stage_ok
else
stage_fail
fi
if [[ -f /mnt/etc/lightdm/lightdm.conf ]]; then
if [[ "${packages}" == "7" ]]; then
stage_prompt="Deepin Greeter"
if arch-chroot /mnt <<-DEEPIN ; then
sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-deepin-greeter|g' /etc/lightdm/lightdm.conf
DEEPIN
stage_ok
else
stage_fail
fi
elif [[ "${packages}" == "8" ]]; then
stage_prompt="GTK Greeter"
if arch-chroot /mnt <<-GTK ; then
sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-gtk-greeter|g' /etc/lightdm/lightdm.conf
GTK
stage_ok
else
stage_fail
fi
else
stage_prompt="Slick Greeter"
if arch-chroot /mnt <<-SLICK ; then
sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-slick-greeter|g' /etc/lightdm/lightdm.conf
SLICK
stage_ok
else
stage_fail
fi
fi
fi
if [[ "${bootloader}" == "1" ]]; then
stage_prompt="Systemd-boot"
if arch-chroot /mnt <<-BOOTCTL ; then
bootctl install --graceful &&
echo "default arch.conf" > /boot/loader/loader.conf &&
echo "
title ${entrname}
linux /vmlinuz-${kernel}
initrd /initramfs-${kernel}.img
options rw ${boot_opts}" | tee /boot/loader/entries/arch.conf &&
systemctl enable systemd-boot-update ${bluetooth} ${displaymanager} ${network} ${trim} ${vm_services}
BOOTCTL
stage_ok
else
stage_fail
fi
elif [[ "${bootloader}" == "2" ]]; then
stage_prompt="Grub"
if arch-chroot /mnt <<-GRUB ; then
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB &&
sed -i \
-e 's|^GRUB_CMDLINE_LINUX_DEFAULT.*|GRUB_CMDLINE_LINUX_DEFAULT="${boot_opts}"|g' \
-e "/^#GRUB_DISABLE_OS_PROBER=false/s/^#//" \
/etc/default/grub &&
grub-mkconfig -o /boot/grub/grub.cfg &&
systemctl enable ${bluetooth} ${displaymanager} ${network} ${trim} ${vm_services}
GRUB
stage_ok
else
stage_fail
fi
if [[ "${bootloader}" == "2" && "${fs}" == "2" ]]; then
stage_prompt="Grub-Btrfsd"
if arch-chroot /mnt <<-GRUBBTRFSD ; then
systemctl enable grub-btrfsd
GRUBBTRFSD
stage_ok
else
stage_fail
fi
fi
if [[ "${vgaconf}" == "y" && "${vendor}" == "Nvidia" ]]; then
stage_prompt="Grub-Nvidia"
if arch-chroot /mnt <<-NVIDIAGRUB ; then
sed -i "/^#GRUB_TERMINAL_OUTPUT=console/s/^#//" /etc/default/grub &&
grub-mkconfig -o /boot/grub/grub.cfg
NVIDIAGRUB
stage_ok
else
stage_fail
fi
fi
fi
if [[ "${vgaconf}" == "y" && "${vendor}" == "Nvidia" ]]; then
if [[ "${kernelnmbr}" == "1" ]] || [[ "${kernelnmbr}" == "2" && "${family}" == "1" ]] || [[ "${kernelnmbr}" == "2" && "${family}" == "2" && "${nvdriver}" == "2" ]]; then
stage_prompt="Nvidia-Hook"
if arch-chroot /mnt <<-NVIDIAHOOK ; then
mkdir -p /etc/pacman.d/hooks/ > /dev/null 2>&1 &&
echo "
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=${nvname}
Target=${kernel}
[Action]
Description=Update NVIDIA module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux*) exit 0; esac; done; /usr/bin/mkinitcpio -P' " | tee /etc/pacman.d/hooks/nvidia.hook
NVIDIAHOOK
stage_ok
else
stage_fail
fi
fi
fi
completion
fi
#------------------------------------------------------------------------------------------
# NOTE: Plasma / Gnome & Systemd-boot Optimized-System Configuration:
if [[ "${packages}" == "2" ]] || [[ "${packages}" == "4" ]]; then
stage_prompt="Main System"
if [[ "${packages}" == "2" ]]; then
displaymanager="sddm"
elif [[ "${packages}" == "4" ]]; then
displaymanager="gdm"
fi
if [[ -n "${nrg_plc}" ]]; then
arch-chroot /mnt <<-NRG
${nrg_plc} performance
NRG
fi
if arch-chroot /mnt <<-OPTIMIZED_CONF ; then
sed -i "/^#${SETLOCALE}/s/^#//" /etc/locale.gen &&
locale-gen &&
echo LANG=${SETLOCALE} > /etc/locale.conf &&
export LANG=${SETLOCALE} &&
echo KEYMAP=${SETKBD} > /etc/vconsole.conf &&
sed -i "/^#Color/s/^#//" /etc/pacman.conf &&
update-pciids &&
echo '
${mkinitcpio_mods}
${mkinitcpio_hooks}
COMPRESSION="zstd"
COMPRESSION_OPTIONS=(-c -T$(nproc) --auto-threads=logical -)
MODULES_DECOMPRESS="yes"' | tee /etc/mkinitcpio.conf.d/mkinitcpiod.conf &&
mkinitcpio -P &&
echo '
CFLAGS="-march=native -O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection \
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now \
-Wl,-z,pack-relative-relocs,-fuse-ld=mold"
RUSTFLAGS="-C force-frame-pointers=yes -C opt-level=3 -C target-cpu=native -C link-arg=-fuse-ld=mold"
MAKEFLAGS="-j$(nproc)"
BUILDENV=(!distcc color ccache check !sign)
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)
COMPRESSGZ=(pigz -c -f -n)
COMPRESSBZ2=(pbzip2 -c -f)
COMPRESSZST=(zstd -c -T0 --ultra -20 --auto-threads=logical -)' | tee /etc/makepkg.conf.d/makepkgd.conf &&
ln -sf /usr/share/zoneinfo/$(curl -s http://ip-api.com/line?fields=timezone) /etc/localtime &&
hwclock --systohc &&
echo ${HOSTNAME} > /etc/hostname &&
echo "
127.0.0.1 localhost
::1 localhost
127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}" >> /etc/hosts &&
echo "
net.core.netdev_max_backlog = 16384
net.core.somaxconn = 8192
net.core.rmem_default = 1048576
net.core.rmem_max = 16777216
net.core.wmem_default = 1048576
net.core.wmem_max = 16777216
net.core.optmem_max = 65536
net.ipv4.tcp_rmem = 4096 1048576 2097152
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.udp_rmem_min = 8192
net.ipv4.udp_wmem_min = 8192
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_sack = 1
net.core.default_qdisc = cake
net.ipv4.tcp_congestion_control = bbr
net.ipv4.ip_local_port_range = 30000 65535
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
vm.vfs_cache_pressure = 50
vm.mmap_min_addr = 65536
kernel.printk = 0 0 0 0
${perf_stream}" | tee /etc/sysctl.d/99-sysctld.conf &&
echo "
[defaults]
ntfs:ntfs3_defaults=uid=1000,gid=1000,windows_names" | tee /etc/udisks2/mount_options.conf &&
echo '
// Original rules: https://github.com/coldfix/udiskie/wiki/Permissions
// Changes: Added org.freedesktop.udisks2.filesystem-mount-system, as this is used by Dolphin.
polkit.addRule(function(action, subject) {
var YES = polkit.Result.YES;
var permission = {
// required for udisks1:
"org.freedesktop.udisks.filesystem-mount": YES,
"org.freedesktop.udisks.luks-unlock": YES,
"org.freedesktop.udisks.drive-eject": YES,
"org.freedesktop.udisks.drive-detach": YES,
// required for udisks2:
"org.freedesktop.udisks2.filesystem-mount": YES,
"org.freedesktop.udisks2.encrypted-unlock": YES,
"org.freedesktop.udisks2.eject-media": YES,
"org.freedesktop.udisks2.power-off-drive": YES,
// Dolphin specific:
"org.freedesktop.udisks2.filesystem-mount-system": YES,
// required for udisks2 if using udiskie from another seat (e.g. systemd):
"org.freedesktop.udisks2.filesystem-mount-other-seat": YES,
"org.freedesktop.udisks2.filesystem-unmount-others": YES,
"org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
"org.freedesktop.udisks2.encrypted-unlock-system": YES,
"org.freedesktop.udisks2.eject-media-other-seat": YES,
"org.freedesktop.udisks2.power-off-drive-other-seat": YES
};
if (subject.isInGroup("wheel")) {
return permission[action.id];
}
});' | tee /etc/polkit-1/rules.d/99-udisks2.rules &&
mkdir -p /etc/systemd/journald.conf.d > /dev/null 2>&1 &&
echo "
[Journal]
SystemMaxUse=100M" | tee /etc/systemd/journald.conf.d/00-journald.conf &&
mkdir -p /etc/systemd/user.conf.d > /dev/null 2>&1 &&
echo "
[Manager]
DefaultTimeoutStopSec=5s
DefaultTimeoutAbortSec=5s" | tee /etc/systemd/user.conf.d/00-userd.conf &&
sed -i 's|^hosts.*|hosts: mymachines mdns_minimal resolve [!UNAVAIL=return] files myhostname dns|g' /etc/nsswitch.conf &&
sed -i 's/ interface = [^ ]*/ interface = all/g' /etc/ipp-usb/ipp-usb.conf &&
sed -i "/# set linenumbers/"'s/^#//' /etc/nanorc &&
echo tcp_bbr | tee /etc/modules-load.d/modulesd.conf &&
echo "
country=${REGDOM}
wps_cred_add_sae=1
pmf=2" | tee /etc/wpa_supplicant/wpa_supplicant.conf &&
bootctl install --graceful &&
echo "default arch.conf" > /boot/loader/loader.conf &&
echo "
title ${entrname}
linux /vmlinuz-${kernel}
initrd /initramfs-${kernel}.img
options rw ${boot_opts}" | tee /boot/loader/entries/arch.conf &&
echo root:${ROOTPASSWD2} | chpasswd &&
chsh -s /bin/zsh &&
useradd -m -G wheel,realtime -s /bin/zsh ${USERNAME} &&
echo ${USERNAME}:${USERPASSWD2} | chpasswd &&
echo "
Defaults env_reset
Defaults pwfeedback
Defaults editor=/usr/bin/nano
%wheel ALL=(ALL) ALL" | tee /etc/sudoers.d/sudoersd &&
visudo -c /etc/sudoers.d/sudoersd &&
systemctl enable avahi-daemon bluetooth cups ipp-usb NetworkManager rngd systemd-boot-update ${displaymanager} ${trim} ${vm_services}
OPTIMIZED_CONF
stage_ok
else
stage_fail
fi
if [[ "${vgaconf}" == "y" && "${vendor}" == "Nvidia" ]]; then
if [[ "${kernelnmbr}" == "1" ]] || [[ "${kernelnmbr}" == "2" && "${family}" == "1" ]] || [[ "${kernelnmbr}" == "2" && "${family}" == "2" && "${nvdriver}" == "2" ]]; then
stage_prompt="Nvidia-Hook"
if arch-chroot /mnt <<-NVIDIAHOOK ; then
mkdir -p /etc/pacman.d/hooks/ > /dev/null 2>&1 &&
echo "
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=${nvname}
Target=${kernel}
[Action]
Description=Update NVIDIA module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux*) exit 0; esac; done; /usr/bin/mkinitcpio -P' " | tee /etc/pacman.d/hooks/nvidia.hook
NVIDIAHOOK
stage_ok
else
stage_fail
fi
fi
fi
completion
fi
#------------------------------------------------------------------------------------------
# NOTE: Custom System Configuration (Add any extra configuration below):
if [[ "${packages}" == "12" ]]; then
stage_prompt="Base System"
if arch-chroot /mnt <<-CUSTOM_CONF ; then
sed -i "/^#${SETLOCALE}/s/^#//" /etc/locale.gen &&
locale-gen &&
echo LANG=${SETLOCALE} > /etc/locale.conf &&
export LANG=${SETLOCALE} &&
echo KEYMAP=${SETKBD} > /etc/vconsole.conf &&
echo "
${mkinitcpio_mods}
${mkinitcpio_hooks}" | tee /etc/mkinitcpio.conf.d/mkinitcpiod.conf &&
mkinitcpio -P &&
ln -sf /usr/share/zoneinfo/$(curl -s http://ip-api.com/line?fields=timezone) /etc/localtime &&
hwclock --systohc &&
echo ${HOSTNAME} > /etc/hostname &&
echo "
127.0.0.1 localhost
::1 localhost
127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}" >> /etc/hosts &&
echo root:${ROOTPASSWD2} | chpasswd &&
useradd -m -G wheel -s /bin/bash ${USERNAME} &&
echo ${USERNAME}:${USERPASSWD2} | chpasswd &&
echo "
%wheel ALL=(ALL) ALL" | tee /etc/sudoers.d/sudoersd &&
visudo -c /etc/sudoers.d/sudoersd
CUSTOM_CONF
stage_ok
else
stage_fail
fi
if [[ -f /mnt/etc/lightdm/lightdm.conf ]]; then
if [[ "${greeternmbr}" == "1" ]]; then
stage_prompt="GTK Greeter"
if arch-chroot /mnt <<-GTK ; then
sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-gtk-greeter|g' /etc/lightdm/lightdm.conf
GTK
stage_ok
else
stage_fail
fi
elif [[ "${greeternmbr}" == "2" ]]; then
stage_prompt="Slick Greeter"
if arch-chroot /mnt <<-SLICK ; then
sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-slick-greeter|g' /etc/lightdm/lightdm.conf
SLICK
stage_ok
else
stage_fail
fi
fi
fi
if [[ "${bootloader}" == "1" ]]; then
stage_prompt="Systemd-boot"
if arch-chroot /mnt <<-BOOTCTL ; then
bootctl install --graceful &&
echo "default arch.conf" > /boot/loader/loader.conf &&
echo "
title ${entrname}
linux /vmlinuz-${kernel}
initrd /initramfs-${kernel}.img
options rw ${boot_opts}" | tee /boot/loader/entries/arch.conf &&
systemctl enable systemd-boot-update ${customservices} ${trim} ${vm_services}
BOOTCTL
stage_ok
else
stage_fail
fi
elif [[ "${bootloader}" == "2" ]]; then
stage_prompt="Grub"
if arch-chroot /mnt <<-GRUB ; then
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB &&
sed -i \
-e 's|^GRUB_CMDLINE_LINUX_DEFAULT.*|GRUB_CMDLINE_LINUX_DEFAULT="${boot_opts}"|g' \
-e "/^#GRUB_DISABLE_OS_PROBER=false/s/^#//" \
/etc/default/grub &&
grub-mkconfig -o /boot/grub/grub.cfg
GRUB
stage_ok
else
stage_fail
fi
if [[ -n "${customservices}" || -n "${trim}" || -n "${vm_services}" ]]; then
stage_prompt="Services"
if arch-chroot /mnt <<-SERVICES ; then
systemctl enable ${customservices} ${trim} ${vm_services}
SERVICES
stage_ok
else
stage_fail
fi
fi
if [[ "${bootloader}" == "2" && "${fs}" == "2" ]]; then
stage_prompt="Grub-Btrfsd"
if arch-chroot /mnt <<-GRUBBTRFSD ; then
systemctl enable grub-btrfsd
GRUBBTRFSD
stage_ok
else
stage_fail
fi
fi
if [[ "${vgaconf}" == "y" && "${vendor}" == "Nvidia" ]]; then
stage_prompt="Grub-Nvidia"
if arch-chroot /mnt <<-NVIDIAGRUB ; then
sed -i "/^#GRUB_TERMINAL_OUTPUT=console/s/^#//" /etc/default/grub &&
grub-mkconfig -o /boot/grub/grub.cfg
NVIDIAGRUB
stage_ok
else
stage_fail
fi
fi
fi
if [[ "${vgaconf}" == "y" && "${vendor}" == "Nvidia" ]]; then
if [[ "${kernelnmbr}" == "1" ]] || [[ "${kernelnmbr}" == "2" && "${family}" == "1" ]] || [[ "${kernelnmbr}" == "2" && "${family}" == "2" && "${nvdriver}" == "2" ]]; then
stage_prompt="Nvidia-Hook"
if arch-chroot /mnt <<-NVIDIAHOOK ; then
mkdir -p /etc/pacman.d/hooks/ > /dev/null 2>&1 &&
echo "
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=${nvname}
Target=${kernel}
[Action]
Description=Update NVIDIA module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux*) exit 0; esac; done; /usr/bin/mkinitcpio -P' " | tee /etc/pacman.d/hooks/nvidia.hook
NVIDIAHOOK
stage_ok
else
stage_fail
fi
fi
fi
completion
fi
umount -R /mnt
exit
}
# ### END FUNCTIONS ###
###########################################################################################
run_as="$(whoami)"
tty="$(tty)"
disks="$(lsblk --nodeps --paths --noheadings --output=name,size,model | cat --number)"
SETLOCALE=""
USERNAME=""
kernelnmbr=""
fs=""
vgaconf=""
packages=""
efi_entr_del=""
wrlss_rgd=""
sanity=""
install=""
bootldr_pkgs=""
devel=""
REGDOM=""
vga_bootopts=""
btrfs_bootopts=""
trim=""
swapmode=""
homecrypt=""
greeter=""
revision=""
greeternmbr=""
cust_bootopts=""
bluetooth=""
vmpkgs=""
vm_services=""
perf_stream=""
displaymanager=""
wireless_reg=""
trg=""
s=""
clear
first_check
sleep 1
CYAN "
*********************************
### Arch Linux Installation ###
$(date)
*********************************
${bwhite}Press any key to start${nc}"
read -r -s -n 1
uefi_check
connection_check
upd_clock
dtct_microcode
until main_menu; do : ; done