Change: When running in 'KVM-QEMU', the installer will no longer enable the 'qemu-guest-agent' service, as the said service gets automatically enabled.

Change: The list of kernel parameters to be set for the installed system, now derives from a versatile array, instead of the 'hard-coded' variables previously used.
Change: Some code optimization has taken place.
Change: A few prompts have been edited/added for enhanced clarity.
This commit is contained in:
Jane Doe 2025-01-04 12:01:10 +00:00
parent 5b509a665d
commit c956eb6c9a

280
Amelia.sh
View file

@ -2,7 +2,7 @@
# Amelia Installer
# https://gitlab.com/prism7/archery
# Version: 8.3.1
# Version: 8.3.2
set -euo pipefail
###################################################################################################
@ -74,6 +74,7 @@ NC() {
skip() {
sleep 0.2
YELLOW "
--> Skipping.. "
}
reload() {
@ -462,18 +463,15 @@ dtct_hyper() {
if [[ "${hypervisor}" != "none" ]]; then
vendor="Virtual Machine"
vgaconf="n"
vgapkgs=""
fi
case "${hypervisor}" in
kvm)
vmpkgs="spice spice-vdagent spice-protocol spice-gtk qemu-guest-agent swtpm"
vm_services="qemu-guest-agent" ;;
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"
vm_services="" ;;
vmpkgs="virtualbox-guest-utils" ;;
microsoft)
vmpkgs="hyperv"
vm_services="hv_kvp_daemon hv_vss_daemon" ;;
@ -1257,7 +1255,7 @@ Enter [Y/n]: "
fs_mod="btrfs"
fstools="btrfs-progs"
roottype="/@"
btrfs_bootopts="rootflags=subvol=@ "
btrfs_bootopts="rootflags=subvol=@"
sleep 0.2
YELLOW "
@ -1356,8 +1354,7 @@ Enter a number: "
sleep 0.2
YELLOW "
### No Swap will be used
"
### No Swap will be used "
skip ;;
"")
choice
@ -1584,13 +1581,20 @@ Enter a number: "
read -r -p "
==> " vendor_slct
if [[ "${vendor_slct}" == "1" ]]; then
vendor="Intel"
elif [[ "${vendor_slct}" == "2" ]]; then
vendor="AMD"
else
vendor="none"
fi
case "${vendor_slct}" in
1)
vendor="Intel" ;;
2)
vendor="AMD" ;;
3)
vendor="none" ;;
"")
choice
return 1 ;;
*)
invalid
return 1 ;;
esac
elif [[ -n "${vendor1}" && -n "${vendor3}" ]]; then
NC "
@ -1607,13 +1611,20 @@ Enter a number: "
read -r -p "
==> " vendor_slct
if [[ "${vendor_slct}" == "1" ]]; then
vendor="Intel"
elif [[ "${vendor_slct}" == "2" ]]; then
vendor="Nvidia"
else
vendor="none"
fi
case "${vendor_slct}" in
1)
vendor="Intel" ;;
2)
vendor="Nvidia" ;;
3)
vendor="none" ;;
"")
choice
return 1 ;;
*)
invalid
return 1 ;;
esac
elif [[ -n "${vendor2}" && -n "${vendor3}" ]]; then
NC "
@ -1630,13 +1641,20 @@ Enter a number: "
read -r -p "
==> " vendor_slct
if [[ "${vendor_slct}" == "1" ]]; then
vendor="AMD"
elif [[ "${vendor_slct}" == "2" ]]; then
vendor="Nvidia"
else
vendor="none"
fi
case "${vendor_slct}" in
1)
vendor="AMD" ;;
2)
vendor="Nvidia" ;;
3)
vendor="none" ;;
"")
choice
return 1 ;;
*)
invalid
return 1 ;;
esac
fi
if [[ "${vendor}" == "Intel" || "${vendor}" == "AMD" ]]; then
sourcetype="Open-source"
@ -1646,8 +1664,6 @@ Enter a number: "
vgaconf="y"
elif [[ "${vendor}" == "none" ]]; then
vgaconf="n"
vgapkgs=""
echo
skip
ok
return 0
@ -1688,25 +1704,30 @@ vga_conf() {
Enter a number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " islands
if [[ -z "${islands}" ]]; then
skip
echo
elif [[ "${islands}" == "1" ]]; then
NC "
case "${islands}" in
1)
sleep 0.2
NC "
==> [${green}Southern Islands OK${nc}]
"
elif [[ "${islands}" == "2" ]]; then
NC "
" ;;
2)
sleep 0.2
NC "
==> [${green}Sea Islands OK${nc}]
"
else
invalid
return 1
fi
" ;;
"")
skip
echo ;;
*)
invalid
return 1 ;;
esac
elif [[ "${vendor}" == "Nvidia" ]]; then
sleep 0.2
YELLOW "
@ -1723,49 +1744,46 @@ Enter a number: "
read -r -p "
==> " family
if [[ "${family}" == "1" ]]; then
sleep 0.2
NC "
case "${family}" in
1) # Turing+ Family
sleep 0.2
NC "
==> [${green}Turing+ OK${nc}]
"
elif [[ "${family}" == "2" ]]; then
sleep 0.2
NC "
"
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia-open"
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-open nvidia-settings nvidia-utils opencl-nvidia vkd3d"
# Other Kernels
else
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-open-dkms nvidia-settings nvidia-utils opencl-nvidia vkd3d"
fi ;;
2) # Maxwell+ Family
sleep 0.2
NC "
==> [${green}Maxwell+ OK${nc}]
"
else
echo
invalid
return 1
fi
# Turing+ Family
if [[ "${family}" == "1" ]]; then
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia-open"
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-open nvidia-settings nvidia-utils opencl-nvidia vkd3d"
# Other Kernels
else
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-open-dkms nvidia-settings nvidia-utils opencl-nvidia vkd3d"
fi
# Maxwell+ Family
elif [[ "${family}" == "2" ]]; then
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia"
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia nvidia-settings nvidia-utils opencl-nvidia vkd3d"
# Linux LTS Kernel
elif [[ "${kernelnmbr}" == "2" ]]; then
nvname="nvidia-lts"
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-lts nvidia-settings nvidia-utils opencl-nvidia vkd3d"
# Other Kernels
else
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-dkms nvidia-settings nvidia-utils opencl-nvidia vkd3d"
fi
fi
"
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia"
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia nvidia-settings nvidia-utils opencl-nvidia vkd3d"
# Linux LTS Kernel
elif [[ "${kernelnmbr}" == "2" ]]; then
nvname="nvidia-lts"
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-lts nvidia-settings nvidia-utils opencl-nvidia vkd3d"
# Other Kernels
else
vgapkgs="libva-nvidia-driver libvdpau-va-gl nvidia-dkms nvidia-settings nvidia-utils opencl-nvidia vkd3d"
fi ;;
"")
choice
return 1 ;;
*)
invalid
return 1 ;;
esac
if [[ "${swapmode}" == "3" || "${swapmode}" == "4" ]]; then
sleep 0.2
@ -1791,7 +1809,6 @@ Enter a number: "
if [[ "${vendor}" == "nvidia" ]]; then
vgapkgs="vulkan-nouveau"
fi
echo
skip
fi
vga_slct="yes"
@ -1887,7 +1904,6 @@ Enter [Y/n]: "
==> [${green}Terminal OK${nc}] " ;;
n)
echo
skip ;;
*)
invalid
@ -1926,7 +1942,6 @@ Enter [Y/n]: "
==> [${green}Terminal OK${nc}] " ;;
n)
echo
skip ;;
*)
invalid
@ -1980,7 +1995,6 @@ Enter [Y/n]: "
==> [${green}base-devel OK${nc}] " ;;
n)
echo
skip ;;
*)
invalid
@ -2008,7 +2022,6 @@ Enter [y/N]: "
y)
add_prmtrs ;;
n)
echo
skip ;;
*)
invalid
@ -2132,7 +2145,6 @@ Enter services to be enabled ${bwhite}(space-seperated)${blue}: "
==> " customservices
if [[ -z "${customservices}" ]]; then
echo
skip
else
ok
@ -2160,7 +2172,6 @@ Enter your Kernel parameters to be set at boot ${bwhite}(space-seperated)${blue}
==> " cust_bootopts
if [[ -z "${cust_bootopts}" ]]; then
echo
skip
else
ok
@ -2269,7 +2280,6 @@ Enter your Country Code, ie:${nc} ${cyan}US ${bwhite}(empty to skip)${blue}: "
==> " REGDOM
if [[ -z "${REGDOM}" ]]; then
echo
skip
elif [[ "${REGDOM}" == "l" ]]; then
sed 's|^#WIRELESS_REGDOM=||g' /etc/conf.d/wireless-regdom |sed 's|"||g'| more
@ -2583,8 +2593,8 @@ ${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}Automati
"
read -r -p "
==> " smartpart
echo
if [[ "${smartpart}" == "y" ]]; then
sgdsk_nmbr="${instl_dsk_nmbr}"
elif [[ "${smartpart}" == "n" ]]; then
@ -3041,7 +3051,7 @@ ${multi_root}
if [[ "${autoroot}" == "y" ]]; then
root_dev="${root_comply}"
multiroot_bootopts="root=PARTUUID=$(blkid -s PARTUUID -o value "${root_dev}") "
multiroot_bootopts="root=PARTUUID=$(blkid -s PARTUUID -o value "${root_dev}")"
elif [[ "${autoroot}" == "n" ]]; then
stage_fail
else
@ -5545,7 +5555,7 @@ XBOOTCTL
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="${boot_opts}"
GRUB_CMDLINE_LINUX_DEFAULT="${boot_opts[*]}"
GRUB_CMDLINE_LINUX=""
GRUB_PRELOAD_MODULES="part_gpt part_msdos"
GRUB_TIMEOUT_STYLE=menu
@ -5707,7 +5717,7 @@ mkinitcpio_preset() {
fi
if arch-chroot /mnt <<-UKI > /dev/null 2>&1 2> amelia_log.txt ; then
mkdir /etc/cmdline.d || exit
echo "rw ${boot_opts}" | tee /etc/cmdline.d/cmdlined.conf || 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 <<-MKINITPRESET > /etc/mkinitcpio.d/${kernel}.preset || exit
ALL_kver="/boot/vmlinuz-${kernel}"
@ -5793,35 +5803,31 @@ set_vars() {
encr_root_dev="/dev/mapper/${ENCROOT}"
# Encrypted Root Options
encr_root_opts="rd.luks.name=$(blkid -s UUID -o value "${root_dev}")=${ENCROOT}"
# Encryption Kernel Parameters
encr_root_bootopts="${encr_root_opts} root=${encr_root_dev} "
# Encryption / Kernel Parameters
encr_root_bootopts="${encr_root_opts} root=${encr_root_dev}"
### Encrypted 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}")=swap"
# Encrypted Swap Kernel Parameters
encr_swap_bootopts="resume=/dev/mapper/swap ${encr_swap_opts} "
# Encrypted Swap Partition Kernel Parameters
encr_swap_bootopts="resume=/dev/mapper/swap ${encr_swap_opts}"
## Encrypted Swapfile
elif [[ "${swapmode}" == "2" ]]; then
# Ext4 Offset
# Ext4 Offset calculation
if [[ "${fs}" == "1" ]]; then
offst="$(filefrag -v /mnt/swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}')"
# Btrfs Offset
# Btrfs Offset calculation
elif [[ "${fs}" == "2" ]]; then
offst="$(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile)"
fi
# Encrypted Swapfile Kernel Parameters
encr_swap_bootopts="resume=${encr_root_dev} resume_offset=${offst} "
encr_swap_bootopts="resume=${encr_root_dev} resume_offset=${offst}"
## Zram Swap
elif [[ "${swapmode}" == "3" ]]; then
# Zram Swap Kernel Parameters
zram_bootopts="zswap.enabled=0 "
## No Swap
elif [[ "${swapmode}" == "4" ]]; then
# No Swap Kernel Parameters
encr_swap_bootopts=""
zram_bootopts="zswap.enabled=0"
fi
### Graphics Setup (Encryption)
@ -5840,7 +5846,7 @@ set_vars() {
# Mkinitcpio Hooks (Encryption)
mkinitcpio_hooks="HOOKS=(systemd keyboard autodetect microcode modconf sd-vconsole block sd-encrypt filesystems fsck)"
# Graphics Kernel Parameters
vga_bootopts="nvidia.NVreg_UsePageAttributeTable=1 "
vga_bootopts="nvidia.NVreg_UsePageAttributeTable=1"
# Amd
elif [[ "${vendor}" == "AMD" ]]; then
# Mkinitcpio Hooks (Encryption)
@ -5850,18 +5856,18 @@ set_vars() {
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(amdgpu ${fs_mod})"
# Graphics Kernel Parameters
vga_bootopts="radeon.si_support=0 amdgpu.si_support=1 amdgpu.dc=1 "
vga_bootopts="radeon.si_support=0 amdgpu.si_support=1 amdgpu.dc=1"
# 'Sea Islands' support
elif [[ "${islands}" == "2" ]]; then
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(amdgpu ${fs_mod})"
# Graphics Kernel Parameters
vga_bootopts="radeon.cik_support=0 amdgpu.cik_support=1 amdgpu.dc=1 "
vga_bootopts="radeon.cik_support=0 amdgpu.cik_support=1 amdgpu.dc=1"
elif [[ -z "${islands}" ]]; then
# Mkinitcpio Modules (Encryption)
mkinitcpio_mods="MODULES=(${fs_mod})"
# Graphics Kernel Parameters
vga_bootopts="amdgpu.dc=1 "
vga_bootopts="amdgpu.dc=1"
fi
fi
## Configuration = 'No'
@ -5871,8 +5877,24 @@ set_vars() {
# Mkinitcpio Hooks (Encryption)
mkinitcpio_hooks="HOOKS=(systemd keyboard autodetect microcode modconf kms sd-vconsole block sd-encrypt filesystems fsck)"
fi
### Kernel Parameters (Encryption)
boot_opts="${encr_root_bootopts}${encr_swap_bootopts}${vga_bootopts}${cust_bootopts}${btrfs_bootopts}${zram_bootopts}"
### Main Kernel Parameters (Encryption)
boot_opts=("${encr_root_bootopts}")
if [[ -n "${encr_swap_bootopts}" ]]; then
boot_opts+=("${encr_swap_bootopts}")
fi
if [[ -n "${vga_bootopts}" ]]; then
boot_opts+=("${vga_bootopts}")
fi
if [[ -n "${cust_bootopts}" ]]; then
boot_opts+=("${cust_bootopts}")
fi
if [[ -n "${btrfs_bootopts}" ]]; then
boot_opts+=("${btrfs_bootopts}")
fi
if [[ -n "${zram_bootopts}" ]]; then
boot_opts+=("${zram_bootopts}")
fi
#-------------------------------------------------------------------------------------------------------------
#### Unencrypted Setup Vars
@ -5881,7 +5903,7 @@ set_vars() {
## Zram Swap
if [[ "${swapmode}" == "3" ]]; then
# Zram Swap Kernel Parameters
zram_bootopts="zswap.enabled=0 "
zram_bootopts="zswap.enabled=0"
fi
### Graphics Setup
## Configuration = 'Yes'
@ -5899,7 +5921,7 @@ set_vars() {
# Mkinitcpio Hooks
mkinitcpio_hooks="HOOKS=(systemd autodetect microcode modconf keyboard sd-vconsole block filesystems fsck)"
# Graphics Kernel Parameters
vga_bootopts="nvidia.NVreg_UsePageAttributeTable=1 "
vga_bootopts="nvidia.NVreg_UsePageAttributeTable=1"
# Amd
elif [[ "${vendor}" == "AMD" ]]; then
# Mkinitcpio Hooks
@ -5909,18 +5931,18 @@ set_vars() {
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=(amdgpu)"
# Graphics Kernel Parameters
vga_bootopts="radeon.si_support=0 amdgpu.si_support=1 amdgpu.dc=1 "
vga_bootopts="radeon.si_support=0 amdgpu.si_support=1 amdgpu.dc=1"
# 'Sea Islands' support
elif [[ "${islands}" == "2" ]]; then
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=(amdgpu)"
# Graphics Kernel Parameters
vga_bootopts="radeon.cik_support=0 amdgpu.cik_support=1 amdgpu.dc=1 "
vga_bootopts="radeon.cik_support=0 amdgpu.cik_support=1 amdgpu.dc=1"
elif [[ -z "${islands}" ]]; then
# Mkinitcpio Modules
mkinitcpio_mods="MODULES=()"
# Graphics Kernel Parameters
vga_bootopts="amdgpu.dc=1 "
vga_bootopts="amdgpu.dc=1"
fi
fi
## Configuration = 'No'
@ -5930,13 +5952,23 @@ set_vars() {
# Mkinitcpio Hooks
mkinitcpio_hooks="HOOKS=(systemd autodetect microcode modconf kms keyboard sd-vconsole block filesystems fsck)"
fi
### Main Kernel Parameters
boot_opts=()
if [[ "${autoroot}" == "y" ]]; then
### Multi-Root Disk Kernel Parameters (No Encryption)
boot_opts="${multiroot_bootopts}${vga_bootopts}${cust_bootopts}${btrfs_bootopts}${zram_bootopts}"
else
### Single-Root Disk Kernel Parameters (No Encryption)
boot_opts="${vga_bootopts}${cust_bootopts}${btrfs_bootopts}${zram_bootopts}"
boot_opts+=("${multiroot_bootopts}")
fi
if [[ -n "${vga_bootopts}" ]]; then
boot_opts+=("${vga_bootopts}")
fi
if [[ -n "${cust_bootopts}" ]]; then
boot_opts+=("${cust_bootopts}")
fi
if [[ -n "${btrfs_bootopts}" ]]; then
boot_opts+=("${btrfs_bootopts}")
fi
if [[ -n "${zram_bootopts}" ]]; then
boot_opts+=("${zram_bootopts}")
fi
fi
}