#!/bin/bash # Amelia Installer # Source: https://gitlab.com/prism7/archery # Version: 1.0.12 set -euo pipefail ################################################################################################### # COLOR FUNCTIONS nc="\e[0m" red="\e[31m" cyan="\e[36m" blue="\e[94m" green="\e[32m" redl="\e[1;31m" yellow="\e[33m" cyanl="\e[1;36m" redbg="\e[1;41m" magenta="\e[35m" bwhite="\e[0;97m" cyanbg="\e[1;46m" bluebg="\e[1;44m" greenl="\e[1;32m" greenbg="\e[1;42m" yellowl="\e[1;33m" magental="\e[1;35m" magentabg="\e[1;45m" MAGENTABG() { echo -e "${magentabg} $1${nc}" ;} YELLOWL() { echo -e "${yellowl} $1${nc}" ;} GREENBG() { echo -e "${greenbg} $1${nc}" ;} MAGENTA() { echo -e "${magenta} $1${nc}" ;} YELLOW() { echo -e "${yellow} $1${nc}" ;} BLUEBG() { echo -e "${bluebg} $1${nc}" ;} CYANBG() { echo -e "${cyanbg} $1${nc}" ;} WHITEB() { echo -e "${bwhite} $1${nc}" ;} GREEN() { echo -e "${green} $1${nc}" ;} REDBG() { echo -e "${redbg} $1${nc}" ;} BLUE() { echo -e "${blue} $1${nc}" ;} CYAN() { echo -e "${cyan} $1${nc}" ;} RED() { echo -e "${red} $1${nc}" ;} NC() { echo -e "${nc} $1${nc}" ;} # END COLOR FUNCTIONS ################################################################################################### # PROMPT FUNCTIONS skip() { sleep 0.2 YELLOWL " --> Skipping.. " } reload() { sleep 0.2 NC " --> [${green}Reloading${nc}] " } alternatives() { sleep 0.2 NC " --> [${green}Providing alternatives..${nc}] " } pkg_displ() { sleep 0.2 YELLOWL " Packages to be installed${nc}: ${deskpkgs}" } deskname() { sleep 0.2 YELLOW " ### ${desktopname} has been selected " } vm() { sleep 0.2 CYAN " >> ${yellowl}Virtual Machine ${nc}detected " } invalid() { sleep 0.2 RED " -------------------------- ### ${nc}Invalid Response ${red}### --------------------------" reload } err_try() { sleep 0.2 RED " -------------------------------------------- ### ${nc}Errors occured. Please try again.. ${red}### --------------------------------------------" reload } err_abort() { sleep 0.2 RED " ------------------------ ### ${nc}Errors occured ${red}### ------------------------" failure } reboot() { if [[ "${luks_encrypt}" == "ok" ]]; then sleep 0.2 CYAN " >> ${nc}The system will now ${yellowl}reboot ${nc}for all changes to take effect " sleep 5 systemctl reboot fi } force_reboot() { sleep 0.2 CYAN " >> ${nc}A reboot is ${yellowl}mandatory ${nc}after performing LUKS encryption " sleep 5 systemctl reboot } line2() { printf '\n\n' } line3() { printf '\n\n\n' } unmount() { sleep 0.2 line2 CYAN " --------------------------- ### ${yellowl}Unmount and Retry ${nc}${cyan}### --------------------------- " reload sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Unmount Filesystems${nc} ${magenta}]${nc}-----------------------------------${magenta}### " if umount -R /mnt > "${void}" 2>&1 ; then sleep 0.2 NC " -------------------- ### ${green}Unmount OK ${nc}### --------------------" else sleep 0.2 RED " --------------------------- ### ${nc}Unmounting Failed ${red}### ---------------------------" failure fi } do_umount() { unmount reload } umount_manual() { unmount sleep 0.2 NC " --> [Switching to ${green}Manual Mode${nc}]" } choice() { sleep 0.2 RED " -------------------------------------------- ### ${nc}Please make a choice to continue.. ${red}### --------------------------------------------" reload } y_n() { sleep 0.2 RED " ---------------------------------------------- ### ${nc}Please type ${yellow}'y' ${nc}or ${yellow}'n' ${nc}to continue.. ${red}### ----------------------------------------------" reload } yes_no() { sleep 0.2 RED " ------------------------------------------------- ### ${nc}Please type ${yellow}'yes' ${nc}or ${yellow}'no' ${nc}to continue.. ${red}### -------------------------------------------------" reload } ok() { sleep 0.2 NC " ==> [${green}${prompt} OK${nc}] " } stage_ok() { sleep 0.2 GREEN " >> ${nc}${stage_prompt} ${green}OK " sleep 0.3 } stage_fail() { sleep 0.2 RED " >> ${bwhite}${stage_prompt} ${nc}${red}FAILED${cyan} >> ${nc}Check ${yellowl}Amelia.log ${nc}for errors " failure } completion_err() { if [[ -e /usr/bin/pv ]]; then sleep 0.2 CYAN " >> ${nc}Please complete ${bwhite}'${stage_prompt}' ${nc}to continue " | pv -qL 70 else sleep 0.2 CYAN " >> ${nc}Please complete ${bwhite}'${stage_prompt}' ${nc}to continue " fi } term_offer() { sleep 0.2 YELLOW " ### NOTE: ${desktopname} desktop lacks a native Terminal emulator by design ### You can use linux console (ctrl+alt+F'n') for shell access > Install ${nc}'gnome-terminal' ${yellow}for convenience ? [Y/n] " BLUE " Enter [Y/n]: " read -r -p " ==> " terminal terminal="${terminal:-y}" terminal="${terminal,,}" case "${terminal}" in y) sleep 0.2 NC " ==> [${green}Terminal OK${nc}] " ;; n) skip ;; *) invalid until term_offer; do : ; done ;; esac } keypress() { NC " ${bwhite}Press any key to continue${nc} " read -r -s -n 1 } amd() { line2 REDBG " ------------------------------- " REDBG " ### AMD Graphics detected ### " REDBG " ------------------------------- " NC " * ${gfxcard} " } intel() { line2 BLUEBG " --------------------------------- " BLUEBG " ### INTEL Graphics detected ### " BLUEBG " --------------------------------- " NC " * ${gfxcard} " } nvidia() { line2 GREENBG " ---------------------------------- " GREENBG " ### NVIDIA Graphics detected ### " GREENBG " ---------------------------------- " NC " * ${gfxcard} " } arch() { sleep 0.2 echo BLUEBG "************************************************************************************************* " BLUEBG " " BLUEBG " ##### Archlinux Installation ##### " BLUEBG " " BLUEBG "************************************************************************************************* " line2 } installing() { sleep 0.2 line3 MAGENTABG "------------------------------------------------------------------------------------------------- " MAGENTABG " ### Installing System ### " MAGENTABG "------------------------------------------------------------------------------------------------- " line3 } cnfg() { sleep 0.2 line3 MAGENTABG "------------------------------------------------------------------------------------------------- " MAGENTABG " ### Configuring System ### " MAGENTABG "------------------------------------------------------------------------------------------------- " MAGENTA " ... Please Wait ... " line3 } completion() { sleep 0.2 line3 GREENBG "************************************************************************************************* " GREENBG " " GREENBG " ### Installation Completed ### " GREENBG " " GREENBG "************************************************************************************************* " line3 } failure() { sleep 0.2 line3 REDBG "************************************************************************************************* " REDBG " " REDBG " ### Installation Aborted ### " REDBG " " REDBG "************************************************************************************************* " line3 umount -R /mnt > "${void}" 2>&1 if [[ "${luks_root}" == "ok" || "${luks_swap}" == "ok" || "${luks_home}" == "ok" ]] && [[ "${installation}" != "ok" ]]; then force_reboot fi exit } # END PROMPT FUNCTIONS ################################################################################################### # SYSTEM FUNCTIONS mode_check() { if [[ "${run_as}" == "root" ]]; then sleep 0.2 YELLOWL " > ${nc}Running in ${red}ROOT ${nc}mode ${yellowl}< " else sleep 0.2 YELLOWL " > ${nc}Running in ${blue}DEMO ${nc}mode ${yellowl}< " fi } ################################################################################################### set_font() { if [[ -f /usr/share/kbd/consolefonts/ter-v18b.psf.gz && -f /usr/share/kbd/consolefonts/ter-v32b.psf.gz ]]; then if [[ "${tty}" == *"tty"* && "${run_as}" == "root" ]]; then until slct_font; do : ; done else if [[ -e /usr/bin/pv ]]; then MAGENTABG " 'Terminus Font' detected ==> Log in as 'root' in a tty & re-run to enable " | pv -qL 70 echo else MAGENTABG " 'Terminus Font' detected ==> Log in as 'root' in a tty & re-run to enable " echo fi fi fi } ################################################################################################### slct_font() { NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Font Selection${nc} ${magenta}]${nc}--------------------------------------${magenta}### " YELLOW " > Select a Font: " NC " [1] Terminus Font [2] HiDPI Terminus Font " BLUE " Enter a number: " read -r -p " ==> " fontselect echo case "${fontselect}" in 1) setfont ter-v18b ;; 2) setfont ter-v32b ;; *) invalid return 1 ;; esac local prompt="Fonts" ok sleep 0.7 clear } ################################################################################################### uefi_check() { bitness="$(cat /sys/firmware/efi/fw_platform_size)" local prompt="UEFI ${bitness}-bit Mode" sleep 0.2 NC " ${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}UEFI Mode Verification${nc} ${magenta}]${nc}---------------------------------${magenta}### " if [[ "${bitness}" == "64" ]]; then uefimode="x86_64-efi" efiname="BOOTX64" ok elif [[ "${bitness}" == "32" ]]; then uefimode="i386-efi" efiname="BOOTIA32" ok else RED " -------------------------- ### ${nc}Not in UEFI Mode ${red}### --------------------------" failure fi } ################################################################################################### connection_check() { local prompt="Internet Connection" sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}Internet Connection Check${nc} ${magenta}]${nc}--------------------------------${magenta}### " if ping -c 3 archlinux.org > "${void}" 2>&1; then ok else RED " ---------------------------------------------------------------------- ### ${nc}A connection to ${yellow}'www.archlinux.org' ${nc}could not be established ${red}### ---------------------------------------------------------------------- " failure fi } ################################################################################################### upd_clock() { local prompt="System Clock" sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}System Clock Update${nc} ${magenta}]${nc}-----------------------------------${magenta}### " sleep 0.2 timedatectl [[ "${run_as}" == "root" ]] && timedatectl set-ntp true echo ok } ################################################################################################### dtct_hyper() { hypervisor="$(systemd-detect-virt)" case "${hypervisor}" in kvm) vmpkgs="spice spice-vdagent spice-protocol spice-gtk qemu-guest-agent swtpm" ;; vmware) vmpkgs="open-vm-tools" vm_services="vmtoolsd vmware-vmblock-fuse" ;; oracle) vmpkgs="virtualbox-guest-utils" ;; microsoft) vmpkgs="hyperv" vm_services="hv_kvp_daemon hv_vss_daemon" ;; esac } ################################################################################################### machine_dtct() { until dtct_hyper; do : ; done local prompt="Machine Detection" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Machine Detection${nc} ${magenta}]${nc}------------------------------------${magenta}### " CPU="$(grep -E 'vendor_id' /proc/cpuinfo)" hardw_model="$(hostnamectl | grep -E "Hardware Model:" | sed 's| Hardware Model: ||')" hardw_model_vend="$(hostnamectl | grep -E "Hardware Model:" | sed 's| Hardware Model: ||' | awk "{print \$1}")" hardw_vendor="$(hostnamectl | grep -E "Hardware Vendor" | awk "{print \$3}")" machine="$(hostnamectl | grep -Em 1 "Chassis" | awk "{print \$2}")" if [[ "${hypervisor}" != "none" ]]; then vm vendor="Virtual Machine" fi if [[ "${CPU}" == *"GenuineIntel"* ]]; then microcode="intel-ucode" nrg_plc="x86_energy_perf_policy" cpu_name="Intel" elif [[ "${CPU}" == *"AuthenticAMD"* ]]; then microcode="amd-ucode" cpu_name="AMD" fi if [[ "${hardw_model_vend}" == "${hardw_vendor}" ]]; then sleep 0.2 YELLOW " ### This system is a(n): ${hardw_model} ${machine} ### The ${cpu_name} cpu microcode will be installed " else sleep 0.2 YELLOW " ### This system is a(n): ${hardw_model} ${hardw_vendor} ${machine} ### The ${cpu_name} cpu microcode will be installed " fi ok } ################################################################################################### main_menu() { sleep 0.2 NC " ${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}Main Menu${nc} ${magenta}]${nc}----------------------------------------${magenta}### " YELLOW " > Make a selection: " if [[ -e /usr/bin/pv ]]; then CYAN " >> ${nc}Select ${bwhite}[4] ${nc}for ${yellowl}Auto-Navigation ${nc}Mode " | pv -qL 70 echo else CYAN " >> ${nc}Select ${bwhite}[4] ${nc}for ${yellowl}Auto-Navigation ${nc}Mode " echo fi NC " [1] Personalization [2] System Configuration [3] Disk Management [4] Start Installation " BLUE " Enter a number: " read -r -p " ==> " menu echo case "${menu}" in 1) until persnl_submn; do : ; done ;; 2) until sys_submn; do : ; done ;; 3) until dsks_submn; do : ; done ;; 4) until instl; do : ; done ;; "") sleep 0.2 RED " --------------------------------- ### ${nc}Please select a Submenu ${red}### ---------------------------------" reload return 1 ;; *) invalid return 1 ;; esac } ################################################################################################### persnl_submn() { sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Personalization${nc} ${magenta}]${nc}-------------------------------------${magenta}### " YELLOW " > Select a Submenu: " NC " [1] Locale & Keyboard Layout Setup [2] User, Root User & Hostname Setup [3] Shell Selection [ ] Return to Main Menu " BLUE " Enter a number: " read -r -p " ==> " persmenu echo 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 ;; 3) until slct_shell; do : ; done return 1 ;; "") until main_menu; do : ; done ;; *) invalid return 1 ;; esac } ################################################################################################### slct_locale() { local prompt="Locale Selection" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Locale Selection${nc} ${magenta}]${nc}------------------------------------${magenta}### " YELLOW " > Select your Locale ### [Enter ${nc}'l'${yellow} to list locales, then ${nc}'enter'${yellow} to search or ${nc}'q'${yellow} to quit] " CYAN " >> ${nc}Exclude ${yellowl}'.UTF_8' ${nc}suffix " BLUE " Enter your Locale ${bwhite}(empty for 'en_US')${blue}: " read -r -p " ==> " LOCALESET echo if [[ -z "${LOCALESET}" ]]; then SETLOCALE="en_US.UTF-8" sleep 0.2 YELLOW " ### en_US.UTF-8 Locale has been selected " elif [[ "${LOCALESET}" == "l" ]]; then grep -E 'UTF-8' /usr/share/i18n/SUPPORTED | less return 1 elif ! grep -q "^#\?$(sed 's/[].*[]/\\&/g' <<< "${LOCALESET}") " /usr/share/i18n/SUPPORTED; then invalid return 1 else SETLOCALE="${LOCALESET}.UTF-8" sleep 0.2 YELLOW " ### ${SETLOCALE} Locale has been selected " fi ok lcl_slct="yes" } ################################################################################################### slct_kbd() { local prompt="Keyboard Layout Selection" local stage_prompt="Setting Keyboard Layout" sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}Keyboard Layout Selection${nc} ${magenta}]${nc}--------------------------------${magenta}### " if [[ "${tty}" == *"pts"* ]]; then SETKBD="us" sleep 0.2 RED " ------------------------------------------- ### ${nc}No 'tty' (Linux console) detected ${red}### -------------------------------------------" YELLOW " ### Default Keyboard Layout ('us') selected " ok return 0 fi YELLOW " > Select your Keyboard Layout ### [Enter ${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 'us')${blue}: " read -r -p " ==> " SETKBD echo if [[ -z "${SETKBD}" ]]; then SETKBD="us" sleep 0.2 YELLOW " ### 'us' Keyboard Layout has been selected " elif [[ "${SETKBD}" == "l" ]]; then localectl list-keymaps | less return 1 elif ! localectl list-keymaps | grep -Fxq "${SETKBD}"; then invalid return 1 else sleep 0.2 YELLOW " ### ${SETKBD} Keyboard Layout has been selected " loadkeys "${SETKBD}" > "${void}" 2> "${log}" || stage_fail fi ok } ################################################################################################### user_setup() { local prompt="User Setup" sleep 0.2 NC " ${magenta}###${nc}---------------------------------------${magenta}[ ${bwhite}User Setup${nc} ${magenta}]${nc}---------------------------------------${magenta}### " BLUE " Enter a username: " read -r -p " ==> " USERNAME echo USERNAME="${USERNAME,,}" if [[ -z "${USERNAME}" ]]; then sleep 0.2 RED " --------------------------------------------- ### ${nc}Please enter a username to continue ${red}### ---------------------------------------------" reload return 1 elif [[ "${USERNAME}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]; then BLUE " Enter a password for${nc} ${cyan}${USERNAME}${blue}: " read -r -p " ==> " USERPASSWD echo if [[ -z "${USERPASSWD}" ]]; then sleep 0.2 RED " --------------------------------------------- ### ${nc}Please enter a password to continue ${red}### ---------------------------------------------" reload return 1 fi BLUE " Re-enter${nc} ${cyan}${USERNAME}'s ${blue}password: " read -r -p " ==> " USERPASSWD2 echo if [[ "${USERPASSWD}" != "${USERPASSWD2}" ]]; then sleep 0.2 RED " --------------------------------------------------- ### ${nc}Passwords don't match. Please try again.. ${red}### ---------------------------------------------------" reload return 1 fi else sleep 0.2 RED " --------------------------------------------------- ### ${nc}Please enter a valid username to continue ${red}### ---------------------------------------------------" reload return 1 fi ok } ################################################################################################### rootuser_setup() { local prompt="Root User Setup" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Root User Setup${nc} ${magenta}]${nc}-------------------------------------${magenta}### " BLUE " Enter a password for the${nc}${cyan} Root ${blue}user: " read -r -p " ==> " ROOTPASSWD echo if [[ -z "${ROOTPASSWD}" ]]; then sleep 0.2 RED " --------------------------------------------------------------- ### ${nc}Please enter a password for the Root user to continue ${red}### ---------------------------------------------------------------" 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.2 RED " --------------------------------------------------- ### ${nc}Passwords don't match. Please try again.. ${red}### ---------------------------------------------------" reload return 1 fi ok } ################################################################################################### slct_hostname() { local prompt="Hostname Setup" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Hostname Setup${nc} ${magenta}]${nc}-------------------------------------${magenta}### " BLUE " Enter a hostname: " read -r -p " ==> " HOSTNAME echo if [[ -z "${HOSTNAME}" ]]; then sleep 0.2 RED " --------------------------------------------- ### ${nc}Please enter a hostname to continue ${red}### ---------------------------------------------" reload return 1 elif [[ "${HOSTNAME}" =~ [[:upper:]] ]]; then sleep 0.2 RED " ---------------------------------------------------- ### ${nc}Lowercase is preferred. Please try again.. ${red}### ----------------------------------------------------" reload return 1 fi ok } ################################################################################################### slct_shell() { local prompt="Shell Selection" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Shell Selection${nc} ${magenta}]${nc}-------------------------------------${magenta}### " YELLOW " > Select a Shell: " NC " [1] Bash [2] Zsh [3] Fish " BLUE " Enter a number: " read -r -p " ==> " shellnmbr echo case "${shellnmbr}" in 1) shell="" shellname="bash" shellname2="Bash" shell_pkgs="bash-completion powerline powerline-fonts" ;; 2) shell="zsh" shellname="zsh" shellname2="Zsh" shell_pkgs="powerline powerline-fonts zsh-autocomplete zsh-autosuggestions zsh-completions zsh-syntax-highlighting" ;; 3) shell="fish" shellname="fish" shellname2="Fish" shell_pkgs="powerline powerline-fonts which" ;; "") sleep 0.2 RED " ------------------------------- ### ${nc}Please select a Shell ${red}### -------------------------------" reload return 1 ;; *) invalid return 1 ;; esac sleep 0.2 YELLOW " ### The ${shellname2} shell has been selected " ok } ################################################################################################### sys_submn() { sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}System Configuration${nc} ${magenta}]${nc}----------------------------------${magenta}### " YELLOW " > Select a Submenu: " NC " [1] Kernel, Secureboot Signing, Bootloader & ESP Mountpoint [2] Filesystem & Swap Setup [3] Graphics Setup [4] Desktop Setup [5] EFI Boot Entries Deletion [6] Optimizations [ ] Return to Main Menu " BLUE " Enter a number: " read -r -p " ==> " sysmenu echo case "${sysmenu}" in 1) until slct_krnl; do : ; done until ask_sign; do : ; done until slct_bootldr; do : ; done until slct_espmnt; do : ; done return 1 ;; 2) until slct_fs; do : ; done until slct_swap; do : ; done return 1 ;; 3) until dtct_gfx; do : ; done return 1 ;; 4) until dsktp_setup; do : ; done return 1 ;; 5) until boot_entr; do : ; done return 1 ;; 6) until optm_submn; do : ; done return 1 ;; "") until main_menu; do : ; done ;; *) invalid return 1 ;; esac } ################################################################################################### slct_krnl() { local prompt="Kernel" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Kernel Selection${nc} ${magenta}]${nc}------------------------------------${magenta}### " YELLOW " > Select a Kernel: " NC " [1] Linux [2] Linux LTS [3] Linux Hardened [4] Linux Zen " BLUE " Enter a number: " read -r -p " ==> " kernelnmbr echo case "${kernelnmbr}" in 1) kernel="linux" kernelname="Linux" ;; 2) kernel="linux-lts" kernelname="Linux LTS" ;; 3) CYAN " >> ${nc}System Hibernation is ${yellowl}not supported ${nc}by this kernel " kernel="linux-hardened" kernelname="Linux Hardened" ;; 4) kernel="linux-zen" kernelname="Linux Zen" ;; "") sleep 0.2 RED " -------------------------------- ### ${nc}Please select a Kernel ${red}### --------------------------------" reload return 1 ;; *) invalid return 1 ;; esac sleep 0.2 YELLOW " ### The ${kernelname} kernel has been selected " ok } ################################################################################################### ask_sign() { sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Secureboot Signing${nc} ${magenta}]${nc}-----------------------------------${magenta}### " YELLOW " > Sign UKI(s), Kernel & binaries for use with Secure Boot ? [y/N]" BLUE " Enter [y/N]: " read -r -p " ==> " sb_sign echo sb_sign="${sb_sign:-n}" sb_sign="${sb_sign,,}" if [[ "${sb_sign}" == "y" ]]; then local prompt="Secure Boot 'Setup' Mode Verification" SB_Status="$(bootctl status 2> "${void}" | grep -E 'Secure Boot' | awk "{print \$4}")" if [[ "${SB_Status}" == "(setup)" ]]; then ok else sleep 0.2 RED " ----------------------------------------- ### ${nc}Secure Boot Not in ${yellowl}'Setup' ${nc}Mode ${red}### ----------------------------------------- " failure fi sleep 0.2 YELLOW " ### 'Secure Boot Signing' has been selected " sleep 0.2 YELLOW " > Create an additional bootloader Rescue entry (for troubleshooting) ? [Y/n]" BLUE " Enter [Y/n]: " read -r -p " ==> " setrescue echo setrescue="${setrescue:-y}" setrescue="${setrescue,,}" if [[ "${setrescue}" == "y" ]]; then local prompt="Rescue Entry set" ok elif [[ "${setrescue}" == "n" ]]; then skip else y_n return 1 fi elif [[ "${sb_sign}" == "n" ]]; then skip else y_n return 1 fi local prompt="Secure Boot Signing setup" ok } ################################################################################################### slct_bootldr() { local prompt="Bootloader Selection" sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Bootloader Selection${nc} ${magenta}]${nc}----------------------------------${magenta}### " YELLOW " > Select a Bootloader: " NC " [1] Systemd-boot [2] Grub " BLUE " Enter a number: " read -r -p " ==> " bootloader echo case "${bootloader}" in 1) uki="y" ukify="systemd-ukify" sleep 0.2 YELLOW " ### Systemd-boot has been selected " ;; 2) uki="n" sleep 0.2 YELLOW " > Select a Boot Path to install to: " NC " [1] Standard Path [2] Fallback Path -- for Removable Devices (recommended) " BLUE " Enter a number: " read -r -p " ==> " path echo case "${path}" in 1) YELLOW " ### Grub (Standard Boot Path) has been selected " ;; 2) YELLOW " ### Grub (Fallback Boot Path) has been selected " ;; "") sleep 0.2 RED " ----------------------------------- ### ${nc}Please select a Boot Path ${red}### -----------------------------------" reload return 1 ;; *) invalid return 1 ;; esac ;; "") sleep 0.2 RED " ------------------------------------ ### ${nc}Please select a Bootloader ${red}### ------------------------------------" reload return 1 ;; *) invalid return 1 ;; esac ok } ################################################################################################### slct_espmnt() { local prompt="ESP Mountpoint" sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}ESP Mountpoint Selection${nc} ${magenta}]${nc}--------------------------------${magenta}### " YELLOW " > Select a Mountpoint for the ESP: " NC " [1] /mnt/efi [2] /mnt/boot " BLUE " Enter a number: " read -r -p " ==> " espmnt echo case "${espmnt}" in 1) esp_mount="/mnt/efi" btldr_esp_mount="/efi" sleep 0.2 YELLOW " ### '/mnt/efi' mountpoint has been selected " ;; 2) esp_mount="/mnt/boot" btldr_esp_mount="/boot" sleep 0.2 YELLOW " ### '/mnt/boot' mountpoint has been selected " ;; "") sleep 0.2 RED " ------------------------------------ ### ${nc}Please select a Mountpoint ${red}### ------------------------------------" reload return 1 ;; *) invalid return 1 ;; esac ok if [[ "${sanity}" == "no" ]]; then until sanity_check; do : ; done fi } ################################################################################################### slct_fs() { local prompt="Filesystem Setup" sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Filesystem Selection${nc} ${magenta}]${nc}----------------------------------${magenta}### " 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.2 YELLOW " ### NOTE: Keeping User Data on a separate /Home partition is supported > Make use of a dedicated /Home partition ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " sep_home echo sep_home="${sep_home:-n}" sep_home="${sep_home,,}" case "${sep_home}" in y) sleep 0.2 YELLOW " > Make a selection: " NC " [1] Create a /Home partition [2] Utilize a previously used unencrypted /Home partition " BLUE " Enter a number: " read -r -p " ==> " hometype echo case "${hometype}" in 1) sleep 0.2 YELLOW " ### A /Home Partition will be created " ;; 2) sleep 0.2 YELLOW " ### An existing /Home Partition will be used " ;; *) invalid return 1 ;; esac ;; n) skip ;; *) invalid return 1 ;; esac sleep 0.2 YELLOW " ### ${fsname} has been selected " ;; 2) fsname="Btrfs" fs_mod="btrfs" fstools="btrfs-progs" roottype="/@" btrfs_bootopts="rootflags=subvol=@" sleep 0.2 YELLOW " ### ${fsname} has been selected " sleep 0.2 YELLOW " > Label your Btrfs snapshots directory: " BLUE " Enter a name: " read -r -p " ==> " snapname echo if [[ -z "${snapname}" ]]; then invalid return 1 fi ;; "") sleep 0.2 RED " ------------------------------------ ### ${nc}Please select a Filesystem ${red}### ------------------------------------" reload return 1 ;; *) invalid return 1 ;; esac ok } ################################################################################################### slct_swap() { local prompt="Swap Setup" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Swap Selection${nc} ${magenta}]${nc}-------------------------------------${magenta}### " YELLOW " > Select Swap type: " NC " [1] Swap Partition [2] Swapfile [3] Zram Swap " BLUE " Enter a number ${bwhite}(empty to skip)${blue}: " read -r -p " ==> " swapmode echo case "${swapmode}" in 1) swaptype="swappart" sleep 0.2 YELLOW " ### Swap Partition has been selected " ;; 2) if [[ "${fs}" == "1" ]]; then swaptype="swapfile" elif [[ "${fs}" == "2" ]]; then swaptype="swapfile_btrfs" fi sleep 0.2 YELLOW " ### Swapfile has been selected " until set_swapsize; do : ; done ;; 3) CYAN " >> ${nc}Hibernating to Swap on Zram is ${yellowl}not supported${nc} " zram="zram-generator" YELLOW " ### Zram Swap has been selected " ;; "") sleep 0.2 YELLOW " ### No Swap will be used " skip ;; *) invalid return 1 ;; esac ok } ################################################################################################### set_swapsize() { local prompt="Swapsize" YELLOW " ### Set Swap size (integers only eg. 1,4,8,16,34) " BLUE " Enter Swap size ${bwhite}(in GB)${blue}: " read -r -p " ==> " swapsize echo if [[ -z "${swapsize}" ]]; then sleep 0.2 RED " ------------------------------------------ ### ${nc}Please enter a value to continue ${red}### ------------------------------------------" reload line2 return 1 elif [[ "${swapsize}" == [[:digit:]] ]]; then ok else sleep 0.2 RED " --------------------------------------------- ### ${nc}Please use only integers as a value ${red}### ---------------------------------------------" reload line2 return 1 fi } ################################################################################################### dtct_gfx() { gfx_slct="yes" if [[ "${vendor}" == "Virtual Machine" ]]; then vm skip return 0 fi sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Graphics Setup${nc} ${magenta}]${nc}-------------------------------------${magenta}### " gfxcount="$(lspci | grep -E -c 'VGA|Display|3D')" gfxcard="$(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]//')" if [[ "${gfxcount}" == "1" ]]; then dtct_single_gfx else dtct_multi_gfx fi } ################################################################################################### dtct_single_gfx() { if [[ "${intelcount}" -eq "1" ]]; then vendor="Intel" sourcetype="Open-source" sleep 0.2 intel elif [[ "${amdcount}" -eq "1" ]]; then vendor="AMD" sourcetype="Open-source" sleep 0.2 amd elif [[ "${nvidiacount}" -eq "1" ]]; then vendor="Nvidia" nvidia sleep 0.2 CYAN " ### ${yellowl}Nvidia: ${nc}ONLY 'Maxwell' (NV110) or newer graphics are supported ${cyan} ### ${nc}Selecting ${yellowl}(n)o ${nc}defaults to the open-source ${yellowl}'nouveau' " YELLOW " > Install proprietary Nvidia drivers ? [Y/n] " BLUE " Enter [Y/n]: " read -r -p " ==> " nvdprop nvdprop="${nvdprop:-y}" nvdprop="${nvdprop,,}" if [[ "${nvdprop}" == "y" ]]; then sourcetype="Proprietary" elif [[ "${nvdprop}" == "n" ]]; then sourcetype="Open-source" skip elif [[ ! "${nvdprop}" =~ ^(y|n)$ ]]; then invalid return 1 fi fi gfx_conf } ################################################################################################### dtct_multi_gfx() { sleep 0.2 YELLOW " ### Multi Graphics Setup detected, consisting of: " NC " ____________________________________________________________________" if [[ "${intelcount}" -ge "1" ]]; then echo BLUEBG " ------------------------------- " BLUEBG " [${intelcount}] Intel Graphics device(s) " BLUEBG " ------------------------------- " NC " ${intelcards} ____________________________________________________________________" fi if [[ "${amdcount}" -ge "1" ]]; then echo REDBG " ------------------------------- " REDBG " [${amdcount}] AMD Graphics device(s) " REDBG " ------------------------------- " NC " ${amdcards} ____________________________________________________________________" fi if [[ "${nvidiacount}" -ge "1" ]]; then echo GREENBG " ------------------------------- " GREENBG " [${nvidiacount}] Nvidia Graphics device(s) " GREENBG " ------------------------------- " NC " ${nvidiacards} ${cyan}### ${yellowl}Nvidia: ${nc}ONLY 'Maxwell' (NV110) or newer graphics are supported ${cyan} ### ${nc}Selecting ${yellowl}(n)o ${nc}defaults to the open-source ${yellowl}'nouveau' ${nc}driver ____________________________________________________________________" YELLOW " > Install proprietary Nvidia drivers ? [Y/n] " BLUE " Enter [Y/n]: " read -r -p " ==> " nvdprop nvdprop="${nvdprop:-y}" nvdprop="${nvdprop,,}" if [[ "${nvdprop}" == "n" ]]; then skip elif [[ ! "${nvdprop}" =~ ^(y|n)$ ]]; then invalid return 1 fi fi multivendors=() multisourcetype=() if [[ "${intelcount}" -ge "1" ]]; then multivendors+=(Intel) multisourcetype+=(Open-source) fi if [[ "${amdcount}" -ge "1" ]]; then multivendors+=(AMD) multisourcetype+=(Open-source) fi if [[ "${nvidiacount}" -ge "1" ]]; then multivendors+=(Nvidia) if [[ "${nvdprop}" == "y" ]]; then multisourcetype+=(Proprietary) else multisourcetype+=(Open-source) fi fi vendors="${multivendors[*]}" sourcetype="${multisourcetype[*]}" if [[ "${sourcetype}" =~ "Open-source" && "${sourcetype}" =~ "Proprietary" ]]; then sourcetype="Open-source & Proprietary" elif [[ "${sourcetype}" =~ "Open-source" ]]; then sourcetype="Open-source" elif [[ "${sourcetype}" =~ "Proprietary" ]]; then sourcetype="Proprietary" fi gfx_conf } ################################################################################################### gfx_conf() { sleep 0.2 YELLOW " ### ${sourcetype} drivers will be used " if [[ "${vendor}" == "AMD" || "${vendors}" =~ "AMD" ]]; then sleep 0.2 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 case "${islands}" in 1) sleep 0.2 NC " ==> [${green}Southern Islands OK${nc}] " ;; 2) sleep 0.2 NC " ==> [${green}Sea Islands OK${nc}] " ;; "") skip echo ;; *) invalid return 1 ;; esac fi if [[ "${nvdprop}" == "y" ]]; then sleep 0.2 YELLOW " > Select Nvidia architecture: " NC " [1] Turing (NV160) Graphics or newer [Nvidia Open] [2] Maxwell (NV110) Graphics or newer [Nvidia / Disabling GSP Firmware available] " BLUE " Enter a number: " read -r -p " ==> " family case "${family}" in 1) # Turing+ Family sleep 0.2 NC " ==> [${green}Turing+ OK${nc}] " ;; 2) # Maxwell+ Family sleep 0.2 NC " ==> [${green}Maxwell+ OK${nc}] " local prompt="GSP Firmware Disabled" sleep 0.2 YELLOW " > Disable 'GSP' firmware (for troubleshooting) ? [y/n] " BLUE " Enter [y/n]: " read -r -p " ==> " nogsp if [[ "${nogsp}" == "n" ]]; then skip echo elif [[ "${nogsp}" == "y" ]]; then ok echo else y_n return 1 fi ;; "") choice return 1 ;; *) invalid return 1 ;; esac local prompt="Low Latency Display Interrupts enabled" sleep 0.2 YELLOW " > Enable Low Latency Display Interrupts (experimental) ? [Y/n] " BLUE " Enter [Y/n]: " read -r -p " ==> " lowlat lowlat="${lowlat:-y}" lowlat="${lowlat,,}" if [[ "${lowlat}" == "n" ]]; then skip echo elif [[ "${lowlat}" == "y" ]]; then ok echo else y_n return 1 fi fi sleep 0.2 YELLOW " ### Graphics will be automatically configured " local prompt="Graphics Setup" ok if [[ "${install}" == "yes" ]]; then keypress fi } ################################################################################################### gfxpkgs_set() { # Graphics packages gfxpkgs=() # Intel Graphics if [[ "${vendor}" == "Intel" || "${vendors}" =~ "Intel" ]]; then # /etc/sysctl.d/99-sysctld.conf perf_stream="dev.i915.perf_stream_paranoid = 0" gfxpkgs+=(intel-compute-runtime intel-media-driver intel-media-sdk libva-intel-driver libva-utils libvpl opencl-headers vpl-gpu-rt vkd3d vulkan-intel vulkan-mesa-layers) fi # AMD Graphics if [[ "${vendor}" == "AMD" || "${vendors}" =~ "AMD" ]]; then gfxpkgs+=(libva-mesa-driver mesa-utils mesa-vdpau opencl-headers rocm-opencl-runtime vkd3d vulkan-mesa-layers vulkan-radeon) fi # Nvidia Graphics if [[ "${nvdprop}" == "y" ]]; then # Swap partition|swapfile|zram-swap = yes if [[ "${swapmode}" =~ ^(1|2|3)$ ]]; then sleep 0.2 NC " ----------------------------------------------------------------${cyan} ### ${yellowl}INFO: ${nc}When Hibernating ${cyan}### ### ${nc}Nvidia's ${yellowl}'Preserve Video Memory after suspend' ${nc}feature ${cyan}### ### ${nc}is incompatible with ${yellowl}'Early KMS' ${nc}use ${cyan}###${nc} ----------------------------------------------------------------" keypress fi gfxpkgs=(libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d) # Turing+ GPUs if [[ "${family}" == "1" ]]; then # Linux Kernel if [[ "${kernelnmbr}" == "1" ]]; then nvname="nvidia-open" gfxpkgs+=(nvidia-open) # Linux LTS Kernel elif [[ "${kernelnmbr}" == "2" ]]; then nvname="nvidia-open-lts" gfxpkgs+=(nvidia-open-lts) # Other Kernels else gfxpkgs+=(nvidia-open-dkms) fi # Maxwell+ GPUs elif [[ "${family}" == "2" ]]; then # Linux Kernel if [[ "${kernelnmbr}" == "1" ]]; then nvname="nvidia" gfxpkgs+=(nvidia) # Linux LTS Kernel elif [[ "${kernelnmbr}" == "2" ]]; then nvname="nvidia-lts" gfxpkgs+=(nvidia-lts) # Other Kernels else gfxpkgs+=(nvidia-dkms) fi fi elif [[ "${nvdprop}" == "n" ]]; then gfxpkgs+=(libva-mesa-driver vulkan-nouveau) fi } ################################################################################################### dsktp_setup() { sleep 0.2 NC " ${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}Desktop Setup${nc} ${magenta}]${nc}--------------------------------------${magenta}### " sleep 0.2 YELLOW " > Make a selection: " NC " [1] Desktop Selection [2] Arch 'base-devel' Meta-package [3] Web browser Selection [4] Printer & Scanner Support [ ] Return to System Configuration " BLUE " Enter a number: " read -r -p " ==> " desk_setup case "${desk_setup}" in 1) until dsktp_slct; do : ; done return 1 ;; 2) until base_devel; do : ; done return 1 ;; 3) until web_browser; do : ; done return 1 ;; 4) until print_scan; do : ; done return 1 ;; "") until sys_submn; do : ; done ;; *) invalid return 1 ;; esac } ################################################################################################### dsktp_slct() { sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Desktop Selection${nc} ${magenta}]${nc}------------------------------------${magenta}### " deskpkgs="" custompkgs="" terminal="" local prompt="Desktop Selection" sleep 0.2 YELLOW " > Make a selection: " NC " [1] Plasma [2] Plasma Lite [3] Gnome [4] Gnome Lite [5] Xfce [6] Cinnamon [7] Deepin [8] Budgie [9] Lxqt [10] Mate [11] Basic Arch Linux (No GUI) [12] Custom Arch Linux [13] Cosmic ${red}## ${yellow}Beta ${red}## " BLUE " Enter a number: " read -r -p " ==> " desktop echo case "${desktop}" in 1) desktopname="Plasma" deskname ;; 2) desktopname="Plasma Lite" deskname ;; 3) desktopname="Gnome" deskname ;; 4) desktopname="Gnome Lite" deskname ;; 5) desktopname="Xfce" deskname ;; 6) desktopname="Cinnamon" deskname term_offer ;; 7) desktopname="Deepin" deskname ;; 8) desktopname="Budgie" deskname term_offer ;; 9) desktopname="Lxqt" deskname ;; 10) desktopname="Mate" deskname ;; 11) desktopname="Basic Arch Linux" deskname ;; 12) desktopname="Custom Arch Linux" until cust_sys; do :; done return 0 ;; 13) desktopname="Cosmic" deskname ;; "") choice return 1 ;; *) invalid return 1 ;; esac ok if [[ -n "${web}" && "${desktop}" =~ ^(11|12)$ ]]; then until web_browser; do : ; done fi if [[ "${printer}" == "y" && "${desktop}" =~ ^(11|12)$ ]]; then until print_scan; do : ; done fi } ################################################################################################### cust_sys() { local prompt="Custom Arch Linux" until add_pkgs; do : ; done until add_services; do : ; done echo ok } ################################################################################################### add_pkgs() { local prompt="Add Packages" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Add Your Packages${nc} ${magenta}]${nc}------------------------------------${magenta}### " 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.2 RED " --------------------------------------------- ### ${nc}Please enter package(s) to continue ${red}### ---------------------------------------------" reload return 1 elif [[ "${custompkgs}" =~ "lightdm" ]]; then sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}LightDM Greeter Selection${nc} ${magenta}]${nc}--------------------------------${magenta}### " YELLOW " > Select a Greeter: " NC " [1] Gtk [2] Slick [3] Deepin " BLUE " Enter a number: " read -r -p " ==> " greeternmbr case "${greeternmbr}" in 1) greeter="lightdm-gtk-greeter" sleep 0.2 NC " ==> [${green}Lightdm Gtk Greeter OK${nc}] " ;; 2) greeter="lightdm-slick-greeter" sleep 0.2 NC " ==> [${green}Lightdm Slick Greeter OK${nc}] " ;; 3) greeter="lightdm-deepin-greeter" sleep 0.2 NC " ==> [${green}Lightdm Deepin Greeter OK${nc}] " ;; "") choice return 1 ;; *) invalid return 1 ;; esac ok else ok fi } ################################################################################################### add_services() { local prompt="Add Services" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Add Your Services${nc} ${magenta}]${nc}------------------------------------${magenta}### " YELLOW " ### Empty to skip " BLUE " Enter services to be enabled ${bwhite}(space-seperated)${blue}: " read -r -p " ==> " customservices if [[ -z "${customservices}" ]]; then skip else ok fi } ################################################################################################### base_devel() { sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}'base-devel' Meta-package${nc} ${magenta}]${nc}--------------------------------${magenta}### " local prompt="'base-devel'" sleep 0.2 YELLOW " ### NOTE: The '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 echo dev="${dev:-n}" dev="${dev,,}" case "${dev}" in y) devel="base-devel" YELLOW " ### The 'base-devel' meta-package will be installed " ;; n) skip ;; *) invalid return 1 ;; esac ok } ################################################################################################### web_browser() { sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Web browser Selection${nc} ${magenta}]${nc}----------------------------------${magenta}### " if [[ ! "${desktop}" =~ ^(11|12)$ && -n "${desktop}" ]]; then local prompt="Web Browser" sleep 0.2 YELLOW " ### Web Browser support is available > Select Web Browser to install " NC " [1] Firefox [2] Chromium [3] Vivaldi [4] Brave Browser [5] Microsoft Edge [6] Zen Browser [7] Opera [8] Google Chrome " BLUE " Enter a number ${bwhite}(empty to skip)${blue}: " read -r -p " ==> " web echo case "${web}" in 1) web_pkg="firefox" web_name="Firefox" ;; 2) web_pkg="chromium" web_name="Chromium" ;; 3) web_pkg="vivaldi" web_name="Vivaldi" ;; 4) web_aur="brave-bin" web_name="Brave Browser" ;; 5) web_aur="microsoft-edge-stable-bin" web_name="Microsoft Edge" ;; 6) web_aur="zen-browser-bin" web_name="Zen Browser" ;; 7) web_aur="opera" web_name="Opera" ;; 8) web_aur="google-chrome" web_name="Google Chrome" ;; "") web_pkg="" web_aur="" web_name="" web_slct="yes" skip ok ;; *) invalid return 1 ;; esac else sleep 0.2 RED " ----------------------------------------- ### ${nc}Incompatible Selection detected ${red}### -----------------------------------------" sleep 0.2 YELLOW " ### Basic Arch Linux / Custom Arch Linux detected or No Desktop selected yet ### No Browser selected " web_pkg="" web_aur="" web_name="" web_slct="" skip keypress fi if [[ "${web}" =~ ^(1|2|3|4|5|6|7|8)$ ]]; then local prompt="${web_name}" web_slct="yes" ok fi } ################################################################################################### print_scan() { sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}Printer & Scanner Support${nc} ${magenta}]${nc}--------------------------------${magenta}### " local prompt="Printer & Scanner Support" if [[ "${vendor}" != "Virtual Machine" ]]; then if [[ ! "${desktop}" =~ ^(11|12)$ && -n "${desktop}" ]]; then sleep 0.2 YELLOW " ### Printer & Scanner support is available > Enable Printer & Scanner support ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " printer echo printer="${printer:-n}" printer="${printer,,}" case "${printer}" in y) if [[ "${desktop}" == "2" ]]; then print_pkgs="bluez-cups cups-pdf cups-browsed cups-pk-helper foomatic-db-gutenprint-ppds gutenprint ipp-usb libusb nss-mdns sane-airscan print-manager skanlite system-config-printer xdg-utils colord" elif [[ "${desktop}" == "4" ]]; then print_pkgs="bluez-cups cups-pdf cups-browsed cups-pk-helper foomatic-db-gutenprint-ppds gutenprint ipp-usb libusb nss-mdns sane-airscan simple-scan system-config-printer xdg-utils colord" else print_pkgs="bluez-cups cups-pdf cups-browsed cups-pk-helper foomatic-db-gutenprint-ppds gutenprint ipp-usb libusb nss-mdns sane-airscan system-config-printer xdg-utils colord" fi ;; n) print_pkgs="" skip ;; *) invalid return 1 ;; esac ok else sleep 0.2 RED " ----------------------------------------- ### ${nc}Incompatible Selection detected ${red}### -----------------------------------------" sleep 0.2 YELLOW " ### Basic Arch Linux / Custom Arch Linux detected or No Desktop selected yet ### Printer/Scanner support not enabled " print_pkgs="" skip ok keypress fi else echo vm print_pkgs="" skip ok fi } ################################################################################################### boot_entr() { if [[ "${vendor}" == "Virtual Machine" ]]; then efi_entr_del="yes" vm skip return 0 fi local prompt="Boot Entries" sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}EFI Boot Entries Deletion${nc} ${magenta}]${nc}--------------------------------${magenta}### " YELLOW " > Select an EFI Boot Entry to Delete ${red}[!] (CAUTION) [!] " sleep 0.2 efibootmgr --unicode entrnmbr="$(efibootmgr --unicode | grep -E 'BootOrder' | awk "{print \$2}")" boot_entry=" " while [[ -n "${boot_entry}" ]]; do BLUE " Enter a Boot Entry number for Deletion ${bwhite}(empty to skip)${blue}: ${cyan}Entries: ${yellowl}${entrnmbr} " read -r -p " ==> " boot_entry echo if [[ -n "${boot_entry}" ]]; then if [[ "${run_as}" != "root" ]]; then sleep 0.2 RED " ----------------------------------- ### ${nc}Root Privileges Missing.. ${red}### ----------------------------------- " reload until sys_submn; do : ; done fi if efibootmgr -b "${boot_entry}" -B --unicode; then sleep 0.2 NC " ==> [${green}Entry ${boot_entry} Deleted${nc}] " else err_try return 1 fi else skip ok fi done efi_entr_del="yes" } ################################################################################################### optm_submn() { sleep 0.2 NC " ${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}Optimizations${nc} ${magenta}]${nc}--------------------------------------${magenta}### " sleep 0.2 YELLOW " > Make a selection: " NC " [1] Custom Kernel Parameters [2] System Watchdogs [3] General System Optimizations [4] Wireless Regulatory Domain [5] Systemd-oomd [6] Irqbalance [7] Thermald [8] Rng-tools [9] Rtkit [10] Tlp [ ] Return to System Configuration " BLUE " Enter a number: " read -r -p " ==> " set_optm case "${set_optm}" in 1) until cust_kern_param; do : ; done return 1 ;; 2) until sys_watchdog; do : ; done return 1 ;; 3) until gen_optm; do : ; done return 1 ;; 4) until ask_wireless_regdom; do : ; done return 1 ;; 5) until systemd_oomd; do : ; done return 1 ;; 6) until irqbalance; do : ; done return 1 ;; 7) until thermald; do : ; done return 1 ;; 8) until rngd; do : ; done return 1 ;; 9) until rtkit; do : ; done return 1 ;; 10) until tlp; do : ; done return 1 ;; "") until sys_submn; do : ; done ;; *) invalid return 1 ;; esac } ################################################################################################### ask_optm() { local prompt="Optimizations" sleep 0.2 YELLOW " > Display available Optimizations ? [y/N]" BLUE " Enter [y/N]: " read -r -p " ==> " askoptm echo askoptm="${askoptm:-n}" askoptm="${askoptm,,}" if [[ "${askoptm}" == "n" ]]; then skip ok elif [[ "${askoptm}" == "y" ]]; then return 0 else invalid return 1 fi } ################################################################################################### cust_kern_param() { sleep 0.2 local prompt="Custom Kernel Parameters" NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}Custom Kernel Parameters${nc} ${magenta}]${nc}--------------------------------${magenta}### " sleep 0.2 YELLOW " ### Custom Kernel Parameters can be set at boot time > Enter your own additional Kernel Parameters to be added to the Kernel Cmdline ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " ask_param echo ask_param="${ask_param:-n}" ask_param="${ask_param,,}" case "${ask_param}" in y) until add_prmtrs; do : ; done ;; n) skip ok ;; *) invalid return 1 ;; esac } ################################################################################################### add_prmtrs() { local prompt="Custom Kernel Parameters" YELLOW " ### Add Your Kernel Parameters ### Empty to skip " BLUE " Enter your own Kernel parameters to be set at boot ${bwhite}(space-seperated)${blue}: " read -r -p " ==> " cust_bootopts if [[ -z "${cust_bootopts}" ]]; then skip ok else ok fi } ################################################################################################### sys_watchdog() { sleep 0.2 local prompt="System Watchdogs" NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}System Watchdogs${nc} ${magenta}]${nc}------------------------------------${magenta}### " sleep 0.2 YELLOW " ### A watchdog is a hardware or software component that keeps track of a system's performance ### and intervenes if it notices any strange behaviour or malfunctions ### [Applicable for non mission-critical platforms such as desktops & laptops] > Disable Watchdogs in the installed system ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " kill_watchdog echo kill_watchdog="${kill_watchdog:-n}" kill_watchdog="${kill_watchdog,,}" case "${kill_watchdog}" in y) YELLOW " ### Watchdogs will be disabled " ;; n) skip ;; *) invalid return 1 ;; esac ok } ################################################################################################### gen_optm() { sleep 0.2 local prompt="System Optimizations" NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}General Optimizations${nc} ${magenta}]${nc}----------------------------------${magenta}### " sleep 0.2 YELLOW " ### General System Optimizations are available ### Type ${nc}'v' ${yellow}to view a summary > Enable System Optimizations ? [v/y/N] " BLUE " Enter [v/y/N]: " read -r -p " ==> " genoptm echo genoptm="${genoptm:-n}" genoptm="${genoptm,,}" case "${genoptm}" in y) YELLOW " ### System Optimizations will be set " ;; n) skip ;; v) view_optm return 1 ;; *) invalid return 1 ;; esac ok } ################################################################################################### ask_wireless_regdom() { if [[ "${vendor}" == "Virtual Machine" ]]; then vm skip return 0 fi local prompt="Wireless Regdom Setup" sleep 0.2 NC " ${magenta}###${nc}----------------------------${magenta}[ ${bwhite}Wireless Regulatory Domain Setup${nc} ${magenta}]${nc}----------------------------${magenta}### " YELLOW " ### The regulatory domain is used to reconfigure wireless drivers, to make sure that wireless ### hardware usage complies with local laws set by the FCC, ETSI and other organizations > Select your Country Code (e.g. US) ### [Enter ${nc}'l'${yellow} to list country codes, then ${nc}'enter'${yellow} to search or ${nc}'q'${yellow} to quit] " BLUE " Enter your Country Code, ie:${nc} ${cyan}US ${bwhite}(empty to skip)${blue}: " read -r -p " ==> " REGDOM echo REGDOM="${REGDOM^^}" if [[ -z "${REGDOM}" ]]; then skip elif [[ "${REGDOM}" == "L" ]]; then sed 's|^#WIRELESS_REGDOM=||g' /etc/conf.d/wireless-regdom | sed 's|"||g'| less return 1 elif ! grep \""${REGDOM}"\" /etc/conf.d/wireless-regdom > "${void}" 2>&1 ; then invalid return 1 else wireless_reg="wireless-regdb" sleep 0.2 YELLOW " ### ${REGDOM} Country Code has been selected " fi ok } ################################################################################################### systemd_oomd() { local prompt="Systemd-oomd Setup" sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Systemd-oomd Setup${nc} ${magenta}]${nc}-----------------------------------${magenta}### " sleep 0.2 YELLOW " ### A system service that uses cgroups-v2 and pressure stall information (PSI) ### to monitor system and take corrective action before an 'OOM' occurs in the kernel space > Enable 'systemd-oomd' ? [y/N] " CYAN " >> ${nc}Swapping enabled is ${yellowl}highly recommended ${nc}for optimal performance " BLUE " Enter [y/N]: " read -r -p " ==> " oomd echo oomd="${oomd:-n}" oomd="${oomd,,}" if [[ "${oomd}" == "y" ]]; then YELLOW " ### 'Systemd-oomd' service will be enabled " elif [[ "${oomd}" == "n" ]]; then skip else invalid return 1 fi ok } ################################################################################################### irqbalance() { local prompt="Irqbalance Setup" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Irqbalance Setup${nc} ${magenta}]${nc}------------------------------------${magenta}### " sleep 0.2 YELLOW " ### Distributes hardware interrupts across processors on a multiprocessor system ### in order to increase performance > Install & enable 'irqbalance' ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " irqbalance echo irqbalance="${irqbalance:-n}" irqbalance="${irqbalance,,}" if [[ "${irqbalance}" == "y" ]]; then YELLOW " ### 'irqbalance' service will be enabled " elif [[ "${irqbalance}" == "n" ]]; then skip else invalid return 1 fi ok } ################################################################################################### thermald() { local prompt="Thermald Setup" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Thermald Setup${nc} ${magenta}]${nc}-------------------------------------${magenta}### " sleep 0.2 YELLOW " ### A Linux daemon used to prevent the overheating of platforms ### This daemon monitors temperature and applies compensation using available cooling methods > Install & enable 'thermald' ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " thermald echo thermald="${thermald:-n}" thermald="${thermald,,}" if [[ "${thermald}" == "y" ]]; then YELLOW " ### 'thermald' service will be enabled " elif [[ "${thermald}" == "n" ]]; then skip else invalid return 1 fi ok } ################################################################################################### rngd() { local prompt="Rng-tools Setup" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Rng-tools Setup${nc} ${magenta}]${nc}-------------------------------------${magenta}### " sleep 0.2 YELLOW " ### The rngd daemon is capable of using both environmental noise ### and hardware random number generators for extracting entropy > Install & enable 'rngd' ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " rngd echo rngd="${rngd:-n}" rngd="${rngd,,}" if [[ "${rngd}" == "y" ]]; then YELLOW " ### 'rngd' service will be enabled " elif [[ "${rngd}" == "n" ]]; then skip else invalid return 1 fi ok } ################################################################################################### rtkit() { local prompt="Rtkit Setup" sleep 0.2 NC " ${magenta}###${nc}---------------------------------------${magenta}[ ${bwhite}Rtkit Setup${nc} ${magenta}]${nc}---------------------------------------${magenta}### " sleep 0.2 YELLOW " ### RealtimeKit is a D-Bus system service that changes the scheduling policy ### of user processes/threads to SCHED_RR, [Realtime Scheduling Mode on request] > Install & enable 'rtkit' ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " rtkit echo rtkit="${rtkit:-n}" rtkit="${rtkit,,}" if [[ "${rtkit}" == "y" ]]; then YELLOW " ### 'rtkit' service will be enabled " elif [[ "${rtkit}" == "n" ]]; then skip else invalid return 1 fi ok } ################################################################################################### tlp() { local prompt="Tlp Setup" sleep 0.2 NC " ${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}Tlp Setup${nc} ${magenta}]${nc}----------------------------------------${magenta}### " sleep 0.2 YELLOW " ### Tlp is a laptop battery power saving utility for Linux ### working out-of-the-box & easy to further configure > Install & enable 'tlp' ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " tlp echo tlp="${tlp:-n}" tlp="${tlp,,}" if [[ "${tlp}" == "y" ]]; then YELLOW " ### 'tlp' service will be enabled " elif [[ "${tlp}" == "n" ]]; then skip else invalid return 1 fi ok } ################################################################################################### dsks_submn() { sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Disk Management${nc} ${magenta}]${nc}-------------------------------------${magenta}### " YELLOW " > Select a Submenu: " NC " [1] GPT Manager [2] Partition Manager [ ] Return to Main Menu " BLUE " Enter a number: " read -r -p " ==> " diskmenu echo case "${diskmenu}" in 1) until gpt_mngr; do : ; done ;; 2) until part_mngr; do : ; done ;; "") until main_menu; do : ; done ;; *) invalid return 1 ;; esac } ################################################################################################### gpt_mngr() { local prompt="GPT Manager" sleep 0.2 NC " ${magenta}###${nc}---------------------------------------${magenta}[ ${bwhite}GPT Manager${nc} ${magenta}]${nc}---------------------------------------${magenta}### " gpt_dsk_nmbr=" " while [[ -n "${gpt_dsk_nmbr}" ]]; do if [[ -z "${instl_drive}" ]]; then 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 echo if [[ -n "${gpt_dsk_nmbr}" ]]; then gptdrive="$(echo "${disks}" | awk "\$1 == ${gpt_dsk_nmbr} {print \$2}")" else skip ok if [[ "${install}" == "yes" ]]; then until instl_dsk; do : ; done return 0 else until dsks_submn; do : ; done return 0 fi fi fi if [[ -n "${instl_drive}" ]]; then gptdrive="${instl_drive}" fi if [[ -e "${gptdrive}" ]]; then parttable="$(fdisk -l "${gptdrive}" 2> "${void}" | grep '^Disklabel type' | awk "{print \$3}")" if [[ "${parttable}" == "gpt" ]]; then sleep 0.2 NC " --------------------- ### ${green}Disk GPT OK ${nc}### ---------------------" elif [[ "${parttable}" != "gpt" && -z "${install}" ]]; then sleep 0.2 RED " ------------------------------------------ ### ${nc}No GPT detected on selected disk ${red}### ------------------------------------------" fi if [[ "${run_as}" != "root" ]]; then sleep 0.2 RED " ----------------------------------- ### ${nc}Root Privileges Missing.. ${red}### ----------------------------------- " reload until dsks_submn; do : ; done fi YELLOW " > Make a Selection: " NC " [1] Create new GPT on selected disk [Destroy any existing GPT/MBR structures] [2] Use the 'gdisk' program interactively [Expert Mode] [ ] Return to Previous Menu " BLUE " Enter a number: " read -r -p " ==> " gptslct echo if [[ "${gptslct}" == "1" ]]; then sgdisk -Z "${gptdrive}" > "${void}" && sgdisk -o "${gptdrive}" > "${void}" && parttable="$(fdisk -l "${gptdrive}" 2> "${void}" | grep '^Disklabel type' | awk "{print \$3}")" if [[ "${parttable}" == "gpt" ]]; then multibooting="n" nowarning="y" gptok="yes" sleep 0.2 NC " ==> [${green}GPT OK${nc}] " if [[ "${install}" == "yes" ]]; then until instl_dsk; do : ; done return 0 else until dsks_submn; do : ; done return 0 fi else gptok="no" sleep 0.2 RED " ------------------------------------------ ### ${nc}No GPT detected on selected disk ${red}### ------------------------------------------" reload return 1 fi elif [[ "${gptslct}" == "2" ]]; then YELLOW " ### Type ${nc}'?'${yellow} for help, ${nc}'x'${yellow} for extra functionality or ${nc}'q'${yellow} to quit " NC " ______________________________________________ " gdisk "${gptdrive}" parttable="$(fdisk -l "${gptdrive}" 2> "${void}" | grep '^Disklabel type' | awk "{print \$3}")" if [[ "${parttable}" == "gpt" ]]; then multibooting="n" nowarning="y" gptok="yes" sleep 0.2 NC " ==> [${green}GPT OK${nc}] " if [[ "${install}" == "yes" ]]; then until instl_dsk; do : ; done return 0 else until dsks_submn; do : ; done return 0 fi else gptok="no" sleep 0.2 RED " ------------------------------------------ ### ${nc}No GPT detected on selected disk ${red}### ------------------------------------------" reload return 1 fi elif [[ -z "${gptslct}" ]]; then if [[ -n "${instl_drive}" ]]; then gptabort="yes" skip ok line2 until instl_dsk; do : ; done return 0 elif [[ -z "${instl_drive}" ]]; then reload return 1 fi else invalid return 1 fi else invalid return 1 fi done } ################################################################################################### ask_multibooting() { [[ "${multibooting}" == "n" ]] && return 0 local prompt="MultiBoot Status" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}MultiBoot Status${nc} ${magenta}]${nc}------------------------------------${magenta}### " YELLOW " > Are you Dual/Multi-Booting with other OS's ? [y/n] " YELLOW " ### ${nc}If ${bwhite}[y]es${nc} then:${cyan} >> ${nc}Your ${yellowl}EFI ${nc}System Partition (ESP) will stay ${yellowl}intact${nc}${cyan} >> ${nc}Only ${yellowl}Manual ${nc}Disk Partitioning will be available for ${yellowl}Disk Management " BLUE " Enter [y/n]: " read -r -p " ==> " multibooting multibooting="${multibooting,,}" case "${multibooting}" in y) sleep 0.2 YELLOW " ### Dual/Multi-Boot selected " ;; n) sleep 0.2 YELLOW " ### No Dual/Multi-Boot " ;; "") y_n return 1 ;; *) invalid return 1 ;; esac ok } ################################################################################################### part_mngr() { if [[ "${multibooting}" == "y" ]]; then until manual_part; do : ; done return 0 fi sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Partition Manager${nc} ${magenta}]${nc}------------------------------------${magenta}### " YELLOW " > Select a Mode: " NC " [1] Automatic Partitioning [2] Manual Partitioning " BLUE " Enter a number: " read -r -p " ==> " part_mode case "${part_mode}" in 1) until auto_part; do : ; done ;; 2) until manual_part; do : ; done ;; "") sleep 0.2 RED " ------------------------------ ### ${nc}Please select a Mode ${red}### ------------------------------" reload return 1 ;; *) invalid return 1 ;; esac } ################################################################################################### auto_part() { sleep 0.2 NC " ${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}Automatic Partitioning${nc} ${magenta}]${nc}---------------------------------${magenta}### " if [[ -e "${instl_drive}" ]]; then if [[ -z "${nowarning}" ]]; then sleep 0.2 line2 REDBG " ------------------------------------------------------------ " REDBG " [!] WARNING: All data on selected disk will be destroyed [!] " REDBG " ------------------------------------------------------------ " line2 fi sgdsk_nmbr="${instl_dsk_nmbr}" sgdrive="$(echo "${disks}" | awk "\$1 == ${sgdsk_nmbr} {print \$2}")" capacity="$(fdisk -l "${sgdrive}" | grep -E 'bytes' | grep -E 'Disk' | awk "{print \$5}")" cap_gib="$((capacity/1024000000))" rootsize="$((capacity*25/100/1024000000))" if [[ "${run_as}" != "root" ]]; then sleep 0.2 RED " ----------------------------------- ### ${nc}Root Privileges Missing.. ${red}### ----------------------------------- " reload until main_menu; do : ; done return 0 fi sleep 0.2 CYAN " >> ${nc}Apply ${yellowl}'Smart Partitioning' ${nc}on disk ${bwhite}'${instl_drive}'${nc} ? ${cyan}[Y/n] " BLUE " Enter [Y/n]: " read -r -p " ==> " smartpart echo smartpart="${smartpart:-y}" smartpart="${smartpart,,}" if [[ "${smartpart}" == "y" ]]; then until smart_presets; do : ; done until set_partsize; do : ; done until partitioner; do : ; done return 0 elif [[ "${smartpart}" == "n" ]]; then alternatives until manual_presets; do : ; done until set_partsize; do : ; done until partitioner; do : ; done return 0 else y_n return 1 fi else YELLOW " > Select a disk for Auto-Partitioning: " NC " ${disks}" BLUE " Enter a disk number ${bwhite}(empty to skip)${blue}: " read -r -p " ==> " sgdsk_nmbr echo if [[ -n "${sgdsk_nmbr}" ]]; then sgdrive="$(echo "${disks}" | awk "\$1 == ${sgdsk_nmbr} {print \$2}")" if [[ -e "${sgdrive}" ]]; then capacity="$(fdisk -l "${sgdrive}" | grep -E 'bytes' | grep -E 'Disk' | awk "{print \$5}")" cap_gib="$((capacity/1024000000))" rootsize="$((capacity*25/100/1024000000))" if [[ "${run_as}" != "root" ]]; then sleep 0.2 RED " ----------------------------------- ### ${nc}Root Privileges Missing.. ${red}### ----------------------------------- " reload until dsks_submn; do : ; done return 0 fi until manual_presets; do : ; done until set_partsize; do : ; done until partitioner; do : ; done else invalid return 1 fi else skip local prompt="Partition Manager" ok fi fi if [[ -z "${sanity}" ]]; then until dsks_submn; do : ; done return 0 fi } ################################################################################################### smart_presets() { if [[ "${fs}" == "1" ]] ; then if [[ "${sep_home}" == "y" && "${swapmode}" == "1" ]]; then preset="4" elif [[ "${sep_home}" == "y" && "${swapmode}" != "1" ]]; then preset="3" elif [[ "${sep_home}" == "n" && "${swapmode}" == "1" ]]; then preset="2" elif [[ "${sep_home}" == "n" && "${swapmode}" != "1" ]]; then preset="1" fi elif [[ "${fs}" == "2" ]]; then if [[ "${swapmode}" == "1" ]]; then preset="2" elif [[ "${swapmode}" != "1" ]]; then preset="1" fi fi } ################################################################################################### manual_presets() { preset="" sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Preset Selection${nc} ${magenta}]${nc}------------------------------------${magenta}### " if [[ -z "${nowarning}" ]]; then sleep 0.2 line2 REDBG " ------------------------------------------------------------ " REDBG " [!] WARNING: All data on selected disk will be destroyed [!] " REDBG " ------------------------------------------------------------ " line2 fi YELLOW " > Select a Partition Layout Preset: " NC " ${cyan}* Ext4${nc} compatible Layout ${magenta}* Btrfs${nc} compatible Layout [1] Create ESP & /Root (${cyan}Ext4${nc},${magenta}Btrfs${nc}) [2] Create ESP, /Root & /Swap (${cyan}Ext4${nc},${magenta}Btrfs${nc}) [3] Create ESP, /Root & /Home (${cyan}Ext4${nc}) [4] Create ESP, /Root, /Home & /Swap (${cyan}Ext4${nc}) " BLUE " Enter a Preset number ${bwhite}(empty to skip)${blue}: " read -r -p " ==> " preset echo if [[ "${preset}" =~ ^(1|2|3|4)$ ]]; then presetpart="y" return 0 elif [[ -z "${preset}" && "${partok}" == "n" ]]; then alternatives manual_part return 0 elif [[ -z "${preset}" ]]; then skip return 0 else invalid return 1 fi } ################################################################################################### set_partsize() { [[ "${partok}" == "y" ]] && return 0 if [[ "${preset}" =~ ^(3|4)$ ]]; then sleep 0.2 YELLOW " ### Total detected capacity of disk ${nc}${sgdrive} ${yellow}is ${nc}${cap_gib} GiB${yellow} ### ${nc}Default ${yellow}Root partition's size is set to aprox. ${nc}25%${yellow} of total disk capacity ### Root partition's ${nc}current ${yellow}size will be ${nc}[${rootsize} GiB]${yellow} > Adjust Root Partition's size (by setting a custom ${nc}% ${yellow}value) ? " BLUE " Enter ${nc}% ${blue}value ${nc}eg. 40 ${bwhite}(empty to skip)${blue}: " read -r -p " ==> " prcnt echo if [[ "${prcnt}" =~ [[:alpha:]] ]]; then sleep 0.2 RED " ------------------------------------------- ### ${nc}Please use only digits as a value ${red}### -------------------------------------------" reload return 1 elif [[ -z "${prcnt}" ]]; then sleep 0.2 YELLOW " ### Default Root Partition's size selected ${nc}[${rootsize} GiB] " elif [[ "${prcnt}" -gt "0" && "${prcnt}" -lt "100" ]]; then rootsize="$((capacity*"${prcnt}"/100/1024000000))" sleep 0.2 YELLOW " ### Custom Root Partition's size selected ${nc}[${rootsize} GiB] " elif [[ "${prcnt}" == "100" ]]; then sleep 0.2 RED " ----------------------------------------------------- ### ${yellow}WARNING: ${nc}No space left for other partitions ${red}### -----------------------------------------------------" reload return 1 else invalid return 1 fi fi } ################################################################################################### partitioner() { [[ "${partok}" == "y" ]] && return 0 if [[ -z "${preset}" && "${install}" == "yes" ]]; then until sanity_check; do : ; done return 0 elif [[ -z "${preset}" ]]; then local prompt="Partition Manager" ok return 0 fi if [[ "${smartpart}" == "y" ]]; then local prompt="Disk ${sgdrive} Smart-Partitioned" elif [[ "${presetpart}" == "y" ]]; then local prompt="Disk ${sgdrive} Preset-Partitioned" fi local stage_prompt="Partitioning Drive" wipefs -af "${sgdrive}" > "${void}" 2> "${log}" || stage_fail if [[ "${gptok}" != "yes" ]]; then sgdisk -Z "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -o "${sgdrive}" > "${void}" 2> "${log}" || stage_fail gptok="yes" fi if [[ "${preset}" == "1" ]]; then sgdisk -I -n1:0:+1024M -t1:ef00 -c1:ESP "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n2:0:0 -t2:8304 -c2:ROOT "${sgdrive}" > "${void}" 2> "${log}" || stage_fail partprobe -s "${sgdrive}" > "${void}" 2> "${log}" || stage_fail elif [[ "${preset}" == "2" ]]; then until set_swapsize; do : ; done sgdisk -I -n1:0:+1024M -t1:ef00 -c1:ESP "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n2:0:+"${swapsize}"G -t2:8200 -c2:SWAP "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n3:0:0 -t3:8304 -c3:ROOT "${sgdrive}" > "${void}" 2> "${log}" || stage_fail partprobe -s "${sgdrive}" > "${void}" 2> "${log}" || stage_fail elif [[ "${preset}" == "3" ]]; then sgdisk -I -n1:0:+1024M -t1:ef00 -c1:ESP "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n2:0:+"${rootsize}"G -t2:8304 -c2:ROOT "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n3:0:0 -t3:8302 -c3:HOME "${sgdrive}" > "${void}" 2> "${log}" || stage_fail partprobe -s "${sgdrive}" > "${void}" 2> "${log}" || stage_fail elif [[ "${preset}" == "4" ]]; then until set_swapsize; do : ; done sgdisk -I -n1:0:+1024M -t1:ef00 -c1:ESP "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n2:0:+"${swapsize}"G -t2:8200 -c2:SWAP "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n3:0:+"${rootsize}"G -t3:8304 -c3:ROOT "${sgdrive}" > "${void}" 2> "${log}" || stage_fail sgdisk -I -n4:0:0 -t4:8302 -c4:HOME "${sgdrive}" > "${void}" 2> "${log}" || stage_fail partprobe -s "${sgdrive}" > "${void}" 2> "${log}" || stage_fail fi if [[ "${install}" == "yes" ]]; then until sanity_check; do : ; done else ok fi } ################################################################################################### manual_part() { sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Manual Partitioning${nc} ${magenta}]${nc}-----------------------------------${magenta}### " cgdsk_nmbr=" " while [[ -n "${cgdsk_nmbr}" ]]; do line2 NC " Supported Partition Types & Mountpoints: " line3 RED " Linux Root x86-64 Partition ${nc} [ GUID Code: 8304 ] ${red}Mountpoint: ${nc}/ " echo BLUE " EFI System Partition ${nc} [ GUID Code: ef00 ] ${blue}Mountpoint: ${nc}/efi or /boot " echo GREEN " Linux Home Partition ${nc} [ GUID Code: 8302 ] ${green}Mountpoint: ${nc}/home " echo YELLOW " Linux Swap Partition ${nc} [ GUID Code: 8200 ] ${yellow}Mountpoint: ${nc}/swap " echo MAGENTA " Linux Extended Boot Partition ${nc} [ GUID Code: ea00 ] ${magenta}Mountpoint: ${nc}/boot " 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 cgdrive="$(echo "${disks}" | awk "\$1 == ${cgdsk_nmbr} {print \$2}")" if [[ -e "${cgdrive}" ]]; then local prompt="Disk ${cgdrive}" if [[ "${run_as}" != "root" ]]; then sleep 0.2 RED " ----------------------------------- ### ${nc}Root Privileges Missing.. ${red}### ----------------------------------- " reload until dsks_submn; do : ; done fi cgdisk "${cgdrive}" clear ok partprobe -s "${cgdrive}" > "${void}" else invalid return 1 fi else skip local prompt="Partition Manager" ok if [[ -z "${sanity}" ]]; then until dsks_submn; do : ; done return 0 elif [[ "${sanity}" == "no" || "${partok}" == "n" ]]; then until sanity_check; do : ; done return 0 fi fi done } ################################################################################################### instl_dsk() { if [[ ! -e "${instl_drive}" ]]; then sleep 0.2 NC " ${magenta}###${nc}-------------------------------${magenta}[ ${bwhite}Installation Disk Selection${nc} ${magenta}]${nc}-------------------------------${magenta}### " YELLOW " > Select a disk to Install to: " NC " ${disks}" BLUE " Enter a disk number: " read -r -p " ==> " instl_dsk_nmbr echo fi 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.2 RED " ----------------------------------- ### ${nc}Root Privileges Missing.. ${red}### ----------------------------------- " reload until main_menu; do : ; done return 0 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,space_cache=v2" trim="fstrim.timer" else sbvl_mnt_opts="rw,noatime,compress=zstd,space_cache=v2" fi parttable="$(fdisk -l "${instl_drive}" | grep '^Disklabel type' | awk "{print \$3}")" if [[ "${parttable}" != "gpt" && -n "${gptabort}" ]]; then sleep 0.2 RED " --------------------------------------- ### ${nc}Please create GPT to continue ${red}### ---------------------------------------" reload until gpt_mngr; do : ; done return 0 elif [[ "${parttable}" != "gpt" ]]; then sleep 0.2 RED " ------------------------------------------ ### ${nc}No GPT detected on selected disk ${red}### ------------------------------------------" reload until gpt_mngr; do : ; done return 0 fi if [[ -z "${multibooting}" ]]; then until ask_multibooting; do : ; done fi until sanity_check; do : ; done return 0 else invalid return 1 fi else sleep 0.2 RED " ----------------------------------------- ### ${nc}Please select ${yellow}Installation ${nc}Disk ${red}### -----------------------------------------" reload return 1 fi } ################################################################################################### sanity_check() { rootcount="$(fdisk -l "${instl_drive}" | grep -E -c 'root' | awk "{print \$1}")" root_dev="$(fdisk -l "${instl_drive}" | grep -E 'root' | awk "{print \$1}")" multi_root="$(fdisk -l "${instl_drive}" | grep -E 'root' | awk "{print \$1}" | cat --number)" root_comply="$(fdisk -l "${instl_drive}" | grep -E 'root' | awk "{print \$1}" | cat --number | grep -E '1[[:blank:]]' | awk "{print \$2}")" espcount="$(fdisk -l "${instl_drive}" | grep -E -c 'EFI' | awk "{print \$1}")" esp_dev="$(fdisk -l "${instl_drive}" | grep -E 'EFI' | awk "{print \$1}")" multi_esp="$(fdisk -l "${instl_drive}" | grep -E 'EFI' | awk "{print \$1}" | cat --number)" esp_comply="$(fdisk -l "${instl_drive}" | grep -E 'EFI' | awk "{print \$1}" | cat --number | grep -E '1[[:blank:]]' | awk "{print \$2}")" xbootcount="$(fdisk -l "${instl_drive}" | grep -E -c 'extended' | awk "{print \$1}")" xboot_dev="$(fdisk -l "${instl_drive}" | grep -E 'extended' | awk "{print \$1}")" multi_xboot="$(fdisk -l "${instl_drive}" | grep -E 'extended' | awk "{print \$1}" | cat --number)" xboot_comply="$(fdisk -l "${instl_drive}" | grep -E 'extended' | awk "{print \$1}" | cat --number | grep -E '1[[:blank:]]' | awk "{print \$2}")" homecount="$(fdisk -l "${instl_drive}" | grep -E -c 'home' | awk "{print \$1}")" home_dev="$(fdisk -l "${instl_drive}" | grep -E 'home' | awk "{print \$1}")" multi_home="$(fdisk -l "${instl_drive}" | grep -E 'home' | awk "{print \$1}" | cat --number)" home_comply="$(fdisk -l "${instl_drive}" | grep -E 'home' | awk "{print \$1}" | cat --number | grep -E '1[[:blank:]]' | awk "{print \$2}")" swapcount="$(fdisk -l "${instl_drive}" | grep -E -c 'swap' | awk "{print \$1}")" swap_dev="$(fdisk -l "${instl_drive}" | grep -E 'swap' | awk "{print \$1}")" multi_swap="$(fdisk -l "${instl_drive}" | grep -E 'swap' | awk "{print \$1}" | cat --number)" swap_comply="$(fdisk -l "${instl_drive}" | grep -E 'swap' | awk "{print \$1}" | cat --number | grep -E '1[[:blank:]]' | awk "{print \$2}")" rootprt="" espprt="" xbootprt="" homeprt="" swapprt="" sleep 0.2 NC " ${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}Sanity Check${nc} ${magenta}]${nc}--------------------------------------${magenta}### " [[ "${rootcount}" == "1" || "${espcount}" == "1" || "${xbootcount}" == "1" || "${homecount}" == "1" || "${swapcount}" == "1" ]] && echo if [[ "${rootcount}" -gt "1" ]]; then local stage_prompt="Selecting Partition" sleep 0.2 CYAN " >> ${nc}Multiple ${greenl}Linux x86-64 /Root ${nc}Partitions have been detected " sleep 0.2 CYAN " ###${nc}------------------------------------------------${cyan}[ ${bwhite}DISK OVERVIEW ${nc}${cyan}]${nc}------------------------------------------------${cyan}### " fdisk -l "${instl_drive}" | grep -E --color=no 'Dev|dev' |GREP_COLORS='mt=01;36' grep -E --color=always 'EFI System|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'Linux root|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'Linux home|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'Linux swap|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'Linux extended boot|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " NC " ${greenl}Linux x86-64 /Root Partitions:${nc} ------------------------------ ${multi_root} ------------------------------ " YELLOW " ### Only the ${nc}1st Linux x86-64 /Root ${yellow}partition on a selected disk can be ${nc}auto-assigned ${yellow}as a valid /Root partition${cyan} >> ${nc}Partition ${yellowl}${root_comply} ${nc}is auto-assigned as such and will be ${red}[!] ${nc}FORMATTED ${red}[!] " BLUE " > Proceed ? [Y/n]" read -r -p " ==> " autoroot autoroot="${autoroot:-y}" autoroot="${autoroot,,}" if [[ "${autoroot}" == "y" ]]; then root_dev="${root_comply}" multiroot_bootopts="root=PARTUUID=$(blkid -s PARTUUID -o value "${root_dev}")" elif [[ "${autoroot}" == "n" ]]; then until auto_part; do : ; done return 0 else y_n return 1 fi fi #------------------------------------------------------------------------------------------------------------------------------------------------------------------- if [[ "${espcount}" -gt "1" ]]; then local stage_prompt="Selecting Partition" sleep 0.2 CYAN " >> ${nc}Multiple ${cyanl}EFI System ${nc}Partitions have been detected " sleep 0.2 CYAN " ###${nc}------------------------------------------------${cyan}[ ${bwhite}DISK OVERVIEW ${nc}${cyan}]${nc}------------------------------------------------${cyan}### " fdisk -l "${instl_drive}" | grep -E --color=no 'Dev|dev' |GREP_COLORS='mt=01;36' grep -E --color=always 'EFI System|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'Linux root|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'Linux home|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'Linux swap|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'Linux extended boot|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " NC " ${cyanl}Linux EFI System Partitions:${nc} ---------------------------- ${multi_esp} ---------------------------- " YELLOW " ### Only the ${nc}1st EFI partition${yellow} on a selected disk can be ${nc}auto-assigned ${yellow}as a valid EFI partition " if [[ "${multibooting}" == "n" ]]; then CYAN " >> ${nc}Partition ${yellowl}${esp_comply} ${nc}is auto-assigned as such and will be ${red}[!] ${nc}FORMATTED ${red}[!] " elif [[ "${multibooting}" == "y" ]]; then CYAN " >> ${nc}Partition ${yellowl}${esp_comply} ${nc}is auto-assigned as such and will be used in the installation " fi BLUE " > Proceed ? [Y/n]" read -r -p " ==> " autoesp autoesp="${autoesp:-y}" autoesp="${autoesp,,}" if [[ "${autoesp}" == "y" ]]; then esp_dev="${esp_comply}" elif [[ "${autoesp}" == "n" ]]; then until auto_part; do : ; done return 0 else y_n return 1 fi fi #------------------------------------------------------------------------------------------------------------------------------------------------------------------- if [[ "${xbootcount}" -gt "1" ]]; then local stage_prompt="Selecting Partition" sleep 0.2 CYAN " >> ${nc}Multiple ${redl}Linux Extended Boot ${nc}Partitions have been detected " sleep 0.2 CYAN " ###${nc}------------------------------------------------${cyan}[ ${bwhite}DISK OVERVIEW ${nc}${cyan}]${nc}------------------------------------------------${cyan}### " fdisk -l "${instl_drive}" | grep -E --color=no 'Dev|dev' |GREP_COLORS='mt=01;36' grep -E --color=always 'EFI System|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'Linux root|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'Linux home|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'Linux swap|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'Linux extended boot|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " NC " ${redl}Linux Extended Boot Partitions:${nc} ---------------------------- ${multi_xboot} ---------------------------- " YELLOW " ### Only the ${nc}1st Linux Extended Boot ${yellow}partition on a selected disk can be ${nc}auto-assigned ${yellow}as a valid /XBOOTLDR partition${cyan} >> ${nc}Partition ${yellowl}${xboot_comply} ${nc}is auto-assigned as such and will be ${red}[!] ${nc}FORMATTED ${red}[!] " BLUE " > Proceed ? [Y/n]" read -r -p " ==> " autoxboot autoxboot="${autoxboot:-y}" autoxboot="${autoxboot,,}" if [[ "${autoxboot}" == "y" ]]; then xboot_dev="${xboot_comply}" elif [[ "${autoxboot}" == "n" ]]; then until auto_part; do : ; done return 0 else y_n return 1 fi fi #------------------------------------------------------------------------------------------------------------------------------------------------------------------- if [[ "${fs}" == "1" && "${sep_home}" == "y" && "${homecount}" -gt "1" ]]; then local stage_prompt="Selecting Partition" sleep 0.2 CYAN " >> ${nc}Multiple ${magental}Linux /Home ${nc}Partitions have been detected " sleep 0.2 CYAN " ###${nc}------------------------------------------------${cyan}[ ${bwhite}DISK OVERVIEW ${nc}${cyan}]${nc}------------------------------------------------${cyan}### " fdisk -l "${instl_drive}" | grep -E --color=no 'Dev|dev' |GREP_COLORS='mt=01;36' grep -E --color=always 'EFI System|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'Linux root|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'Linux home|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'Linux swap|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'Linux extended boot|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " NC " ${magental}Linux /Home Partitions:${nc} ----------------------- ${multi_home} ----------------------- " YELLOW " ### Only the ${nc}1st Linux /Home ${yellow}partition on a selected disk can be ${nc}auto-assigned ${yellow}as a valid /Home partition${cyan} >> ${nc}Partition ${yellowl}${home_comply} ${nc}is auto-assigned as such and will be used in the installation " BLUE " > Proceed ? [Y/n]" read -r -p " ==> " autohome autohome="${autohome:-y}" autohome="${autohome,,}" if [[ "${autohome}" == "y" ]]; then home_dev="${home_comply}" elif [[ "${autohome}" == "n" ]]; then until auto_part; do : ; done return 0 else y_n return 1 fi fi #------------------------------------------------------------------------------------------------------------------------------------------------------------------- if [[ "${swapmode}" == "1" && "${swapcount}" -gt "1" ]]; then local stage_prompt="Selecting Partition" sleep 0.2 CYAN " >> ${nc}Multiple ${yellowl}Linux /Swap ${nc}Partitions have been detected " sleep 0.2 CYAN " ###${nc}------------------------------------------------${cyan}[ ${bwhite}DISK OVERVIEW ${nc}${cyan}]${nc}------------------------------------------------${cyan}### " fdisk -l "${instl_drive}" | grep -E --color=no 'Dev|dev' |GREP_COLORS='mt=01;36' grep -E --color=always 'EFI System|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'Linux root|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'Linux home|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'Linux swap|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'Linux extended boot|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " NC " ${yellowl}Linux /Swap Partitions:${nc} ----------------------- ${multi_swap} ----------------------- " YELLOW " ### Only the ${nc}1st Linux /Swap ${yellow}partition on a selected disk can be ${nc}auto-assigned ${yellow}as a valid /Swap partition${cyan} >> ${nc}Partition ${yellowl}${swap_comply} ${nc}is auto-assigned as such and will be ${red}[!] ${nc}FORMATTED ${red}[!] " BLUE " > Proceed ? [Y/n]" read -r -p " ==> " autoswap autoswap="${autoswap:-y}" autoswap="${autoswap,,}" if [[ "${autoswap}" == "y" ]]; then swap_dev="${swap_comply}" elif [[ "${autoswap}" == "n" ]]; then until auto_part; do : ; done return 0 else y_n return 1 fi fi #------------------------------------------------------------------------------------------------------------------------------------------------------------------- if [[ -e "${root_dev}" ]]; then rootpartsize="$(lsblk -dno SIZE --bytes "${root_dev}")" if [[ "${rootpartsize}" -ge "8589934592" ]]; then rootprt="ok" else rootprt="ok" sleep 0.2 CYAN " >> ${yellowl}WARNING: ${nc}/Root's size might not be adequate " #ATTENTION sleep 0.2 CYAN " >> ${nc}Depending on the ${yellowl}size ${nc}of your setup, installation might ${yellowl}fail " #ATTENTION keypress fi if [[ "${autoroot}" == "y" ]]; then if [[ "${presetpart}" == "y" || "${smartpart}" == "y" ]]; then rootprt="ok" sleep 0.2 GREEN " >> ${nc}Linux x86-64 /Root partition ${green}OK " #ATTENTION else rootprt="ok" local prompt="Confirmed /Root Partition" ok fi else sleep 0.2 rootprt="ok" GREEN " >> ${nc}Linux x86-64 /Root partition ${green}OK " #ATTENTION fi else rootprt="fail" sleep 0.2 RED " >> ${yellowl}Linux x86-64 /Root ${nc}partition not detected " #ATTENTION fi #.................................................................................................. if [[ ! -e "${esp_dev}" ]]; then espprt="fail" sleep 0.2 RED " >> ${yellowl}EFI System ${nc}partition not detected " #ATTENTION fi if [[ -e "${esp_dev}" ]]; then espsize="$(lsblk -dno SIZE --bytes "${esp_dev}")" fi if [[ -e "${esp_dev}" && "${espsize}" -ge "209715200" ]]; then espprt="ok" xbootloader="no" if [[ "${autoesp}" == "y" ]]; then if [[ "${presetpart}" == "y" || "${smartpart}" == "y" ]]; then espprt="ok" sleep 0.2 GREEN " >> ${nc}EFI System partition ${green}OK " #ATTENTION else espprt="ok" local prompt="Confirmed /EFI System Partition" ok fi else espprt="ok" sleep 0.2 GREEN " >> ${nc}EFI System partition ${green}OK " #ATTENTION fi fi if [[ -e "${esp_dev}" && "${espsize}" -lt "209715200" ]]; then if [[ "${bootloader}" == "1" ]]; then if [[ "${multibooting}" == "y" ]]; then xbootloader="yes" if [[ -e "${xboot_dev}" ]]; then xbootprt="ok" espprt="ok" if [[ "${autoesp}" == "y" ]]; then if [[ "${presetpart}" == "y" || "${smartpart}" == "y" ]]; then espprt="ok" sleep 0.2 GREEN " >> ${nc}EFI System partition ${green}OK " #ATTENTION else espprt="ok" local prompt="Confirmed /EFI System Partition" ok fi else espprt="ok" sleep 0.2 GREEN " >> ${nc}EFI System partition ${green}OK " #ATTENTION fi if [[ "${autoxboot}" == "y" ]]; then if [[ "${presetpart}" == "y" || "${smartpart}" == "y" ]]; then sleep 0.2 GREEN " >> ${nc}Linux Extended Boot partition ${green}OK " #ATTENTION else local prompt="Confirmed /XBOOTLDR Partition" ok fi else sleep 0.2 GREEN " >> ${nc}Linux Extended Boot partition ${green}OK " #ATTENTION fi else xbootprt="fail" espprt="fail" sleep 0.2 CYAN " >> ${yellowl}WARNING: ${nc}ESP's size is not ${bwhite}adequate " #ATTENTION sleep 0.2 RED " >> ${yellowl}Linux Extended Boot ${nc}partition not detected " #ATTENTION fi elif [[ "${multibooting}" == "n" ]]; then espprt="fail" xbootloader="no" sleep 0.2 CYAN " >> ${yellowl}WARNING: ${nc}ESP's size is not ${bwhite}adequate " #ATTENTION fi elif [[ "${bootloader}" == "2" ]]; then if [[ "${espmnt}" == "2" ]]; then espprt="fail" xbootloader="no" sleep 0.2 CYAN " >> ${yellowl}WARNING: ${nc}ESP's size is not ${bwhite}adequate " #ATTENTION elif [[ "${espmnt}" == "1" ]]; then espprt="ok" xbootloader="no" if [[ "${autoesp}" == "y" ]]; then if [[ "${presetpart}" == "y" || "${smartpart}" == "y" ]]; then sleep 0.2 GREEN " >> ${nc}EFI System partition ${green}OK " #ATTENTION else local prompt="Confirmed /EFI System Partition" ok fi else sleep 0.2 GREEN " >> ${nc}EFI System partition ${green}OK " #ATTENTION fi fi fi fi #.................................................................................................. if [[ "${fs}" == "1" ]]; then if [[ "${sep_home}" == "y" ]]; then if [[ -e "${home_dev}" ]]; then homeprt="ok" if [[ "${autohome}" == "y" ]]; then if [[ "${presetpart}" == "y" || "${smartpart}" == "y" ]]; then sleep 0.2 GREEN " >> ${nc}Linux /Home partition ${green}OK " #ATTENTION else local prompt="Confirmed /Home Partition" ok fi else GREEN " >> ${nc}Linux /Home partition ${green}OK " #ATTENTION fi else homeprt="fail" sleep 0.2 RED " >> ${yellowl}Linux /Home ${nc}partition not detected " #ATTENTION fi fi fi #.................................................................................................. if [[ "${swapmode}" == "1" ]]; then if [[ -e "${swap_dev}" ]]; then swapprt="ok" if [[ "${autoswap}" == "y" ]]; then if [[ "${presetpart}" == "y" || "${smartpart}" == "y" ]]; then sleep 0.2 GREEN " >> ${nc}Linux /Swap partition ${green}OK " #ATTENTION else local prompt="Confirmed /Swap Partition" ok fi else sleep 0.2 GREEN " >> ${nc}Linux /Swap partition ${green}OK " #ATTENTION fi else swapprt="fail" sleep 0.2 RED " >> ${yellowl}Linux /Swap ${nc}partition not detected " #ATTENTION fi fi #.................................................................................................. if [[ "${rootprt}" == "fail" || "${espprt}" == "fail" || "${xbootprt}" == "fail" || "${homeprt}" == "fail" || "${swapprt}" == "fail" ]]; then sanity="no" else sanity="ok" fi #-------------------------------------------------------------------------------------------------- if [[ "${sanity}" == "ok" ]]; then if [[ "${smartpart}" == "y" ]]; then sleep 0.2 NC " ==> [${green}Disk ${sgdrive} Smart-Partitioned OK${nc}] " elif [[ "${presetpart}" == "y" ]]; then sleep 0.2 NC " ==> [${green}Disk ${sgdrive} Preset-Partitioned OK${nc}] " fi sleep 0.2 GREEN " ----------------------- ### ${bwhite}SANITY CHECK OK${nc}${green} ### -----------------------" sleep 0.2 CYAN " ###${nc}------------------------------------------------${cyan}[ ${bwhite}DISK OVERVIEW ${nc}${cyan}]${nc}------------------------------------------------${cyan}### " fdisk -l "${instl_drive}" | grep -E --color=no 'Dev|dev' |GREP_COLORS='mt=01;36' grep -E --color=always 'EFI System|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'Linux root|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'Linux home|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'Linux swap|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'Linux extended boot|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " BLUE " > Proceed using the ${nc}${cyan}current ${blue}partitioning layout ? [Y/n] " read -r -p " ==> " partok echo partok="${partok:-y}" partok="${partok,,}" local prompt="Disk Partitioning" local stage_prompt="Partitioning" if [[ "${partok}" == "y" ]]; then ok return 0 elif [[ "${partok}" == "n" ]]; then if [[ "${multibooting}" == "n" && "${hometype}" == "1" ]]; then reload until auto_part; do : ; done return 0 elif [[ "${multibooting}" == "n" && "${hometype}" == "2" ]]; then reload until manual_part; do : ; done return 0 elif [[ "${multibooting}" == "n" ]]; then reload until auto_part; do : ; done return 0 elif [[ "${multibooting}" == "y" ]]; then reload until manual_part; do : ; done return 0 fi else y_n return 1 fi #-------------------------------------------------------------------------------------------------- elif [[ "${sanity}" == "no" ]]; then sleep 0.2 RED " ----------------------------- ### ${bwhite}SANITY CHECK FAILED ${nc}${red}### ----------------------------- " keypress if [[ "${multibooting}" == "y" ]]; then if [[ "${espprt}" == "fail" && -e "${esp_dev}" ]]; then sleep 0.2 CYAN " >> ${yellowl}ESP: ${nc}Not all prerequisites are satisfied " #ATTENTION if [[ "${espmnt}" == "2" ]]; then sleep 0.2 CYAN " >> ${nc}Select ${yellowl}/mnt/efi ${nc}as the mountpoint for your ${yellowl}ESP " #ATTENTION fi if [[ "${xbootprt}" == "fail" ]]; then sleep 0.2 CYAN " >> ${yellowl}Systemd-boot:${nc}${cyan} >> ${nc}Create a ${yellowl}300M ${nc}(at minimum) Linux Extended Boot Partition ${bwhite}(XBOOTLDR) ${yellowl}[GUID CODE: ea00] " #ATTENTION fi keypress if [[ "${espmnt}" == "2" ]]; then until slct_espmnt; do : ; done fi if [[ "${xbootprt}" == "fail" ]]; then until manual_part; do : ; done fi elif [[ "${espprt}" == "fail" && ! -e "${esp_dev}" ]]; then reload until manual_part; do : ; done elif [[ "${homeprt}" == "fail" || "${swapprt}" == "fail" ]]; then reload until manual_part; do : ; done fi elif [[ "${multibooting}" == "n" ]]; then if [[ -z "${hometype}" || "${hometype}" == "1" ]]; then reload until auto_part; do : ; done else reload until manual_part; do : ; done fi fi fi } ################################################################################################### ask_crypt() { local prompt="Encryption Setup" LuksArray=("Root") [[ "${hometype}" == "1" ]] && LuksArray+=("Home") [[ "${swapmode}" == "1" ]] && LuksArray+=("Swap") delimiter="" LuksParts="" for item in "${LuksArray[@]}"; do LuksParts="$LuksParts$delimiter$item" delimiter="," done sleep 0.2 NC " ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Encryption Setup${nc} ${magenta}]${nc}------------------------------------${magenta}### " BLUE " > Utilize LUKS encryption for your system ? " NC " * Type '${cyan}no${nc}' to proceed without encryption * Type '${cyan}yes${nc}' to encrypt your ${yellowl}${LuksParts} " read -r -p " ==> " encrypt echo if [[ "${encrypt}" == "no" ]]; then skip ok line2 return 0 elif [[ "${encrypt}" == "yes" ]]; then if [[ "${bootloader}" == "2" && "${espmnt}" == "1" ]]; then sleep 0.2 RED " ----------------------------------------- ### ${nc}Incompatible Selection detected ${red}### -----------------------------------------" YELLOW " ### ESP cannot be mounted on ${nc}'/efi' ${yellow}when using Grub on a LUKS encrypted Root partition > Change ESP mountpoint to ${nc}'/boot' ${yellow}instead ? [Y/n] " BLUE " Enter [Y/n]: " read -r -p " ==> " cng_espmnt echo cng_espmnt="${cng_espmnt:-y}" cng_espmnt="${cng_espmnt,,}" if [[ "${cng_espmnt}" == "y" ]]; then espmnt="2" esp_mount="/mnt/boot" btldr_esp_mount="/boot" sleep 0.2 YELLOW " ### '/mnt/boot' mountpoint has been selected " elif [[ "${cng_espmnt}" == "n" ]]; then failure else y_n return 1 fi fi sleep 0.2 YELLOW " > Set your LUKS encryption password: " BLUE " Enter password: " read -r -p " ==> " CRYPTPASS sleep 0.2 YELLOW " > Verify your LUKS encryption password: " BLUE " Re-enter password: " read -r -p " ==> " CRYPTPASS2 if [[ "${CRYPTPASS}" != "${CRYPTPASS2}" ]]; then sleep 0.2 RED " --------------------------------------------------- ### ${nc}Passwords don't match. Please try again.. ${red}### ---------------------------------------------------" reload return 1 fi if [[ "${sep_home}" == "y" && "${hometype}" == "2" ]]; then homecrypt="no" elif [[ "${sep_home}" == "y" && "${hometype}" == "1" ]]; then homecrypt="yes" fi ok else yes_no return 1 fi } ################################################################################################### instl() { install="yes" if [[ -z "${lcl_slct}" ]]; then if [[ -e /usr/bin/pv ]]; then sleep 0.2 CYAN " >> ${nc}Please complete ${bwhite}'Locale & Keyboard Layout Selection' ${nc}to continue " | pv -qL 70 else sleep 0.2 CYAN " >> ${nc}Please complete ${bwhite}'Locale & Keyboard Layout Selection' ${nc}to continue " fi until slct_locale; do : ; done until slct_kbd; do : ; done fi if [[ -z "${USERNAME}" ]]; then local stage_prompt="User, Root User, Hostname & Shell Setup" completion_err until user_setup; do : ; done until rootuser_setup; do : ; done until slct_hostname; do : ; done until slct_shell; do : ; done fi if [[ -z "${kernelnmbr}" ]]; then local stage_prompt="Kernel, Secureboot Signing, Bootloader & ESP Mountpoint" completion_err until slct_krnl; do : ; done until ask_sign; do : ; done until slct_bootldr; do : ; done until slct_espmnt; do : ; done fi if [[ -z "${fs}" ]]; then local stage_prompt="Filesystem & Swap Setup" completion_err until slct_fs; do : ; done until slct_swap; do : ; done fi if [[ "${vendor}" != "Virtual Machine" && -z "${gfx_slct}" ]]; then local stage_prompt="Graphics Setup" completion_err until dtct_gfx; do : ; done fi if [[ -z "${desktop}" ]]; then local stage_prompt="Desktop Setup" completion_err until dsktp_slct; do : ; done fi if [[ -z "${dev}" ]]; then until base_devel; do : ; done fi if [[ -z "${web_slct}" ]]; then if [[ ! "${desktop}" =~ ^(11|12)$ ]]; then until web_browser; do : ; done fi fi if [[ "${vendor}" != "Virtual Machine" ]]; then if [[ -z "${printer}" ]]; then if [[ ! "${desktop}" =~ ^(11|12)$ ]]; then until print_scan; do : ; done fi fi if [[ -z "${efi_entr_del}" ]]; then local stage_prompt="EFI Boot Entries Deletion" completion_err until boot_entr; do : ; done fi fi if [[ -z "${askoptm}" ]]; then local stage_prompt="Optimizations" completion_err until ask_optm; do : ; done if [[ "${askoptm}" == "y" ]]; then until cust_kern_param; do : ; done until sys_watchdog; do : ; done until gen_optm; do : ; done if [[ "${vendor}" != "Virtual Machine" ]]; then until ask_wireless_regdom; do : ; done fi until systemd_oomd; do : ; done until irqbalance; do : ; done until thermald; do : ; done until rngd; do : ; done until rtkit; do : ; done if [[ "${vendor}" != "Virtual Machine" ]]; then until tlp; do : ; done fi fi fi until instl_dsk; do : ; done until ask_crypt; do : ; done 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 set_wireless_regdom; do : ; done fi set_vars chroot_conf fi } ################################################################################################### swappart() { if [[ "${encrypt}" == "yes" ]]; then line2 fi local prompt="Swap Partition Creation" local stage_prompt="Swap Partition Creation" sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Swap Partition Setup${nc} ${magenta}]${nc}----------------------------------${magenta}### " if mkswap "${swap_dev}" > "${void}" 2> "${log}" ; then ok else stage_fail fi } ################################################################################################### set_mode() { if [[ "${rootcount}" -gt "1" || "${espcount}" -gt "1" || "${xbootcount}" -gt "1" || "${homecount}" -gt "1" || "${swapcount}" -gt "1" ]]; then until auto_mode; do : ; done sleep 0.2 NC " ==> [${green}Filesystems OK${nc}] " sleep 0.2 CYAN " ###${nc}---------------------------------------------${cyan}[ ${bwhite}FILESYSTEM OVERVIEW ${nc}${cyan}]${nc}---------------------------------------------${cyan}### " 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|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " sleep 0.2 return 0 fi sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Mode Selection${nc} ${magenta}]${nc}-------------------------------------${magenta}### " 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 " ------------------------------------------ ### ${nc}Please select a Mode to continue ${red}### ------------------------------------------" reload return 1 ;; *) invalid return 1 ;; esac sleep 0.2 NC " ==> [${green}Filesystems OK${nc}] " sleep 0.2 CYAN " ###${nc}---------------------------------------------${cyan}[ ${bwhite}FILESYSTEM OVERVIEW ${nc}${cyan}]${nc}---------------------------------------------${cyan}### " 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|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " sleep 0.2 } ################################################################################################### auto_mode() { espfs="$(lsblk -dno FSTYPE "${esp_dev}")" sleep 0.2 NC " ${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}Auto Mode${nc} ${magenta}]${nc}----------------------------------------${magenta}### " sleep 0.2 YELLOW " > Auto Mode Selected " if [[ "${fs}" == "1" ]]; then if mkfs.ext4 -F -L Root "${root_dev}" > "${void}" 2> "${log}" ; then tune2fs -O fast_commit "${root_dev}" > "${void}" 2> "${log}" || err_abort mount "${root_dev}" /mnt > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/Root OK${nc}] " else umount_manual until form_root; do : ; done until mount_mnt; do : ; done fi #-------------------------------------------------------------------------------------------------- elif [[ "${fs}" == "2" ]]; then if mkfs.btrfs -f -L Root "${root_dev}" > "${void}" 2> "${log}" ; then mount "${root_dev}" /mnt > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@ > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@home > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@cache > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@log > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@tmp > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@snapshots > "${void}" 2> "${log}" || err_abort if [[ "${swapmode}" == "2" ]]; then btrfs subvolume create /mnt/@swap > "${void}" 2> "${log}" || err_abort fi umount /mnt > "${void}" 2> "${log}" || err_abort mount -o "${sbvl_mnt_opts}",subvol=@ "${root_dev}" /mnt > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@home "${root_dev}" /mnt/home > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@cache "${root_dev}" /mnt/var/cache > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@log "${root_dev}" /mnt/var/log > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@tmp "${root_dev}" /mnt/var/tmp > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@snapshots "${root_dev}" /mnt/"${snapname}" > "${void}" 2> "${log}" || err_abort if [[ "${swapmode}" == "2" ]]; then mount --mkdir -o "${sbvl_mnt_opts}",subvol=@swap "${root_dev}" /mnt/swap > "${void}" 2> "${log}" || err_abort fi sleep 0.2 NC " ==> [${green}/@ OK${nc}] " else umount_manual until form_root; do : ; done until mount_mnt; do : ; done fi fi sleep 0.2 #-------------------------------------------------------------------------------------------------- if [[ "${multibooting}" == "n" ]]; then if mkfs.fat -F 32 -n ESP "${esp_dev}" > "${void}" 2> "${log}" ; then mount --mkdir "${esp_dev}" "${esp_mount}" > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/ESP OK${nc}] " else umount_manual until form_esp; do : ; done until mount_mnt; do : ; done until mount_esp; do : ; done fi elif [[ "${multibooting}" == "y" && "${espfs}" == "vfat" ]]; then if mount --mkdir "${esp_dev}" "${esp_mount}" > "${void}" 2> "${log}" ; then sleep 0.2 NC " ==> [${green}Unformatted /ESP Mounted OK${nc}] " else umount_manual until mount_mnt; do : ; done until mount_esp; do : ; done fi elif [[ "${multibooting}" == "y" && "${espfs}" != "vfat" ]]; then if mkfs.fat -F 32 -n ESP "${esp_dev}" > "${void}" 2> "${log}" ; then mount --mkdir "${esp_dev}" "${esp_mount}" > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/ESP OK${nc}] " else umount_manual until form_esp; do : ; done until mount_mnt; do : ; done until mount_esp; do : ; done fi fi sleep 0.2 #-------------------------------------------------------------------------------------------------- if [[ "${xbootloader}" == "yes" ]]; then if mkfs.fat -F 32 -n XBOOTLDR "${xboot_dev}" > "${void}" 2> "${log}" ; then mount --mkdir "${xboot_dev}" /mnt/boot > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/XBOOTLDR OK${nc}] " else umount_manual until form_xboot; do : ; done until mount_mnt; do : ; done until mount_esp; do : ; done until mount_xboot; do : ; done fi fi sleep 0.2 #-------------------------------------------------------------------------------------------------- if [[ "${fs}" == "1" && -e "${home_dev}" && "${sep_home}" == "y" ]]; then if [[ "${smartpart}" == "y" ]]; then homeform="y" elif [[ "${preset}" =~ ^(3|4)$ ]]; then homeform="y" elif [[ "${hometype}" == "1" ]]; then homeform="y" elif [[ "${hometype}" == "2" ]]; then homeform="n" fi if [[ "${homeform}" == "y" ]]; then if mkfs.ext4 -F -L Home "${home_dev}" > "${void}" 2> "${log}" ; then tune2fs -O fast_commit "${home_dev}" > "${void}" 2> "${log}" || err_abort mount --mkdir "${home_dev}" /mnt/home > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/Home OK${nc}] " else umount_manual until manual_part; do : ; done until form_home; do : ; done until mount_mnt; do : ; done until mount_esp; do : ; done if [[ "${xbootloader}" == "yes" ]]; then until mount_xboot; do : ; done fi until mount_home; do : ; done fi elif [[ "${homeform}" == "n" ]]; then mount --mkdir "${home_dev}" /mnt/home > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Unformatted /Home Mounted OK${nc}] " else y_n until ask_homepart_form; do : ; done fi fi } ################################################################################################### manual_mode() { volumes="$(fdisk -l | grep '^/dev' | cat --number)" until form_esp; do : ; done if [[ "${xbootloader}" == "yes" ]]; then until form_xboot; do : ; done fi until form_root; do : ; done if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then until form_home; do : ; done fi until mount_mnt; do : ; done until mount_esp; do : ; done if [[ "${xbootloader}" == "yes" ]]; then until mount_xboot; do : ; done fi if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then until mount_home; do : ; done fi } ################################################################################################### form_esp() { sleep 0.2 NC " ${magenta}###${nc}-------------------------------${magenta}[ ${bwhite}Format EFI System Partition${nc} ${magenta}]${nc}-------------------------------${magenta}### " form_esp_nmbr=" " while [[ -n "${form_esp_nmbr}" ]]; do YELLOW " > Select an EFI System Partition to format as ${nc}vfat ${volumes}" BLUE " Enter a partition number: " read -r -p " ==> " form_esp_nmbr if [[ -n "${form_esp_nmbr}" ]]; then esppart="$(echo "${volumes}" | awk "\$1 == ${form_esp_nmbr} {print \$2}")" manespfs="$(lsblk -dno FSTYPE "${esppart}" 2> "${void}")" if [[ -e "${esppart}" ]]; then if [[ "${multibooting}" == "n" ]]; then if mkfs.fat -F 32 -n ESP "${esppart}" > "${void}" 2> "${log}" ; then sleep 0.2 NC " ==> [${green}Format & Label /ESP OK${nc}] " return 0 else do_umount until manual_part; do : ; done until form_esp; do : ; done return 0 fi elif [[ "${multibooting}" == "y" && "${manespfs}" == "vfat" ]]; then sleep 0.2 NC " ==> [${green}/Unformatted ESP OK${nc}] " return 0 elif [[ "${multibooting}" == "y" && "${manespfs}" != "vfat" ]]; then if mkfs.fat -F 32 -n ESP "${esppart}" > "${void}" 2> "${log}" ; then sleep 0.2 NC " ==> [${green}Format & Label /ESP OK${nc}] " return 0 else do_umount until manual_part; do : ; done until form_esp; do : ; done return 0 fi fi else invalid return 1 fi else choice return 1 fi done } ################################################################################################### form_xboot() { sleep 0.2 NC " ${magenta}###${nc}--------------------------${magenta}[ ${bwhite}Format Linux Extended Boot Partition${nc} ${magenta}]${nc}--------------------------${magenta}### " form_xboot_nmbr=" " while [[ -n "${form_xboot_nmbr}" ]]; do YELLOW " > Select a Linux Extended Boot Partition to format as ${nc}vfat ${volumes}" BLUE " Enter a partition number: " read -r -p " ==> " form_xboot_nmbr if [[ -n "${form_xboot_nmbr}" ]]; then xbootpart="$(echo "${volumes}" | awk "\$1 == ${form_xboot_nmbr} {print \$2}")" if [[ -e "${xbootpart}" ]]; then if mkfs.fat -F 32 -n XBOOTLDR "${xbootpart}" > "${void}" 2> "${log}" ; then sleep 0.2 NC " ==> [${green}Format & Label /XBOOTLDR OK${nc}] " return 0 else do_umount until manual_part; do : ; done until form_xboot; do : ; done return 0 fi else invalid return 1 fi else choice return 1 fi done } ################################################################################################### form_root() { sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Format Root Partition${nc} ${magenta}]${nc}----------------------------------${magenta}### " form_root_nmbr=" " while [[ -n "${form_root_nmbr}" ]]; do YELLOW " > Select a ${roottype} Partition to format as ${nc}${fsname} ${volumes}" BLUE " Enter a partition number: " 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}" > "${void}" 2> "${log}" ; then tune2fs -O fast_commit "${rootpart}" > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Format ${roottype} OK${nc}] " else do_umount until manual_part; do : ; done until form_root; do : ; done return 0 fi #-------------------------------------------------------------------------------------------------- elif [[ "${fs}" == "2" ]]; then if mkfs.btrfs -f "${rootpart}" > "${void}" 2> "${log}" ; then mount "${rootpart}" /mnt > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@ > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@home > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@cache > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@log > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@tmp > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@snapshots > "${void}" 2> "${log}" || err_abort if [[ "${swapmode}" == "2" ]]; then btrfs subvolume create /mnt/@swap > "${void}" 2> "${log}" || err_abort fi umount /mnt > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Format ${roottype} OK${nc}] " else do_umount until manual_part; 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: " read -r -p " ==> " rootpartname if [[ -n "${rootpartname}" ]]; then if [[ "${fs}" == "1" ]]; then if e2label "${rootpart}" "${rootpartname}" > "${void}" 2> "${log}" ; then sleep 0.2 NC " ==> [${green}Label ${roottype} OK${nc}] " return 0 else err_try return 1 fi elif [[ "${fs}" == "2" ]]; then mount "${rootpart}" /mnt || err_abort btrfs filesystem label /mnt "${rootpartname}" > "${void}" 2> "${log}" || err_abort umount /mnt || err_abort sleep 0.2 NC " ==> [${green}Label ${roottype} OK${nc}] " return 0 fi else sleep 0.2 RED " ----------------------------- ### ${nc}Please enter a name ${red}### -----------------------------" reload return 1 fi else choice return 1 fi done } ################################################################################################### ask_homepart_form() { if [[ "${fs}" == "1" && -e "${home_dev}" && "${sep_home}" == "y" ]]; then if [[ "${smartpart}" == "y" ]]; then homeform="y" elif [[ "${preset}" =~ ^(3|4)$ ]]; then homeform="y" elif [[ "${hometype}" == "1" ]]; then homeform="y" elif [[ "${hometype}" == "2" ]]; then homeform="n" fi if [[ "${homeform}" == "y" ]]; then if mkfs.ext4 -F -L Home "${home_dev}" > "${void}" 2> "${log}" ; then tune2fs -O fast_commit "${home_dev}" > "${void}" 2> "${log}" || err_abort mount --mkdir "${home_dev}" /mnt/home > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/Home OK${nc}] " else umount_manual until manual_part; do : ; done until form_home; do : ; done until mount_mnt; do : ; done until mount_esp; do : ; done if [[ "${xbootloader}" == "yes" ]]; then until mount_xboot; do : ; done fi until mount_home; do : ; done fi elif [[ "${homeform}" == "n" ]]; then mount --mkdir "${home_dev}" /mnt/home > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Unformatted /Home Mounted OK${nc}] " else y_n return 1 fi fi } ################################################################################################### form_home() { sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Format Home Partition${nc} ${magenta}]${nc}----------------------------------${magenta}### " form_home_nmbr=" " while [[ -n "${form_home_nmbr}" ]]; do YELLOW " > Select a /Home Partition to format as ${nc}Ext4 ${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}" > "${void}" 2> "${log}" ; then tune2fs -O fast_commit "${homepart}" > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Format /Home OK${nc}] " else do_umount until manual_part; do : ; done until form_home; do : ; done return 0 fi else invalid return 1 fi YELLOW " > Label the /Home Partition " BLUE " Enter a name: " read -r -p " ==> " homepartname if [[ -n "${homepartname}" ]]; then if e2label "${homepart}" "${homepartname}" > "${void}" 2> "${log}" ;then sleep 0.2 NC " ==> [${green}Label /Home OK${nc}] " return 0 else err_try return 1 fi else sleep 0.2 RED " ----------------------------- ### ${nc}Please enter a name ${red}### -----------------------------" reload return 1 fi else RED " --------------------------------------------------- ### ${yellow}WARNING: ${nc}PARTITION HAS NOT BEEN FORMATTED ${red}### ---------------------------------------------------" skip return 0 fi done } ################################################################################################### mount_mnt() { local prompt="Mount ${roottype}" sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Mount Root Partition${nc} ${magenta}]${nc}----------------------------------${magenta}### " YELLOW " > Select a ${roottype} Partition to mount to ${nc}/mnt ${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 > "${void}" 2> "${log}" ; then sleep 0.2 ok return 0 else do_umount until mount_mnt; do : ; done fi #-------------------------------------------------------------------------------------------------- elif [[ "${fs}" == "2" ]]; then if mount -o "${sbvl_mnt_opts}",subvol=@ "${rootpart}" /mnt > "${void}" 2> "${log}" ; then mount --mkdir -o "${sbvl_mnt_opts}",subvol=@home "${rootpart}" /mnt/home > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@cache "${rootpart}" /mnt/var/cache > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@log "${rootpart}" /mnt/var/log > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@tmp "${rootpart}" /mnt/var/tmp > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@snapshots "${rootpart}" /mnt/"${snapname}" > "${void}" 2> "${log}" || err_abort if [[ "${swapmode}" == "2" ]]; then mount --mkdir -o "${sbvl_mnt_opts}",subvol=@swap "${rootpart}" /mnt/swap > "${void}" 2> "${log}" || err_abort fi sleep 0.2 ok return 0 else do_umount until mount_mnt; do : ; done fi fi #-------------------------------------------------------------------------------------------------- else invalid return 1 fi else choice return 1 fi } ################################################################################################### mount_esp() { local prompt="Mount ESP" sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Mount ESP Partition${nc} ${magenta}]${nc}-----------------------------------${magenta}### " YELLOW " > Select an EFI System Partition to mount to ${nc}${esp_mount} ${volumes}" BLUE " Enter your${nc} ${cyan}/ESP ${blue}partition number: " read -r -p " ==> " mntesp_nmbr echo if [[ -n "${mntesp_nmbr}" ]]; then esppart="$(echo "${volumes}" | awk "\$1 == ${mntesp_nmbr} {print \$2}")" if [[ -e "${esppart}" ]]; then if mount --mkdir "${esppart}" "${esp_mount}" > "${void}" 2> "${log}" ; then ok return 0 else do_umount until mount_mnt; do : ; done until mount_esp; do : ; done fi else invalid return 1 fi else choice return 1 fi } ################################################################################################### mount_xboot() { local prompt="Mount XBOOTLDR" sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}Mount XBOOTLDR Partition${nc} ${magenta}]${nc}--------------------------------${magenta}### " YELLOW " > Select a Linux Extended Boot Partition to mount to ${nc}/mnt/boot ${volumes}" BLUE " Enter your${nc} ${cyan}/XBOOTLDR ${blue}partition number: " read -r -p " ==> " mntxboot_nmbr echo if [[ -n "${mntxboot_nmbr}" ]]; then xbootpart="$(echo "${volumes}" | awk "\$1 == ${mntxboot_nmbr} {print \$2}")" if [[ -e "${xbootpart}" ]]; then if mount --mkdir "${xbootpart}" /mnt/boot > "${void}" 2> "${log}" ; then ok return 0 else do_umount until mount_mnt; do : ; done until mount_esp; do : ; done until mount_xboot; do : ; done fi else invalid return 1 fi else choice return 1 fi } ################################################################################################### mount_home() { local prompt="Mount /Home" sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Mount Home Partition${nc} ${magenta}]${nc}----------------------------------${magenta}### " YELLOW " > Select a /Home Partition to mount to ${nc}/mnt/home ${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 --mkdir "${homepart}" /mnt/home > "${void}" 2> "${log}" ; then ok return 0 else do_umount until mount_mnt; do : ; done until mount_esp; do : ; done until mount_xboot; 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.2 NC " ${magenta}###${nc}-------------------------------${magenta}[ ${bwhite}Confirm Installation Status${nc} ${magenta}]${nc}-------------------------------${magenta}### " 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 set_wireless_regdom; do : ; done fi set_vars chroot_conf elif [[ "${agree}" == "no" ]]; then unmount until revise; do : ; done else yes_no return 1 fi } ################################################################################################### revise() { reset=(xbootloader="" desktop="" terminal="" custompkgs="" customservices="" cust_bootopts="" REGDOM="" autoroot="" autoxboot="" autohome="" autoswap="" lowlat="" nogsp="" sanity="" partok="" preset="" set_optm="" ask_param="" kill_watchdog="" genoptm="" desk_setup="" devel="" web="" web_pkg="" web_aur="" web_slct="" oomd="" irqbalance="" thermald="" rngd="" rtkit="" tlp="" CRYPTPASS="" CRYPTPASS2="" askoptm="" gptslct="" gptok="" gptabort="" nvdprop="" nowarning="" hometype="" homeform="" smartpart="" LuksParts="") export "${reset[@]}" gfxpkgs=() until slct_krnl; do : ; done until ask_sign; do : ; done until slct_bootldr; do : ; done until slct_espmnt; do : ; done until slct_fs; do : ; done until slct_swap; do : ; done if [[ "${vendor}" != "Virtual Machine" ]]; then until dtct_gfx; do : ; done fi until dsktp_slct; do : ; done until base_devel; do : ; done if [[ ! "${desktop}" =~ ^(11|12)$ ]]; then until web_browser; do : ; done fi if [[ "${vendor}" != "Virtual Machine" ]]; then until print_scan; do : ; done until boot_entr; do : ; done fi if [[ "${askoptm}" == "y" ]]; then until cust_kern_param; do : ; done until sys_watchdog; do : ; done until gen_optm; do : ; done if [[ "${vendor}" != "Virtual Machine" ]]; then until ask_wireless_regdom; do : ; done fi until systemd_oomd; do : ; done until irqbalance; do : ; done until thermald; do : ; done until rngd; do : ; done until rtkit; do : ; done if [[ "${vendor}" != "Virtual Machine" ]]; then until tlp; do : ; done fi fi until instl_dsk; do : ; done until ask_crypt; do : ; done 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 set_wireless_regdom; do : ; done fi set_vars chroot_conf fi } ################################################################################################### sec_erase() { local prompt="Secure Erasure" sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Secure Disk Erasure${nc} ${magenta}]${nc}-----------------------------------${magenta}### " erase_dsk_nmbr=" " while [[ -n "${erase_dsk_nmbr}" ]]; do YELLOW " > Select a disk for Secure Erasure ${red}[!] (CAUTION) [!]${yellow} " CYAN " >> ${nc}A reboot is mandatory and will take effect ${yellowl}immediately ${nc}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 || err_abort dd if=/dev/zero of=/dev/mapper/temp status=progress bs=1M oflag=direct || err_abort cryptsetup close temp || err_abort sleep 0.2 NC " ==> [${green}Drive ${erasedrive} Erased OK${nc}] " sleep 0.2 NC " ==> [${green}Rebooting${nc}] " sleep 1 reboot else invalid return 1 fi else skip ok fi done } ################################################################################################### luks() { espfs="$(lsblk -f --noheadings "${esp_dev}" | awk "{print \$2}")" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}LUKS Encryption${nc} ${magenta}]${nc}-------------------------------------${magenta}### " BLUE " > Encrypting your ${yellowl}${LuksParts}${blue}: " if echo -n "${CRYPTPASS}" | cryptsetup luksFormat --label CRYPTROOT "${root_dev}" > "${void}"; then if [[ "${rota}" == "0" ]]; then echo -n "${CRYPTPASS}" | cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --persistent luksOpen "${root_dev}" CryptRoot || err_abort else echo -n "${CRYPTPASS}" | cryptsetup luksOpen "${root_dev}" CryptRoot || err_abort fi #------------------------------------------------------------------------------------------ if [[ "${fs}" == "1" ]]; then mkfs.ext4 -F -L CryptRoot /dev/mapper/CryptRoot > "${void}" 2> "${log}" || err_abort tune2fs -O fast_commit /dev/mapper/CryptRoot > "${void}" 2> "${log}" || err_abort mount /dev/mapper/CryptRoot /mnt > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Encrypted /Root OK${nc}] " luks_root="ok" #------------------------------------------------------------------------------------------ elif [[ "${fs}" == "2" ]]; then mkfs.btrfs -f -L CryptRoot /dev/mapper/CryptRoot > "${void}" 2> "${log}" || err_abort mount /dev/mapper/CryptRoot /mnt > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@ > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@home > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@cache > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@log > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@tmp > "${void}" 2> "${log}" || err_abort btrfs subvolume create /mnt/@snapshots > "${void}" 2> "${log}" || err_abort if [[ "${swapmode}" == "2" ]]; then btrfs subvolume create /mnt/@swap > "${void}" 2> "${log}" || err_abort fi umount /mnt > "${void}" 2> "${log}" || err_abort mount -o "${sbvl_mnt_opts}",subvol=@ /dev/mapper/CryptRoot /mnt > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@home /dev/mapper/CryptRoot /mnt/home > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@cache /dev/mapper/CryptRoot /mnt/var/cache > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@log /dev/mapper/CryptRoot /mnt/var/log > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@tmp /dev/mapper/CryptRoot /mnt/var/tmp > "${void}" 2> "${log}" || err_abort mount --mkdir -o "${sbvl_mnt_opts}",subvol=@snapshots /dev/mapper/CryptRoot /mnt/"${snapname}" > "${void}" 2> "${log}" || err_abort if [[ "${swapmode}" == "2" ]]; then mount --mkdir -o "${sbvl_mnt_opts}",subvol=@swap /dev/mapper/CryptRoot /mnt/swap > "${void}" 2> "${log}" || err_abort fi sleep 0.2 NC " ==> [${green}Encrypted /@ OK${nc}] " luks_root="ok" fi else line2 err_try do_umount return 1 fi #-------------------------------------------------------------------------------------------------- if [[ -e "${swap_dev}" && "${swapmode}" == "1" ]]; then line2 if echo -n "${CRYPTPASS}" | cryptsetup luksFormat --label CRYPTSWAP "${swap_dev}" > "${void}"; then if [[ "${rota}" == "0" ]]; then echo -n "${CRYPTPASS}" | cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --persistent luksOpen "${swap_dev}" CryptSwap || err_abort else echo -n "${CRYPTPASS}" | cryptsetup luksOpen "${swap_dev}" CryptSwap || err_abort fi mkswap /dev/mapper/CryptSwap > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Encrypted /Swap OK${nc}] " luks_swap="ok" else line2 err_try do_umount return 1 fi fi #-------------------------------------------------------------------------------------------------- if [[ "${homecrypt}" == "yes" ]]; then line2 if echo -n "${CRYPTPASS}" | cryptsetup luksFormat --label CRYPTHOME "${home_dev}" > "${void}"; then if [[ "${rota}" == "0" ]]; then echo -n "${CRYPTPASS}" | cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --persistent luksOpen "${home_dev}" CryptHome || err_abort else echo -n "${CRYPTPASS}" | cryptsetup luksOpen "${home_dev}" CryptHome || err_abort fi mkfs.ext4 -F -L CryptHome /dev/mapper/CryptHome > "${void}" 2> "${log}" || err_abort tune2fs -O fast_commit /dev/mapper/CryptHome > "${void}" 2> "${log}" || err_abort mount --mkdir /dev/mapper/CryptHome /mnt/home > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Encrypted /Home OK${nc}] " luks_home="ok" else line2 err_try do_umount return 1 fi elif [[ "${homecrypt}" == "no" ]]; then [[ "${hometype}" == "1" ]] && homeform="y" if [[ "${hometype}" == "2" ]]; then homeform="n" sleep 0.2 YELLOW " > An existing /Home partition has been detected and will be utilized in this installation " keypress fi fi if [[ "${homeform}" == "y" ]]; then if mkfs.ext4 -F -L Home "${home_dev}" > "${void}" 2> "${log}" ; then tune2fs -O fast_commit "${home_dev}" > "${void}" 2> "${log}" || err_abort mount --mkdir "${home_dev}" /mnt/home > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/Home OK${nc}] " else line2 err_try do_umount return 1 fi elif [[ "${homeform}" == "n" ]]; then mount --mkdir "${home_dev}" /mnt/home > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}Unformatted /Home Mounted OK${nc}] " fi #-------------------------------------------------------------------------------------------------- if [[ "${multibooting}" == "n" ]]; then if mkfs.fat -F 32 -n ESP "${esp_dev}" > "${void}" 2> "${log}" ; then mount --mkdir "${esp_dev}" "${esp_mount}" > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/ESP OK${nc}] " else do_umount until luks; do : ; done fi elif [[ "${multibooting}" == "y" && "${espfs}" == "vfat" ]]; then if mount --mkdir "${esp_dev}" "${esp_mount}" > "${void}" 2> "${log}" ; then sleep 0.2 NC " ==> [${green}Unformatted /ESP Mounted OK${nc}] " else line2 err_try do_umount return 1 fi elif [[ "${multibooting}" == "y" && "${espfs}" != "vfat" ]]; then if mkfs.fat -F 32 -n ESP "${esp_dev}" > "${void}" 2> "${log}" ; then mount --mkdir "${esp_dev}" "${esp_mount}" > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/ESP OK${nc}] " else do_umount until luks; do : ; done fi fi #-------------------------------------------------------------------------------------------------- if [[ "${xbootloader}" == "yes" ]] ; then if mkfs.fat -F 32 -n XBOOTLDR "${xboot_dev}" > "${void}" 2> "${log}" ; then mount --mkdir "${xboot_dev}" /mnt/boot > "${void}" 2> "${log}" || err_abort sleep 0.2 NC " ==> [${green}/XBOOTLDR OK${nc}] " else line2 err_try do_umount return 1 fi fi #-------------------------------------------------------------------------------------------------- sleep 0.2 NC " ==> [${green}Encryption Completed OK${nc}]" luks_encrypt="ok" sleep 0.2 NC " ==> [${green}Filesystems OK${nc}] " sleep 0.2 CYAN " ###${nc}---------------------------------------------${cyan}[ ${bwhite}FILESYSTEM OVERVIEW ${nc}${cyan}]${nc}---------------------------------------------${cyan}### " 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|$' CYAN " ###${nc}-----------------------------------------------------------------------------------------------------------------${cyan}### " sleep 0.2 } ################################################################################################### opt_pcmn() { local prompt="PacMan" sleep 0.2 NC " ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Pacman Optimization${nc} ${magenta}]${nc}-----------------------------------${magenta}### " YELLOW " > Select a Country for your Arch Mirrors: ### [Enter ${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 COUNTRY="${COUNTRY^^}" if [[ -z "${COUNTRY}" ]] ; then sleep 0.2 NC " ==> [${green}Default Mirrors OK${nc}] " elif [[ "${COUNTRY}" == "l" ]]; then reflector --list-countries | less return 1 elif [[ -n "${COUNTRY}" ]]; then line2 if reflector --verbose -c "${COUNTRY}" -l 10 -p https -f 10 --sort rate --save /etc/pacman.d/mirrorlist ; then sleep 0.2 NC " ==> [${green}${COUNTRY}'s Mirrors OK${nc}] " else err_try return 1 fi fi YELLOW " > Enable Arch's 'Multilib' repository in the installed system ? [y/N] " BLUE " Enter [y/N]: " read -r -p " ==> " multilib echo multilib="${multilib:-n}" multilib="${multilib,,}" if [[ "${multilib}" == "y" ]]; then sleep 0.2 NC " ==> [${green}Multilib repository OK${nc}]" elif [[ "${multilib}" == "n" ]]; then skip else y_n return 1 fi ok } ################################################################################################### pacstrap_system() { sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Pacstrap System${nc} ${magenta}]${nc}-------------------------------------${magenta}### " installing gfxpkgs_set if [[ "${bootloader}" == "2" ]]; then [[ "${fs}" == "1" ]] && bootldr_pkgs="grub os-prober" [[ "${fs}" == "2" ]] && bootldr_pkgs="grub-btrfs inotify-tools os-prober" fi basepkgs=(base efibootmgr nano networkmanager pkgstats sudo vim "${bootldr_pkgs}" "${fstools}" "${kernel}" "${microcode}" "${shell_pkgs}") [[ -n "${shell}" ]] && basepkgs+=("${shell}") [[ -n "${nrg_plc}" ]] && basepkgs+=("${nrg_plc}") [[ -n "${ukify}" ]] && basepkgs+=("${ukify}") [[ -n "${zram}" ]] && basepkgs+=("${zram}") [[ -n "${gfxpkgs[*]}" ]] && basepkgs+=("${gfxpkgs[*]}") [[ -n "${devel}" ]] && basepkgs+=("${devel}") [[ -n "${wireless_reg}" ]] && basepkgs+=("${wireless_reg}") [[ -n "${print_pkgs}" ]] && basepkgs+=("${print_pkgs}") [[ -n "${web_pkg}" ]] && basepkgs+=("${web_pkg}") [[ "${vendor}" == "Virtual Machine" ]] && basepkgs+=("${vmpkgs}") [[ "${vendor}" != "Virtual Machine" ]] && basepkgs+=(alsa-firmware linux-firmware sof-firmware) [[ "${terminal}" == "y" ]] && basepkgs+=(gnome-terminal) [[ "${nvdprop}" == "y" ]] && basepkgs+=("${kernel}-headers") [[ ! "${desktop}" =~ ^(11|12)$ ]] && basepkgs+=(7zip alsa-utils bluez bluez-hid2hci bluez-obex bluez-utils exfatprogs git glibc-locales gst-libav gst-plugin-libcamera gst-plugin-pipewire gst-plugins-bad gst-plugins-good gst-plugins-ugly libfido2 man-db man-pages mesa-utils nano-syntax-highlighting pacman-contrib pipewire-alsa pipewire-libcamera pipewire-pulse pipewire-zeroconf reflector usb_modeswitch xdg-user-dirs) case "${desktop}" in 1) # Plasma Desktop: deskpkgs="${basepkgs[*]} dolphin-plugins konsole plasma plasma-x11-session qt6-multimedia-gstreamer" displaymanager="sddm" ;; 2) # Plasma Lite Desktop: deskpkgs="${basepkgs[*]} ark bluedevil breeze-gtk colord-kde dolphin-plugins flatpak-kcm freerdp kate kcalc kclock kde-gtk-config kdegraphics-mobipocket kdegraphics-thumbnailers kdenetwork-filesharing kdeplasma-addons kdf kdialog keditbookmarks kget kimageformats kio-admin kio-gdrive kio-zeroconf konsole krdc krfb kscreen kwayland-integration kwrited okular purpose ocean-sound-theme packagekit-qt6 partitionmanager plasma5-integration plasma-browser-integration plasma-desktop plasma-disks plasma-firewall plasma-nm plasma-pa plasma-systemmonitor plasma-wayland-protocols plasma-x11-session sddm-kcm spectacle appmenu-gtk-module arj dosfstools ffmpegthumbs icoutils kvantum libappimage lrzip lzop ntfs-3g power-profiles-daemon qt5-xmlpatterns qt6-connectivity qt6-multimedia-gstreamer unarchiver unrar xdg-desktop-portal-gtk" displaymanager="sddm" ;; 3) # Gnome Desktop: deskpkgs="${basepkgs[*]} gnome" displaymanager="gdm" ;; 4) # Gnome Lite Desktop: deskpkgs="${basepkgs[*]} dconf-editor file-roller gdm gnome-browser-connector gnome-calculator gnome-clocks gnome-console gnome-control-center gnome-disk-utility gnome-keyring gnome-menus gnome-shell-extensions gnome-system-monitor gnome-text-editor gnome-tweaks gnome-user-share gvfs gvfs-afc gvfs-mtp gvfs-smb loupe papers sushi dosfstools glib2-devel gparted ntfs-3g power-profiles-daemon unrar unzip xorg-xhost zip" displaymanager="gdm" ;; 5) # Xfce Desktop: deskpkgs="${basepkgs[*]} blueman catfish ffmpegthumbnailer gvfs gvfs-afc gvfs-mtp gvfs-smb libgsf libopenraw lightdm-gtk-greeter mousepad mugshot network-manager-applet pavucontrol poppler-glib ristretto thunar-archive-plugin thunar-media-tags-plugin thunar-shares-plugin xfce4 xfce4-artwork xfce4-battery-plugin xfce4-clipman-plugin xfce4-datetime-plugin xfce4-indicator-plugin xfce4-mount-plugin xfce4-power-manager xfce4-pulseaudio-plugin xfce4-screensaver xfce4-screenshooter xfce4-taskmanager xfce4-whiskermenu-plugin xfce4-power-manager xiccd" displaymanager="lightdm" ;; 6) # Cinnamon Desktop: deskpkgs="${basepkgs[*]} blueman cinnamon ffmpegthumbnailer gnome-color-manager gnome-keyring lightdm-slick-greeter touchegg wget" displaymanager="lightdm" ;; 7) # Deepin Desktop: deskpkgs="${basepkgs[*]} adobe-source-han-sans-otc-fonts deepin deepin-calculator deepin-camera deepin-clipboard deepin-community-wallpapers deepin-compressor deepin-device-formatter deepin-editor deepin-font-manager deepin-grand-search deepin-kwin deepin-movie deepin-printer deepin-screensaver deepin-shortcut-viewer deepin-terminal iw proxychains-ng qt6-multimedia-gstreamer redshift zssh" displaymanager="lightdm" ;; 8) # Budgie Desktop: deskpkgs="${basepkgs[*]} blueman budgie gnome-user-share lightdm-gtk-greeter materia-gtk-theme nemo network-manager-applet openssh papirus-icon-theme power-profiles-daemon rygel" displaymanager="lightdm" ;; 9) # Lxqt Desktop: deskpkgs="${basepkgs[*]} blueman breeze-icons gvfs gvfs-mtp kimageformats libarchive lxqt network-manager-applet oxygen-icons python-pyxdg qt6-imageformats qt6-multimedia-gstreamer sddm xscreensaver xsettingsd" displaymanager="sddm" ;; 10) # Mate Desktop: deskpkgs="${basepkgs[*]} atril blueman caja-actions caja-audio-video-properties caja-open-terminal caja-sendto caja-share caja-wallpaper cpio engrampa eom gnome-keyring lightdm-gtk-greeter mate mate-applets mate-calc mate-icon-theme mate-icon-theme-faenza mate-media mate-netbook mate-power-manager mate-screensaver mate-system-monitor mate-terminal mate-user-share mate-utils mozo network-manager-applet pluma python-gobject unace unrar webp-pixbuf-loader xdg-user-dirs-gtk" displaymanager="lightdm" ;; 11) # Base System: deskpkgs="${basepkgs[*]}" ;; 12) # Custom System: custarray=(base sudo "${bootldr_pkgs}" "${custompkgs}" "${fstools}" "${kernel}" "${microcode}") [[ -n "${shell}" ]] && custarray+=("${shell}") [[ -n "${ukify}" ]] && custarray+=("${ukify}") [[ -n "${zram}" ]] && custarray+=("${zram}") [[ -n "${gfxpkgs[*]}" ]] && custarray+=("${gfxpkgs[*]}") [[ -n "${wireless_reg}" ]] && custarray+=("${wireless_reg}") [[ -n "${print_pkgs}" ]] && custarray+=("${print_pkgs}") [[ "${vendor}" == "Virtual Machine" ]] && custarray+=("${vmpkgs}") [[ "${vendor}" != "Virtual Machine" ]] && custarray+=(linux-firmware) [[ "${nvdprop}" == "y" ]] && custarray+=("${kernel}-headers") [[ "${greeternmbr}" =~ ^(1|2|3)$ ]] && custarray+=("${greeter}") deskpkgs="${custarray[*]}" ;; 13) # Cosmic Desktop: deskpkgs="${basepkgs[*]} cosmic cosmic-player dconf gnome-keyring gvfs gvfs-dnssd gvfs-nfs gvfs-smb packagekit power-profiles-daemon pulseaudio-alsa" displaymanager="cosmic-greeter" ;; esac pkg_displ echo keypress if pacstrap -K /mnt ${deskpkgs} 2> "${log}" ; then local prompt="Pacstrap System" ok else failure fi if [[ "${fs}" == "2" ]]; then local prompt="Fstab" local stage_prompt="Fstab" genfstab -t PARTUUID /mnt >> /mnt/etc/fstab 2> "${log}" || stage_fail arch-chroot /mnt <<-FSTAB_SBVL_MNT_OPTS > "${void}" 2>&1 2> "${log}" || stage_fail sed -i 's/rw,noatime,compress=zstd:3,discard=async,space_cache=v2/${sbvl_mnt_opts}/' /etc/fstab || exit FSTAB_SBVL_MNT_OPTS ok fi if [[ "${swapmode}" != "2" ]]; then line2 fi } ################################################################################################### swapfile() { local prompt="Swapfile Creation" local stage_prompt="Swapfile Creation" sleep 0.2 NC " ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Swapfile Setup${nc} ${magenta}]${nc}-------------------------------------${magenta}### " if arch-chroot /mnt <<-SWAPFILE > "${void}" 2>&1 2> "${log}" ; then mkswap -U clear --size ${swapsize}G --file /swapfile || exit SWAPFILE cat >> /mnt/etc/fstab <<-FSTAB || err_abort /swapfile none swap defaults 0 0 FSTAB ok else stage_fail fi } ################################################################################################### swapfile_btrfs() { local prompt="Btrfs Swapfile Creation" local stage_prompt="Btrfs Swapfile Creation" sleep 0.2 NC " ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Btrfs Swapfile Setup${nc} ${magenta}]${nc}----------------------------------${magenta}### " if arch-chroot /mnt <<-SWAPFILE_BTRFS > "${void}" 2>&1 2> "${log}" ; then btrfs filesystem mkswapfile --size ${swapsize}g --uuid clear /swap/swapfile || exit SWAPFILE_BTRFS cat >> /mnt/etc/fstab <<-FSTAB || err_abort /swap/swapfile none swap defaults 0 0 FSTAB ok else stage_fail fi } ################################################################################################### set_wireless_regdom() { local prompt="Wireless Regulatory Domain" local stage_prompt="Wireless Regulatory Domain" sleep 0.2 NC " ${magenta}###${nc}--------------------------${magenta}[ ${bwhite}Setting Up Wireless Regulatory Domain${nc} ${magenta}]${nc}--------------------------${magenta}### " if sed -i "/^#WIRELESS_REGDOM=\"${REGDOM}\"/s/^#//" /mnt/etc/conf.d/wireless-regdom ; then ok line2 else stage_fail fi } ################################################################################################### main_chroot() { local stage_prompt="Base System Configuration" if arch-chroot /mnt <<-CONF > "${void}" 2>&1 2> "${log}" ; then sed -i "/^#${SETLOCALE}/s/^#//" /etc/locale.gen || exit locale-gen || exit echo LANG=${SETLOCALE} > /etc/locale.conf || exit export LANG=${SETLOCALE} || exit echo KEYMAP=${SETKBD} > /etc/vconsole.conf || exit cat <<-MKINITCPIO > /etc/mkinitcpio.conf.d/mkinitcpiod.conf || exit ${mkinitcpio_mods} ${mkinitcpio_bins} ${mkinitcpio_hooks} MKINITCPIO mkinitcpio -P || exit ln -sf /usr/share/zoneinfo/$(curl -s http://ip-api.com/line?fields=timezone) /etc/localtime || exit hwclock --systohc || exit echo ${HOSTNAME} > /etc/hostname || exit cat <<-HOSTS > /etc/hosts || exit 127.0.0.1 localhost ::1 localhost 127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME} HOSTS echo root:${ROOTPASSWD2} | chpasswd || exit chsh -s /bin/${shellname} || exit useradd -m -G wheel -s /bin/${shellname} ${USERNAME} || exit echo ${USERNAME}:${USERPASSWD2} | chpasswd || exit echo "%wheel ALL=(ALL) ALL" | tee /etc/sudoers.d/sudoersd || exit visudo -c /etc/sudoers.d/sudoersd || exit CONF stage_ok else stage_fail fi } ################################################################################################### btldrcfg() { if [[ "${bootloader}" == "1" ]]; then local stage_prompt="Systemd-boot Configuration" if [[ "${xbootloader}" == "no" ]]; then if arch-chroot /mnt <<-SDBOOT_INSTL > "${void}" 2>&1 2> "${log}" ; then bootctl install || exit cat <<-LOADER_CFG > ${btldr_esp_mount}/loader/loader.conf || exit timeout 3 console-mode auto editor no LOADER_CFG systemctl enable systemd-boot-update || exit SDBOOT_INSTL stage_ok else stage_fail fi elif [[ "${xbootloader}" == "yes" ]]; then if arch-chroot /mnt <<-SDBOOT_XBOOTLDR_INSTL > "${void}" 2>&1 2> "${log}" ; then bootctl --esp-path=/efi --boot-path=/boot install || exit cat <<-LOADER_CFG > ${btldr_esp_mount}/loader/loader.conf || exit default arch.conf timeout 3 console-mode auto editor no LOADER_CFG cat <<-ENTRY_CFG > /boot/loader/entries/arch.conf || exit title Arch Linux linux /vmlinuz-${kernel} initrd /initramfs-${kernel}.img options rw ${boot_opts[*]} ENTRY_CFG systemctl enable systemd-boot-update || exit SDBOOT_XBOOTLDR_INSTL stage_ok else stage_fail fi fi elif [[ "${bootloader}" == "2" ]]; then local stage_prompt="Grub Configuration" if arch-chroot /mnt <<-GRUB_CONF > "${void}" 2>&1 2> "${log}" ; then cp /etc/default/grub /etc/default/grub.bak || exit cat <<-CFG > /etc/default/grub || exit GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="Arch" GRUB_CMDLINE_LINUX_DEFAULT="${boot_opts[*]}" GRUB_CMDLINE_LINUX="" GRUB_PRELOAD_MODULES="part_gpt part_msdos" GRUB_TIMEOUT_STYLE=menu GRUB_TERMINAL_INPUT=console GRUB_GFXMODE=auto GRUB_GFXPAYLOAD_LINUX=keep GRUB_DISABLE_RECOVERY=true GRUB_DISABLE_OS_PROBER=false #GRUB_TERMINAL_OUTPUT=console CFG GRUB_CONF stage_ok else stage_fail fi local stage_prompt="Grub Installation" if [[ "${sb_sign}" == "y" && "${path}" == "1" ]]; then if arch-chroot /mnt <<-SB_GRUB_INSTL > "${void}" 2>&1 2> "${log}" ; then grub-install --target=${uefimode} --efi-directory=${btldr_esp_mount} --bootloader-id=GRUB --modules="tpm" --disable-shim-lock --recheck || exit sed -i 's/SecureBoot/SecureB00t/' ${btldr_esp_mount}/EFI/GRUB/grubx${bitness}.efi || exit grub-mkconfig -o /boot/grub/grub.cfg || exit SB_GRUB_INSTL stage_ok else stage_fail fi elif [[ "${sb_sign}" == "y" && "${path}" == "2" ]]; then if arch-chroot /mnt <<-SB_GRUB_INSTL_RMV > "${void}" 2>&1 2> "${log}" ; then grub-install --target=${uefimode} --efi-directory=${btldr_esp_mount} --bootloader-id=GRUB --removable --modules="tpm" --disable-shim-lock --recheck || exit sed -i 's/SecureBoot/SecureB00t/' ${btldr_esp_mount}/EFI/BOOT/${efiname}.EFI || exit grub-mkconfig -o /boot/grub/grub.cfg || exit SB_GRUB_INSTL_RMV stage_ok else stage_fail fi elif [[ "${sb_sign}" == "n" && "${path}" == "1" ]]; then if arch-chroot /mnt <<-GRUB_INSTL > "${void}" 2>&1 2> "${log}" ; then grub-install --target=${uefimode} --efi-directory=${btldr_esp_mount} --bootloader-id=GRUB --recheck || exit grub-mkconfig -o /boot/grub/grub.cfg || exit GRUB_INSTL stage_ok else stage_fail fi elif [[ "${sb_sign}" == "n" && "${path}" == "2" ]]; then if arch-chroot /mnt <<-GRUB_INSTL_RMV > "${void}" 2>&1 2> "${log}" ; then grub-install --target=${uefimode} --efi-directory=${btldr_esp_mount} --bootloader-id=GRUB --removable --recheck || exit grub-mkconfig -o /boot/grub/grub.cfg || exit GRUB_INSTL_RMV stage_ok else stage_fail fi fi if [[ "${fs}" == "2" ]]; then local stage_prompt="Grub-Btrfsd Service Activation" if arch-chroot /mnt <<-GRUB_BTRFSD > "${void}" 2>&1 2> "${log}" ; then systemctl enable grub-btrfsd || exit GRUB_BTRFSD stage_ok else stage_fail fi fi if [[ "${nvdprop}" == "y" ]]; then local stage_prompt="Grub/Nvidia Configuration" if arch-chroot /mnt <<-NVIDIA_GRUB > "${void}" 2>&1 2> "${log}" ; then sed -i "/^#GRUB_TERMINAL_OUTPUT=console/s/^#//" /etc/default/grub || exit grub-mkconfig -o /boot/grub/grub.cfg || exit NVIDIA_GRUB stage_ok else stage_fail fi fi fi } ################################################################################################### trimcfg() { if [[ -n "${trim}" ]]; then local stage_prompt="Trim Service Activation" if arch-chroot /mnt <<-TRIM > "${void}" 2>&1 2> "${log}" ; then systemctl enable ${trim} || exit TRIM stage_ok else stage_fail fi fi } ################################################################################################### vm_serv() { if [[ -n "${vm_services}" ]]; then local stage_prompt="VM Service(s) Activation" if arch-chroot /mnt <<-VM_SRVC > "${void}" 2>&1 2> "${log}" ; then systemctl enable ${vm_services} || exit VM_SRVC stage_ok else stage_fail fi fi } ################################################################################################### zramcfg() { if [[ -n "${zram}" ]]; then local stage_prompt="Zram Swap Activation" zram_service="systemd-zram-setup@zram0.service" if arch-chroot /mnt <<-ZRAM_CONF > "${void}" 2>&1 2> "${log}" ; then mkdir -p /etc/systemd/zram-generator.conf.d || exit cat <<-ZRAM_GEN > /etc/systemd/zram-generator.conf.d/zram.conf || exit [zram0] zram-size = ram / 2 compression-algorithm = zstd ZRAM_GEN cat <<-ZRAM_VM > /etc/sysctl.d/99-vm-zram-parameters.conf || exit vm.swappiness = 180 vm.watermark_boost_factor = 0 vm.watermark_scale_factor = 125 vm.page-cluster = 0 ZRAM_VM systemctl daemon-reload || exit systemctl start ${zram_service} || exit ZRAM_CONF stage_ok else stage_fail fi fi } ################################################################################################### nvidia_hook() { if [[ "${nvdprop}" == "y" && -n "${nvname}" ]]; then local stage_prompt="Nvidia Hook Creation" if arch-chroot /mnt <<-NVIDIA_HOOK > "${void}" 2>&1 2> "${log}" ; then mkdir -p /etc/pacman.d/hooks/ || exit cat <<-HOOK > /etc/pacman.d/hooks/nvidia.hook || exit [Trigger] Operation=Install Operation=Upgrade Operation=Remove Type=Package Target=${nvname} Target=${kernel} [Action] Description=Updating 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' HOOK NVIDIA_HOOK stage_ok else stage_fail fi fi } ################################################################################################### mkinitcpio_preset() { local stage_prompt="Mkinitcpio Kernel Presets Configuration" if [[ "${uki}" == "y" ]]; then if [[ ! -e "${esp_mount}"/EFI/Linux ]]; then mkdir -p "${esp_mount}"/EFI/Linux || exit fi if arch-chroot /mnt <<-UKI > "${void}" 2>&1 2> "${log}" ; then mkdir /etc/cmdline.d || exit echo "rw ${boot_opts[*]}" | tee /etc/cmdline.d/cmdlined.conf || exit cp /etc/mkinitcpio.d/${kernel}.preset /etc/mkinitcpio.d/${kernel}.preset.bak || exit cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset || exit # mkinitcpio preset file for the '${kernel}' package ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf" ALL_kver="/boot/vmlinuz-${kernel}" PRESETS=('default') default_uki="${btldr_esp_mount}/EFI/Linux/arch-${kernel}.efi" MKINITCPIO_PRESET mkinitcpio -P || exit UKI stage_ok else stage_fail fi if [[ -e /mnt/boot/initramfs-"${kernel}".img ]]; then rm /mnt/boot/initramfs-"${kernel}".img || exit fi if [[ -e /mnt/boot/initramfs-"${kernel}"-fallback.img ]]; then rm /mnt/boot/initramfs-"${kernel}"-fallback.img || exit fi elif [[ "${uki}" == "n" ]]; then if arch-chroot /mnt <<-NO_UKI > "${void}" 2>&1 2> "${log}" ; then cp /etc/mkinitcpio.d/${kernel}.preset /etc/mkinitcpio.d/${kernel}.preset.bak || exit cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset || exit # mkinitcpio preset file for the '${kernel}' package ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf" ALL_kver="/boot/vmlinuz-${kernel}" PRESETS=('default') default_image="/boot/initramfs-${kernel}.img" MKINITCPIO_PRESET mkinitcpio -P || exit NO_UKI stage_ok else stage_fail fi fi } ################################################################################################### var_opts() { if [[ "${sb_sign}" == "y" && "${setrescue}" == "y" ]]; then local stage_prompt="Rescue Entry Creation" if [[ "${bootloader}" == "1" && "${uki}" == "y" ]]; then if arch-chroot /mnt <<-SDBOOT_RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then echo "systemd.unit=rescue.target rw ${boot_opts[*]}" | tee /etc/cmdline.d/rescued.conf || exit cat <<-MKINITCPIO_PRESET > /etc/mkinitcpio.d/${kernel}.preset || exit # mkinitcpio preset file for the '${kernel}' package ALL_config="/etc/mkinitcpio.conf.d/mkinitcpiod.conf" ALL_kver="/boot/vmlinuz-${kernel}" PRESETS=('default' 'rescue') default_uki="${btldr_esp_mount}/EFI/Linux/arch-${kernel}.efi" default_options="--cmdline /etc/cmdline.d/cmdlined.conf" rescue_uki="${btldr_esp_mount}/EFI/Linux/rescue.efi" rescue_options="--cmdline /etc/cmdline.d/rescued.conf" MKINITCPIO_PRESET mkinitcpio -P || exit SDBOOT_RESCUE_ENTRY stage_ok else stage_fail fi elif [[ "${bootloader}" == "1" && "${uki}" == "n" ]]; then if arch-chroot /mnt <<-SDBOOT_XBOOTLDR_RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then cat <<-XBOOTLDR_RESCUE_CONF > /boot/loader/entries/rescue.conf || exit title Arch Rescue linux /vmlinuz-${kernel} initrd /initramfs-${kernel}.img options rw systemd.unit=rescue.target ${boot_opts[*]} XBOOTLDR_RESCUE_CONF SDBOOT_XBOOTLDR_RESCUE_ENTRY stage_ok else stage_fail fi elif [[ "${bootloader}" == "2" ]]; then if arch-chroot /mnt <<-GRUB_RESCUE_ENTRY > "${void}" 2>&1 2> "${log}" ; then touch /boot/grub/custom.cfg grep -E -A 11 "'Arch Linux'" /boot/grub/grub.cfg > /boot/grub/custom.cfg || exit sed -i 's/Arch Linux/Rescue Environment/' /boot/grub/custom.cfg || exit sed -i '/vmlinuz/ s/$/ systemd.unit=rescue.target/' /boot/grub/custom.cfg || exit GRUB_RESCUE_ENTRY stage_ok else stage_fail fi fi fi if [[ "${multilib}" == "y" ]]; then local stage_prompt="Multilib Configuration" if arch-chroot /mnt <<-MULTILIB > "${void}" 2>&1 2> "${log}" ; then sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf || exit pacman -Syy || exit MULTILIB stage_ok else stage_fail fi fi if [[ "${CPU}" == *"GenuineIntel"* && "${kill_watchdog}" == "y" ]]; then local stage_prompt="Intel Watchdog Configuration" if arch-chroot /mnt <<-INTEL_WATCHDOG > "${void}" 2>&1 2> "${log}" ; then echo "blacklist iTCO_wdt" | tee /etc/modprobe.d/blacklist.conf || exit INTEL_WATCHDOG stage_ok else stage_fail fi elif [[ "${CPU}" == *"AuthenticAMD"* && "${kill_watchdog}" == "y" ]]; then local stage_prompt="AMD Watchdog Configuration" if arch-chroot /mnt <<-AMD_WATCHDOG > "${void}" 2>&1 2> "${log}" ; then echo "blacklist sp5100_tco" | tee /etc/modprobe.d/blacklist.conf || exit AMD_WATCHDOG stage_ok else stage_fail fi fi if [[ "${oomd}" == "y" ]]; then local stage_prompt="Systemd-oomd Service Activation" if arch-chroot /mnt <<-OOMD > "${void}" 2>&1 2> "${log}" ; then mkdir -p /etc/systemd/system.conf.d > "${void}" 2>&1 || exit cat <<-OOMD_CONF > /etc/systemd/system.conf.d/00-oomd.conf || exit [Manager] DefaultMemoryAccounting=yes OOMD_CONF systemctl enable systemd-oomd || exit OOMD stage_ok else stage_fail fi fi if [[ "${irqbalance}" == "y" ]]; then local stage_prompt="Irqbalance Service Activation" if arch-chroot /mnt <<-IRQBALANCE > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm irqbalance || exit systemctl enable irqbalance || exit IRQBALANCE stage_ok else stage_fail fi fi if [[ "${thermald}" == "y" ]]; then local stage_prompt="Thermald Service Activation" if arch-chroot /mnt <<-THERMALD > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm thermald || exit systemctl enable thermald || exit THERMALD stage_ok else stage_fail fi fi if [[ "${rngd}" == "y" ]]; then local stage_prompt="Rngd Service Activation" if arch-chroot /mnt <<-RNGD > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm rng-tools || exit systemctl enable rngd || exit RNGD stage_ok else stage_fail fi fi if [[ "${rtkit}" == "y" ]]; then local stage_prompt="Rtkit Service Activation" if arch-chroot /mnt <<-RTKIT > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm realtime-privileges rtkit || exit systemctl enable rtkit-daemon || exit usermod -aG realtime ${USERNAME} RTKIT stage_ok else stage_fail fi fi if [[ "${tlp}" == "y" ]]; then local stage_prompt="Power-profiles-daemon Removal" if [[ -e usr/lib/power-profiles-daemon ]]; then if arch-chroot /mnt <<-PPD > "${void}" 2>&1 2> "${log}" ; then pacman -Rns --noconfirm power-profiles-daemon || exit PPD stage_ok else stage_fail fi fi local stage_prompt="Tlp Service Activation" if arch-chroot /mnt <<-TLP > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm tlp || exit systemctl enable tlp systemctl mask systemd-rfkill.service systemd-rfkill.socket || exit TLP stage_ok else stage_fail fi fi if [[ "${printer}" == "y" ]]; then local stage_prompt="Print & Scan Services Activation" if arch-chroot /mnt <<-PRINT_CONF > "${void}" 2>&1 2> "${log}" ; then systemctl enable avahi-daemon.socket cups.socket cups-browsed ipp-usb || exit sed -i 's|^hosts.*|hosts: mymachines mdns_minimal resolve [!UNAVAIL=return] files myhostname dns|g' /etc/nsswitch.conf || exit sed -i 's/ interface = [^ ]*/ interface = all/g' /etc/ipp-usb/ipp-usb.conf || exit PRINT_CONF stage_ok else stage_fail fi fi } ################################################################################################### foreign() { if [[ -n "${web_aur}" ]]; then local stage_prompt="Base-devel Installation" if [[ "${dev}" != "y" ]]; then if arch-chroot /mnt <<-BASE_DEVEL > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm base-devel || exit BASE_DEVEL stage_ok else stage_fail fi fi local stage_prompt="Git Installation" if [[ "${desktop}" =~ ^(11|12)$ ]]; then if arch-chroot /mnt <<-GIT > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm git || exit GIT stage_ok else stage_fail fi fi local stage_prompt="AUR Packages Installation" if arch-chroot /mnt <<-AUR_GIT_PKGS > "${void}" 2>&1 2> "${log}" ; then sed -i 's|if (( EUID == 0 )); then|if (( EUID != 0 )); then|g' /usr/bin/makepkg || exit git clone --branch ${web_aur} --single-branch https://github.com/archlinux/aur.git ${web_aur} && cd ${web_aur} && makepkg -s --noconfirm && sudo pacman -U --noconfirm *x86_64.pkg.tar.zst && cd .. && rm -rf ${web_aur} || exit sed -i 's|if (( EUID != 0 )); then|if (( EUID == 0 )); then|g' /usr/bin/makepkg || exit AUR_GIT_PKGS stage_ok else stage_fail fi fi } ################################################################################################### optimizations() { if [[ "${genoptm}" == "y" ]]; then local stage_prompt="General System Optimizations" if arch-chroot /mnt <<-GEN_OPTM > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm ccache ntfs-3g pbzip2 pigz || exit sed -i 's/^#Color/Color\nILoveCandy/' /etc/pacman.conf || exit update-pciids || exit cat <<-MKINITCPIO >> /etc/mkinitcpio.conf.d/mkinitcpiod.conf || exit COMPRESSION="zstd" COMPRESSION_OPTIONS=(-c -T$(nproc) --auto-threads=logical -) MODULES_DECOMPRESS="yes" MKINITCPIO mkinitcpio -P || exit cat <<-MAKEPKG > /etc/makepkg.conf.d/makepkgd.conf || exit #!/hint/bash 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" 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 --auto-threads=logical -) MAKEPKG cat <<-IO_SCHED > /etc/udev/rules.d/60-ioschedulers.rules || exit # HDD ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq" # SSD ACTION=="add|change", KERNEL=="sd[a-z]*|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="bfq" # NVMe SSD ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none" IO_SCHED cat <<-SYSCTL > /etc/sysctl.d/99-sysctld.conf || exit net.core.netdev_max_backlog = 16384 net.ipv4.tcp_fastopen = 3 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_slow_start_after_idle = 0 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 vm.vfs_cache_pressure = 50 vm.mmap_min_addr = 65536 kernel.printk = 0 0 0 0 ${perf_stream} SYSCTL cat <<-POLKIT > /etc/polkit-1/rules.d/99-udisks2.rules || exit // 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]; } }); POLKIT mkdir -p /etc/systemd/journald.conf.d > ${void} 2>&1 || exit cat <<-JOURNAL > /etc/systemd/journald.conf.d/00-journald.conf || exit [Journal] SystemMaxUse=100M JOURNAL mkdir -p /etc/systemd/user.conf.d > ${void} 2>&1 || exit cat <<-TIMEOUT > /etc/systemd/user.conf.d/00-timeout.conf || exit [Manager] DefaultTimeoutStopSec=5s DefaultTimeoutAbortSec=5s TIMEOUT sed -i \ -e '/^# set linenumbers/s/^#//' \ -e '/^# set minibar/s/^#//' \ -e '/^# set mouse/s/^#//' /etc/nanorc || exit echo " include /usr/share/nano/*.nanorc" | tee -a /etc/nanorc || exit echo tcp_bbr | tee /etc/modules-load.d/modulesd.conf || exit cat <<-SUDOERS > /etc/sudoers.d/sudoersd || exit Defaults pwfeedback Defaults editor=/usr/bin/nano %wheel ALL=(ALL) ALL SUDOERS visudo -c /etc/sudoers.d/sudoersd || exit GEN_OPTM stage_ok else stage_fail fi if [[ -d /mnt/etc/udisks2 ]]; then local stage_prompt="Udisks2 Mount Options" if arch-chroot /mnt <<-UDISKS2 > "${void}" 2>&1 2> "${log}" ; then cat <<-UDISKS_CONF > /etc/udisks2/mount_options.conf || exit [defaults] ntfs_drivers=ntfs3,ntfs ntfs:ntfs3_defaults=uid=*,gid=*,windows_names ntfs:ntfs_defaults=uid=*,gid=*,windows_names exfat_defaults=uid=*,gid=*,errors=remount-ro UDISKS_CONF UDISKS2 stage_ok else stage_fail fi fi if [[ -n "${REGDOM}" ]]; then local stage_prompt="Wpa_Supplicant Configuration" if arch-chroot /mnt <<-WPA > "${void}" 2>&1 2> "${log}" ; then cat <<-SUPPLICANT > /etc/wpa_supplicant/wpa_supplicant.conf || exit country=${REGDOM} wps_cred_add_sae=1 pmf=2 SUPPLICANT WPA stage_ok else stage_fail fi fi fi } ################################################################################################### view_optm() { if [[ "${genoptm}" == "v" ]]; then typeset -f optimizations |grep -E 'pacman|/pacman.conf|update-pciids|usermod|systemctl|/etc|/mkinitcpio.conf.d|/makepkg.conf.d|/sysctl.d|/polkit-1/rules.d|/systemd/journald.conf.d|/systemd/user.conf.d|/nanorc|/modules-load.d|/sudoers.d|/udisks2|/wpa_supplicant|/udev/rules.d' | less fi } ################################################################################################### secboot_sign() { if [[ "${sb_sign}" == "y" ]]; then local stage_prompt="Secure-Boot Signing" if [[ "${bootloader}" == "1" && "${uki}" == "y" ]]; then if arch-chroot /mnt <<-SDBOOT_SEC_SIGN > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm sbctl || exit sbctl create-keys || exit sbctl enroll-keys -m || exit sbctl sign -s /boot/vmlinuz-${kernel} || exit sbctl sign -s ${btldr_esp_mount}/EFI/BOOT/${efiname}.EFI || exit sbctl sign -s ${btldr_esp_mount}/EFI/Linux/arch-${kernel}.efi || exit sbctl sign -s ${btldr_esp_mount}/EFI/systemd/systemd-bootx${bitness}.efi || exit sbctl sign -s -o /usr/lib/systemd/boot/efi/systemd-bootx${bitness}.efi.signed /usr/lib/systemd/boot/efi/systemd-bootx${bitness}.efi || exit SDBOOT_SEC_SIGN stage_ok else stage_fail fi if [[ "${setrescue}" == "y" ]]; then local stage_prompt="Rescue Entry Secure-Boot Signing" if arch-chroot /mnt <<-SDBOOT_RESCUE_SEC_SIGN > "${void}" 2>&1 2> "${log}" ; then sbctl sign -s ${btldr_esp_mount}/EFI/Linux/rescue.efi || exit SDBOOT_RESCUE_SEC_SIGN stage_ok else stage_fail fi fi elif [[ "${bootloader}" == "1" && "${uki}" == "n" ]]; then if arch-chroot /mnt <<-SD_XBOOTLDR_SEC_SIGN > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm sbctl || exit sbctl create-keys || exit sbctl enroll-keys -m || exit sbctl sign -s /boot/vmlinuz-${kernel} || exit sbctl sign -s ${btldr_esp_mount}/EFI/BOOT/${efiname}.EFI || exit sbctl sign -s ${btldr_esp_mount}/EFI/systemd/systemd-bootx${bitness}.efi || exit sbctl sign -s -o /usr/lib/systemd/boot/efi/systemd-bootx${bitness}.efi.signed /usr/lib/systemd/boot/efi/systemd-bootx${bitness}.efi || exit SD_XBOOTLDR_SEC_SIGN stage_ok else stage_fail fi elif [[ "${bootloader}" == "2" ]]; then if [[ "${path}" == "1" ]]; then if arch-chroot /mnt <<-GRUB_SEC_SIGN > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm sbctl || exit sbctl create-keys || exit sbctl enroll-keys -m || exit sbctl sign -s /boot/vmlinuz-${kernel} || exit sbctl sign -s ${btldr_esp_mount}/EFI/GRUB/grubx${bitness}.efi || exit GRUB_SEC_SIGN stage_ok else stage_fail fi elif [[ "${path}" == "2" ]]; then if arch-chroot /mnt <<-GRUB_FALLBACK_SEC_SIGN > "${void}" 2>&1 2> "${log}" ; then pacman -S --noconfirm sbctl || exit sbctl create-keys || exit sbctl enroll-keys -m || exit sbctl sign -s /boot/vmlinuz-${kernel} || exit sbctl sign -s ${btldr_esp_mount}/EFI/BOOT/${efiname}.EFI || exit GRUB_FALLBACK_SEC_SIGN stage_ok else stage_fail fi fi fi fi } ################################################################################################### set_vars() { if [[ "${multibooting}" == "y" && "${xbootloader}" == "yes" ]]; then uki="n" fi # Mkinitcpio Modules/Binaries/Hooks MODULES=() BINARIES=() HOOKS=() #-------------------------------------------------------------------------------------------------- # BINARIES SETUP # Btrfs Mkinitcpio Binary [[ "${fs}" == "2" ]] && BINARIES+=(/usr/bin/btrfs) #-------------------------------------------------------------------------------------------------- # LUKS ENCRYPTION if [[ "${encrypt}" == "yes" ]]; then # Encrypted Root Device encr_root_dev="/dev/mapper/CryptRoot" # Encrypted Root Options encr_root_opts="rd.luks.name=$(blkid -s UUID -o value "${root_dev}")=CryptRoot" # ATTENTION LUKS ROOT KERNEL CMDLINE encr_root_bootopts="${encr_root_opts} root=${encr_root_dev}" #-------------------------------------------------------------------------------------------------- # LUKS SWAP SETUP # Encrypted Swap Partition if [[ "${swapmode}" == "1" ]]; then # Encrypted Swap Partition Options encr_swap_opts="rd.luks.name=$(blkid -s UUID -o value "${swap_dev}")=CryptSwap" # ATTENTION LUKS SWAP PARTITION KERNEL CMDLINE encr_swap_bootopts="resume=/dev/mapper/CryptSwap ${encr_swap_opts}" # Encrypted Swapfile elif [[ "${swapmode}" == "2" ]]; then # Ext4 Offset calculation if [[ "${fs}" == "1" ]]; then offst="$(filefrag -v /mnt/swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}')" # Btrfs Offset calculation elif [[ "${fs}" == "2" ]]; then offst="$(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile)" fi # ATTENTION LUKS SWAPFILE KERNEL CMDLINE encr_swap_bootopts="resume=${encr_root_dev} resume_offset=${offst}" fi #-------------------------------------------------------------------------------------------------- # LUKS HOOKS SETUP # Nvidia Proprietary GFX Hooks if [[ "${nvdprop}" == "y" ]]; then HOOKS+=(systemd keyboard autodetect microcode modconf sd-vconsole block sd-encrypt filesystems) # Open-source GFX Hooks else HOOKS+=(systemd keyboard autodetect microcode modconf kms sd-vconsole block sd-encrypt filesystems) fi # Add Fsck Hook [[ "${fs}" == "1" ]] && HOOKS+=(fsck) #-------------------------------------------------------------------------------------------------- # LUKS MODULES SETUP # LUKS Mkinitcpio Modules MODULES+=("${fs_mod}") #-------------------------------------------------------------------------------------------------- # ATTENTION MAIN KERNEL CMDLINE boot_opts=("${encr_root_bootopts}") # If LUKS Swap: [[ -n "${encr_swap_bootopts}" ]] && boot_opts+=("${encr_swap_bootopts}") #-------------------------------------------------------------------------------------------------- # NO ENCRYPTION elif [[ "${encrypt}" == "no" ]]; then # HOOKS SETUP # Nvidia Proprietary GFX Hooks if [[ "${nvdprop}" == "y" ]]; then HOOKS+=(systemd autodetect microcode modconf keyboard sd-vconsole block filesystems) # Open-source GFX Hooks else HOOKS+=(systemd autodetect microcode modconf kms keyboard sd-vconsole block filesystems) fi # Add Fsck Hook [[ "${fs}" == "1" ]] && HOOKS+=(fsck) #-------------------------------------------------------------------------------------------------- # ATTENTION MAIN KERNEL CMDLINE boot_opts=() # If Multiroot: [[ "${autoroot}" == "y" ]] && boot_opts+=("${multiroot_bootopts}") fi #-------------------------------------------------------------------------------------------------- # GFX CONFIGURATION # Gfx Kernel Cmdline gfx_bootopts=() # Nvidia Proprietary if [[ "${nvdprop}" == "y" ]]; then MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm) gfx_bootopts+=(nvidia.NVreg_UsePageAttributeTable=1) # MultiGfx with Intel [[ "${vendors}" =~ "Intel" ]] && MODULES+=(i915) # MultiGfx with AMD [[ "${vendors}" =~ "AMD" ]] && MODULES+=(amdgpu) # Disable GSP Firmware [[ "${nogsp}" == "y" ]] && gfx_bootopts+=(nvidia.NVreg_EnableGpuFirmware=0) # Enable Experimental Low Latency Interrupts [[ "${lowlat}" == "y" ]] && gfx_bootopts+=(nvidia.NVreg_RegistryDwords=RMIntrLockingMode=1) fi # AMD if [[ "${vendor}" == "AMD" || "${vendors}" =~ "AMD" ]]; then if [[ -n "${islands}" && -z "${nvdprop}" ]]; then MODULES+=(amdgpu) fi # 'Southern Islands' support if [[ "${islands}" == "1" ]]; then gfx_bootopts+=(amdgpu.dc=1 radeon.si_support=0 amdgpu.si_support=1) # 'Sea Islands' support elif [[ "${islands}" == "2" ]]; then gfx_bootopts+=(amdgpu.dc=1 radeon.cik_support=0 amdgpu.cik_support=1) fi fi #-------------------------------------------------------------------------------------------------- # ATTENTION ADD TO MAIN KERNEL CMDLINE [[ -n "${gfx_bootopts[*]}" ]] && boot_opts+=("${gfx_bootopts[*]}") [[ -n "${cust_bootopts}" ]] && boot_opts+=("${cust_bootopts}") [[ -n "${btrfs_bootopts}" ]] && boot_opts+=("${btrfs_bootopts}") [[ "${swapmode}" == "3" ]] && boot_opts+=(zswap.enabled=0) [[ "${kill_watchdog}" == "y" ]] && boot_opts+=(nowatchdog) #-------------------------------------------------------------------------------------------------- # MAIN MKINITCPIO MODULES mkinitcpio_mods="MODULES=(${MODULES[*]})" # MAIN MKINITCPIO BINARIES mkinitcpio_bins="BINARIES=(${BINARIES[*]})" # MAIN MKINITCPIO HOOKS mkinitcpio_hooks="HOOKS=(${HOOKS[*]})" } ################################################################################################### chroot_conf() { if [[ "${swapmode}" == "2" ]]; then line2 fi sleep 0.2 NC " ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}Chroot & Configure System${nc} ${magenta}]${nc}--------------------------------${magenta}###${nc} " # Desktops Configuration: if [[ "${desktop}" != "12" ]]; then cnfg main_chroot if [[ -f /mnt/etc/lightdm/lightdm.conf ]]; then if [[ "${desktop}" == "7" ]]; then local stage_prompt="Deepin Greeter Configuration" if arch-chroot /mnt <<-DEEPIN > "${void}" 2>&1 2> "${log}" ; then sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-deepin-greeter|g' /etc/lightdm/lightdm.conf || exit DEEPIN stage_ok else stage_fail fi elif [[ "${desktop}" =~ ^(5|8|10)$ ]]; then local stage_prompt="GTK Greeter Configuration" if arch-chroot /mnt <<-GTK > "${void}" 2>&1 2> "${log}" ; then sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-gtk-greeter|g' /etc/lightdm/lightdm.conf || exit GTK stage_ok else stage_fail fi elif [[ "${desktop}" == "6" ]]; then local stage_prompt="Slick Greeter Configuration" if arch-chroot /mnt <<-SLICK > "${void}" 2>&1 2> "${log}" ; then sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-slick-greeter|g' /etc/lightdm/lightdm.conf || exit SLICK stage_ok else stage_fail fi fi fi if [[ "${vendor}" != "Virtual Machine" && "${desktop}" != "11" ]]; then local stage_prompt="Bluetooth Services Activation" if arch-chroot /mnt <<-BLUETOOTH > "${void}" 2>&1 2> "${log}" ; then systemctl enable bluetooth || exit BLUETOOTH stage_ok else stage_fail fi fi if [[ -n "${displaymanager}" ]]; then local stage_prompt="Display Manager Service Activation" if arch-chroot /mnt <<-DM > "${void}" 2>&1 2> "${log}" ; then systemctl enable ${displaymanager} || exit DM stage_ok else stage_fail fi fi if [[ "${desktop}" != "12" ]]; then local stage_prompt="Network Manager Service Activation" if arch-chroot /mnt <<-NETWORK > "${void}" 2>&1 2> "${log}" ; then systemctl enable NetworkManager || exit NETWORK stage_ok else stage_fail fi fi fi #-------------------------------------------------------------------------------------------------- # Custom System Configuration: if [[ "${desktop}" == "12" ]]; then cnfg main_chroot if [[ -f /mnt/etc/lightdm/lightdm.conf ]]; then if [[ "${greeternmbr}" == "1" ]]; then local stage_prompt="GTK Greeter Configuration" if arch-chroot /mnt <<-GTK > "${void}" 2>&1 2> "${log}" ; then sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-gtk-greeter|g' /etc/lightdm/lightdm.conf || exit GTK stage_ok else stage_fail fi elif [[ "${greeternmbr}" == "2" ]]; then local stage_prompt="Slick Greeter Configuration" if arch-chroot /mnt <<-SLICK > "${void}" 2>&1 2> "${log}" ; then sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-slick-greeter|g' /etc/lightdm/lightdm.conf || exit SLICK stage_ok else stage_fail fi elif [[ "${greeternmbr}" == "3" ]]; then local stage_prompt="Deepin Greeter Configuration" if arch-chroot /mnt <<-DEEPIN > "${void}" 2>&1 2> "${log}" ; then sed -i 's|^#greeter-session=example-gtk-gnome|greeter-session=lightdm-deepin-greeter|g' /etc/lightdm/lightdm.conf || exit DEEPIN stage_ok else stage_fail fi fi fi if [[ -n "${customservices}" ]]; then local stage_prompt="Custom Service(s) Activation" if arch-chroot /mnt <<-CUSTOM_SRVC > "${void}" 2>&1 2> "${log}" ; then systemctl enable ${customservices} || exit CUSTOM_SRVC stage_ok else stage_fail fi fi fi btldrcfg trimcfg vm_serv zramcfg nvidia_hook mkinitcpio_preset var_opts foreign optimizations secboot_sign completion installation="ok" umount -R /mnt reboot exit } # END SYSTEM FUNCTIONS ################################################################################################### clear run_as="$(whoami)" tty="$(tty)" void="/dev/null" log="Amelia.log" disks="$(lsblk --nodeps --paths --noheadings --output=name,size,model | cat --number)" trg="" vars=(LOCALESET="" SETLOCALE="" lcl_slct="" USERNAME="" kernelnmbr="" fs="" gfxcount="" gfxcard="" intelcount="" intelcards="" nvidiacount="" nvidiacards="" amdcount="" amdcards="" vendor="" vendors="" desktop="" terminal="" efi_entr_del="" sanity="" install="" bootldr_pkgs="" devel="" REGDOM="" gfx_bootopts="" btrfs_bootopts="" trim="" swapmode="" homecrypt="" greeter="" greeternmbr="" cust_bootopts="" vmpkgs="" vm_services="" perf_stream="" displaymanager="" wireless_reg="" bitness="" bootloader="" gfx_slct="" espsize="" autoroot="" autoesp="" autoxboot="" autohome="" autoswap="" rootprt="" espprt="" xbootprt="" homeprt="" swapprt="" partok="" instl_drive="" sgdsk_nmbr="" part_mode="" preset="" capacity="" cap_gib="" rootsize="" sgdrive="" cgdrive="" smartpart="" presetpart="" prcnt="" roottype="" stage_prompt="" zram="" xbootloader="" multibooting="" hypervisor="" mkinitcpio_mods="" mkinitcpio_bins="" uki="" ukify="" cng_espmnt="" sep_home="" encr_swap_bootopts="" uefimode="" luks_encrypt="" nrg_plc="" multilib="" nvname="" nogsp="" luks_root="" luks_swap="" luks_home="" installation="" kill_watchdog="" oomd="" setrescue="" lowlat="" dev="" web="" web_pkg="" web_aur="" web_slct="" printer="" print_pkgs="" shellnmbr="" shell="" shellname="" shellname2="" shell_pkgs="" genoptm="" set_optm="" ask_param="" desk_setup="" irqbalance="" thermald="" rngd="" rtkit="" tlp="" CRYPTPASS="" CRYPTPASS2="" askoptm="" gptslct="" gptok="" gptabort="" nvdprop="" nowarning="" efiname="" path="" hometype="" homeform="" LuksParts="") export "${vars[@]}" sleep 0.2 CYANBG "************************************************************************************************* " CYANBG " " CYANBG " ### Amelia Installer ### " CYANBG " " CYANBG "************************************************************************************************* " mode_check line3 line3 keypress clear set_font arch uefi_check connection_check upd_clock machine_dtct until main_menu; do : ; done