Change: Code replacement for efficiency

Change: Prompts have been edited for better aesthetics
This commit is contained in:
Jane Doe
2025-11-22 21:42:40 +02:00
parent e496b26edb
commit 34b3508266
+180 -187
View File
@@ -2,7 +2,7 @@
# Amelia Installer
# Source: https://gitlab.com/prism7/archery
# Version: 1.0.11
# Version: 1.0.12
set -euo pipefail
###################################################################################################
@@ -44,9 +44,10 @@ NC() { echo -e "${nc} $1${nc}" ;}
# PROMPT FUNCTIONS
skip() {
sleep 0.2
YELLOW "
YELLOWL "
--> Skipping.. "
--> Skipping..
"
}
reload() {
sleep 0.2
@@ -284,6 +285,16 @@ Enter [Y/n]: "
until term_offer; do : ; done ;;
esac
}
keypress() {
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
}
amd() {
line2
REDBG " ------------------------------- "
@@ -384,12 +395,14 @@ mode_check() {
sleep 0.2
YELLOWL "
> ${nc}Running in ${red}ROOT ${nc}mode ${yellowl}< "
> ${nc}Running in ${red}ROOT ${nc}mode ${yellowl}< "
else
sleep 0.2
YELLOWL "
> ${nc}Running in ${blue}DEMO ${nc}mode ${yellowl}< "
> ${nc}Running in ${blue}DEMO ${nc}mode ${yellowl}< "
fi
}
###################################################################################################
@@ -1192,8 +1205,11 @@ Enter [y/N]: "
sleep 0.2
RED "
-----------------------------------------
### ${nc}Secure Boot Not in ${yellow}'Setup' ${nc}Mode ${red}###
-----------------------------------------"
### ${nc}Secure Boot Not in ${yellowl}'Setup' ${nc}Mode ${red}###
-----------------------------------------
"
failure
fi
sleep 0.2
@@ -1438,49 +1454,47 @@ Enter [y/N]: "
sep_home="${sep_home:-n}"
sep_home="${sep_home,,}"
case "${sep_home}" in
y)
sleep 0.2
YELLOW "
case "${sep_home}" in
y)
sleep 0.2
YELLOW "
> Make a selection: "
NC "
NC "
[1] Create a /Home partition
[2] Utilize a previously used unencrypted /Home partition "
BLUE "
BLUE "
Enter a number: "
read -r -p "
read -r -p "
==> " hometype
echo
case "${hometype}" in
1)
sleep 0.2
YELLOW "
echo
case "${hometype}" in
1)
sleep 0.2
YELLOW "
### A /Home Partition will be created " ;;
2)
sleep 0.2
YELLOW "
2)
sleep 0.2
YELLOW "
### An existing /Home Partition will be used " ;;
*) invalid
return 1 ;;
esac ;;
n)
skip
echo;;
*)
invalid
return 1 ;;
esac
*) invalid
return 1 ;;
esac ;;
n)
skip ;;
*)
invalid
return 1 ;;
esac
sleep 0.2
YELLOW "
### ${fsname} has been selected
" ;;
2)
@@ -1510,7 +1524,7 @@ Enter a name: "
invalid
return 1
fi ;;
"")
"")
sleep 0.2
RED "
------------------------------------
@@ -1585,7 +1599,8 @@ Enter a number ${bwhite}(empty to skip)${blue}: "
sleep 0.2
YELLOW "
### No Swap will be used "
### No Swap will be used
"
skip ;;
*)
invalid
@@ -1949,6 +1964,9 @@ Enter [Y/n]: "
"
local prompt="Graphics Setup"
ok
if [[ "${install}" == "yes" ]]; then
keypress
fi
}
###################################################################################################
gfxpkgs_set() {
@@ -1981,13 +1999,7 @@ gfxpkgs_set() {
### ${nc}is incompatible with ${yellowl}'Early KMS' ${nc}use ${cyan}###${nc}
----------------------------------------------------------------"
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
keypress
fi
gfxpkgs=(libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d)
@@ -2325,27 +2337,32 @@ ${magenta}###${nc}--------------------------------${magenta}[ ${bwhite}'base-dev
> Install 'base-devel' meta-package ? [Y/n] "
> Install 'base-devel' meta-package ? [y/N] "
BLUE "
Enter [Y/n]: "
Enter [y/N]: "
read -r -p "
==> " dev
dev="${dev:-y}"
echo
dev="${dev:-n}"
dev="${dev,,}"
case "${dev}" in
y)
devel="base-devel"
ok ;;
n)
skip ;;
*)
invalid
return 1 ;;
esac
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() {
@@ -2358,6 +2375,7 @@ ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Web bro
"
if [[ ! "${desktop}" =~ ^(11|12)$ && -n "${desktop}" ]]; then
local prompt="Web Browser"
sleep 0.2
YELLOW "
@@ -2391,6 +2409,7 @@ Enter a number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " web
echo
case "${web}" in
1)
web_pkg="firefox"
@@ -2421,7 +2440,8 @@ Enter a number ${bwhite}(empty to skip)${blue}: "
web_aur=""
web_name=""
web_slct="yes"
skip ;;
skip
ok ;;
*)
invalid
return 1 ;;
@@ -2445,14 +2465,7 @@ Enter a number ${bwhite}(empty to skip)${blue}: "
web_name=""
web_slct=""
skip
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
keypress
fi
if [[ "${web}" =~ ^(1|2|3|4|5|6|7|8)$ ]]; then
@@ -2489,6 +2502,7 @@ Enter [y/N]: "
read -r -p "
==> " printer
echo
printer="${printer:-n}"
printer="${printer,,}"
@@ -2500,8 +2514,7 @@ Enter [y/N]: "
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
ok ;;
fi ;;
n)
print_pkgs=""
skip ;;
@@ -2509,6 +2522,7 @@ Enter [y/N]: "
invalid
return 1 ;;
esac
ok
else
sleep 0.2
RED "
@@ -2524,20 +2538,15 @@ Enter [y/N]: "
"
print_pkgs=""
skip
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
ok
keypress
fi
else
echo
vm
print_pkgs=""
skip
ok
fi
}
###################################################################################################
@@ -2577,30 +2586,32 @@ 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 "
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 "
-----------------------------------
"
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
err_try
return 1
fi
else
skip
ok
fi
done
efi_entr_del="yes"
}
@@ -2680,7 +2691,6 @@ Enter a number: "
until tlp; do : ; done
return 1 ;;
"")
set_optm_slct="yes"
until sys_submn; do : ; done ;;
*)
invalid
@@ -2703,23 +2713,25 @@ 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
ok
}
###################################################################################################
cust_kern_param() {
sleep 0.2
local prompt="Custom Kernel Parameters"
NC "
@@ -2741,23 +2753,25 @@ 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 ;;
*)
invalid
return 1 ;;
esac
case "${ask_param}" in
y)
until add_prmtrs; do : ; done ;;
n)
skip
ok ;;
*)
invalid
return 1 ;;
esac
}
###################################################################################################
add_prmtrs() {
local prompt="Kernel Parameters"
local prompt="Custom Kernel Parameters"
YELLOW "
@@ -2774,6 +2788,7 @@ Enter your own Kernel parameters to be set at boot ${bwhite}(space-seperated)${b
if [[ -z "${cust_bootopts}" ]]; then
skip
ok
else
ok
fi
@@ -2782,6 +2797,7 @@ Enter your own Kernel parameters to be set at boot ${bwhite}(space-seperated)${b
sys_watchdog() {
sleep 0.2
local prompt="System Watchdogs"
NC "
@@ -2808,24 +2824,29 @@ Enter [y/N]: "
read -r -p "
==> " kill_watchdog
echo
kill_watchdog="${kill_watchdog:-n}"
kill_watchdog="${kill_watchdog,,}"
case "${kill_watchdog}" in
y)
local prompt="Watchdogs Disabled"
ok ;;
n)
skip ;;
*)
invalid
return 1 ;;
esac
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 "
@@ -2850,22 +2871,26 @@ Enter [v/y/N]: "
read -r -p "
==> " genoptm
echo
genoptm="${genoptm:-n}"
genoptm="${genoptm,,}"
case "${genoptm}" in
y)
local prompt="System Optimizations"
ok ;;
n)
skip ;;
v)
view_optm
return 1 ;;
*)
invalid
return 1 ;;
esac
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() {
@@ -2905,6 +2930,7 @@ Enter your Country Code, ie:${nc} ${cyan}US ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " REGDOM
echo
REGDOM="${REGDOM^^}"
if [[ -z "${REGDOM}" ]]; then
@@ -3304,9 +3330,11 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
if [[ "${run_as}" != "root" ]]; then
sleep 0.2
RED "
-----------------------------------
### ${nc}Root Privileges Missing.. ${red}###
-----------------------------------"
-----------------------------------
"
reload
until dsks_submn; do : ; done
fi
@@ -3550,7 +3578,8 @@ ${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}Automati
RED "
-----------------------------------
### ${nc}Root Privileges Missing.. ${red}###
-----------------------------------"
-----------------------------------
"
reload
until main_menu; do : ; done
return 0
@@ -3611,7 +3640,8 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
RED "
-----------------------------------
### ${nc}Root Privileges Missing.. ${red}###
-----------------------------------"
-----------------------------------
"
reload
until dsks_submn; do : ; done
return 0
@@ -3879,9 +3909,12 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
if [[ "${run_as}" != "root" ]]; then
sleep 0.2
RED "
-----------------------------------
### ${nc}Root Privileges Missing.. ${red}###
-----------------------------------"
-----------------------------------
"
reload
until dsks_submn; do : ; done
fi
@@ -3941,7 +3974,8 @@ Enter a disk number: "
RED "
-----------------------------------
### ${nc}Root Privileges Missing.. ${red}###
-----------------------------------"
-----------------------------------
"
reload
until main_menu; do : ; done
return 0
@@ -4297,16 +4331,9 @@ ${multi_swap}
>> ${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
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
>> ${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
@@ -4582,16 +4609,9 @@ ${multi_swap}
-----------------------------
### ${bwhite}SANITY CHECK FAILED ${nc}${red}###
-----------------------------"
NC "
${bwhite}Press any key to continue${nc}
-----------------------------
"
read -r -s -n 1
keypress
if [[ "${multibooting}" == "y" ]]; then
if [[ "${espprt}" == "fail" && -e "${esp_dev}" ]]; then
@@ -4613,12 +4633,7 @@ ${multi_swap}
>> ${nc}Create a ${yellowl}300M ${nc}(at minimum) Linux Extended Boot Partition ${bwhite}(XBOOTLDR) ${yellowl}[GUID CODE: ea00]
" #ATTENTION
fi
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
keypress
if [[ "${espmnt}" == "2" ]]; then
until slct_espmnt; do : ; done
@@ -4846,7 +4861,7 @@ instl() {
fi
fi
if [[ -z "${set_optm_slct}" ]]; then
if [[ -z "${askoptm}" ]]; then
local stage_prompt="Optimizations"
completion_err
until ask_optm; do : ; done
@@ -5798,7 +5813,7 @@ ${magenta}###${nc}-------------------------------${magenta}[ ${bwhite}Confirm In
###################################################################################################
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="" set_optm_slct="" oomd="" irqbalance="" thermald="" rngd="" rtkit="" tlp="" CRYPTPASS="" CRYPTPASS2="" askoptm="" gptslct="" gptok="" gptabort="" nvdprop="" nowarning="" hometype="" homeform="" smartpart="" LuksParts="")
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=()
@@ -6040,14 +6055,7 @@ ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}LUKS
> An existing /Home partition has been detected and will be utilized in this installation
"
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
keypress
fi
fi
@@ -6322,15 +6330,8 @@ ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Pacs
esac
pkg_displ
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
echo
keypress
if pacstrap -K /mnt ${deskpkgs} 2> "${log}" ; then
local prompt="Pacstrap System"
@@ -7478,7 +7479,7 @@ CUSTOM_SRVC
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="" set_optm_slct="" irqbalance="" thermald="" rngd="" rtkit="" tlp="" CRYPTPASS="" CRYPTPASS2="" askoptm="" gptslct="" gptok="" gptabort="" nvdprop="" nowarning="" efiname="" path="" hometype="" homeform="" LuksParts="")
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 "************************************************************************************************* "
@@ -7487,17 +7488,9 @@ CUSTOM_SRVC
CYANBG " "
CYANBG "************************************************************************************************* "
mode_check
NC "
${bwhite}Press any key to start${nc} "
read -r -s -n 1
line3
line3
keypress
clear
set_font
arch