A new mechanism has been added, to scan the partitions on the selected (installation) disk and if more than one of each type {root/EFI/home/swap} is detected,

to Auto-Assign the 1st partition of each type, to be used by systemd's automation in the installation (as the 'Discoverable Partitions Specifications' dictate).
Of course comes with its own menu/prompts, for user interaction.
This commit is contained in:
Jane Doe 2024-06-11 14:29:02 +00:00
parent 1c5dad5fec
commit c322988b4c

271
Amelia.sh
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Amelia Installer # Amelia Installer
# Version: 5.1 # Version: 5.2
set -euo pipefail set -euo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
@ -133,7 +133,6 @@ vm_skip (){
" "
skip skip
} }
line2 (){ line2 (){
printf '\n\n' printf '\n\n'
} }
@ -154,6 +153,7 @@ unmount (){
${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Unmount Filesystems${nc} ${magenta}]${nc}-----------------------------------${magenta}###${nc} ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Unmount Filesystems${nc} ${magenta}]${nc}-----------------------------------${magenta}###${nc}
" "
if umount -R /mnt > /dev/null 2>&1 ; then if umount -R /mnt > /dev/null 2>&1 ; then
swapoff "${swap_dev}" > /dev/null 2>&1
sleep 0.3 sleep 0.3
NC " NC "
@ -248,7 +248,7 @@ arch (){
line3 line3
BLUEBG "************************************************************************************************* " BLUEBG "************************************************************************************************* "
BLUEBG " " BLUEBG " "
BLUEBG " ##### ARCH LINUX INSTALLATION ##### " BLUEBG " ##### Arch Linux Installation ##### "
BLUEBG " " BLUEBG " "
BLUEBG "************************************************************************************************* " BLUEBG "************************************************************************************************* "
line2 line2
@ -341,7 +341,7 @@ Enter a number: "
################################################################################################### ###################################################################################################
uefi_check (){ uefi_check (){
bootmode=$(cat /sys/firmware/efi/fw_platform_size) bootmode=$(cat /sys/firmware/efi/fw_platform_size)
local prompt="UEFI ${bootmode}-bit Mode" local prompt="UEFI ${bootmode}-bit Mode"
sleep 0.3 sleep 0.3
NC " NC "
@ -462,7 +462,7 @@ Enter a number: "
3) 3)
until dsks_submn; do : ; done ;; until dsks_submn; do : ; done ;;
4) 4)
instl ;; until instl; do : ; done ;;
"") "")
sleep 0.3 sleep 0.3
RED " RED "
@ -2396,11 +2396,196 @@ sanity_check (){
${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}Sanity Check${nc} ${magenta}]${nc}--------------------------------------${magenta}###${nc} ${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}Sanity Check${nc} ${magenta}]${nc}--------------------------------------${magenta}###${nc}
" "
root_dev="$(fdisk -l "${instl_drive}" | grep 'root' | awk "{print \$1}")" rootcount="$(fdisk -l "${instl_drive}" | grep -E -c 'root' | awk "{print \$1}")"
boot_dev="$(fdisk -l "${instl_drive}" | grep 'EFI' | awk "{print \$1}")" root_dev="$(fdisk -l "${instl_drive}" | grep -E 'root' | awk "{print \$1}")"
home_dev="$(fdisk -l "${instl_drive}" | grep 'home' | awk "{print \$1}")" multi_root="$(fdisk -l "${instl_drive}" | grep -E 'root' | awk "{print \$1}" | cat --number)"
swap_dev="$(fdisk -l "${instl_drive}" | grep 'swap' | awk "{print \$1}")" root_comply="$(fdisk -l "${instl_drive}" | grep -E 'root' | awk "{print \$1}" | cat --number | grep -E '1[[:blank:]]' | awk "{print \$2}")"
bootcount="$(fdisk -l "${instl_drive}" | grep -E -c 'EFI' | awk "{print \$1}")"
boot_dev="$(fdisk -l "${instl_drive}" | grep -E 'EFI' | awk "{print \$1}")"
multi_boot="$(fdisk -l "${instl_drive}" | grep -E 'EFI' | awk "{print \$1}" | cat --number)"
boot_comply="$(fdisk -l "${instl_drive}" | grep -E 'EFI' | 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}")"
if [[ "${rootcount}" -gt "1" ]]; then
local prompt="Confirm /Root Partition"
local stage_prompt="Partition"
sleep 0.3
RED "
[!] WARNING: Multiple Linux x86-64 /Root Partitions have been detected
"
NC "
Linux x86-64 /Root Partitions:
------------------------------
${multi_root}
------------------------------
"
YELLOW "
### Only the 1st Linux x86-64 /Root partition on a selected disk can be auto-assigned as a valid /Root partition
### Partition ${nc}${root_comply} ${yellow}is auto-assigned as such and will be ${red}[!] FORMATTED [!]
"
BLUE "
> Proceed ? [y/n]"
read -r -p "
==> " autoroot
if [[ "${autoroot}" == "y" ]]; then
root_dev="${root_comply}"
ok
line2
elif [[ "${autoroot}" == "n" ]]; then
stage_fail
else
invalid
echo
return 1
fi
fi
if [[ "${bootcount}" -gt "1" ]]; then
local prompt="Confirm /Boot Partition"
local stage_prompt="Partition"
sleep 0.3
RED "
[!] WARNING: Multiple EFI Partitions have been detected
"
NC "
Linux EFI System Partitions:
----------------------------
${multi_boot}
----------------------------
"
YELLOW "
### Only the 1st EFI partition on a selected disk can be auto-assigned as a valid EFI partition
### Partition ${nc}${boot_comply} ${yellow}is auto-assigned as such and will be ${red}[!] FORMATTED [!]
"
BLUE "
> Proceed ? [y/n]"
read -r -p "
==> " autoboot
if [[ "${autoboot}" == "y" ]]; then
boot_dev="${boot_comply}"
ok
line2
elif [[ "${autoboot}" == "n" ]]; then
stage_fail
else
invalid
echo
return 1
fi
fi
if [[ "${homecount}" -gt "1" ]]; then
local prompt="Confirm /Home Partition"
local stage_prompt="Partition"
sleep 0.3
RED "
[!] WARNING: Multiple Linux /Home Partitions have been detected
"
NC "
Linux /Home Partitions:
-----------------------
${multi_home}
-----------------------
"
YELLOW "
### Only the 1st Linux /Home partition on a selected disk can be auto-assigned as a valid /Home partition
### Partition ${nc}${home_comply} ${yellow}is auto-assigned as such and will be ${red}[!] FORMATTED [!]
"
BLUE "
> Proceed ? [y/n]"
read -r -p "
==> " autohome
if [[ "${autohome}" == "y" ]]; then
home_dev="${home_comply}"
ok
line2
elif [[ "${autohome}" == "n" ]]; then
stage_fail
else
invalid
echo
return 1
fi
fi
if [[ "${swapcount}" -gt "1" ]]; then
local prompt="Confirm /Swap Partition"
local stage_prompt="Partition"
sleep 0.3
RED "
[!] WARNING: Multiple Linux /Swap Partitions have been detected
"
NC "
Linux /Swap Partitions:
------------------------
${multi_swap}
------------------------
"
YELLOW "
### Only the 1st Linux /Swap partition on a selected disk can be auto-assigned as a valid /Swap partition
### Partition ${nc}${swap_comply} ${yellow}is auto-assigned as such and will be ${red}[!] FORMATTED [!]
"
BLUE "
> Proceed ? [y/n]"
read -r -p "
==> " autoswap
if [[ "${autoswap}" == "y" ]]; then
swap_dev="${swap_comply}"
ok
line2
echo
elif [[ "${autoswap}" == "n" ]]; then
stage_fail
else
invalid
echo
return 1
fi
fi
local prompt="Installation Disk"
if [[ ! -e "${root_dev}" && ! -e "${boot_dev}" ]]; then if [[ ! -e "${root_dev}" && ! -e "${boot_dev}" ]]; then
sanity="no" sanity="no"
sleep 0.3 sleep 0.3
@ -2475,29 +2660,37 @@ ${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}San
return 0 return 0
elif [[ -e "${root_dev}" && -e "${boot_dev}" ]]; then elif [[ -e "${root_dev}" && -e "${boot_dev}" ]]; then
sanity="ok" sanity="ok"
sleep 0.3 if [[ "${autoroot}" != "y" ]]; then
NC "
==> [Linux x86-64 /Root ${green}OK${nc}] "
sleep 0.3
NC "
==> [EFI System Partition ${green}OK${nc}] "
if [[ -e "${home_dev}" ]]; then
sleep 0.3 sleep 0.3
NC " NC "
==> [Linux x86-64 /Root ${green}OK${nc}] "
fi
if [[ "${autoboot}" != "y" ]]; then
sleep 0.3
NC "
==> [EFI System Partition ${green}OK${nc}] "
fi
if [[ -e "${home_dev}" ]]; then
if [[ "${autohome}" != "y" ]]; then
sleep 0.3
NC "
==> [Linux /Home ${green}OK${nc}] " ==> [Linux /Home ${green}OK${nc}] "
fi
fi fi
if [[ "${swapmode}" == "1" ]]; then if [[ "${swapmode}" == "1" ]]; then
if [[ -e "${swap_dev}" ]]; then if [[ -e "${swap_dev}" ]]; then
sanity="ok" if [[ "${autoswap}" != "y" ]]; then
sleep 0.3 sanity="ok"
NC " sleep 0.3
NC "
==> [Linux /Swap ${green}OK${nc}] " ==> [Linux /Swap ${green}OK${nc}] "
fi
else else
sanity="no" sanity="no"
sleep 0.3 sleep 0.3
@ -2766,6 +2959,28 @@ ${magenta}###${nc}----------------------------------${magenta}[ ${bwhite}Swap P
################################################################################################### ###################################################################################################
set_mode (){ set_mode (){
if [[ "${rootcount}" -gt "1" || "${bootcount}" -gt "1" || "${homecount}" -gt "1" || "${swapcount}" -gt "1" ]]; then
line2
until auto_mode; do : ; done
sleep 0.3
NC "
==> [${green}Filesystems OK${nc}]
"
sleep 0.3
YELLOW "
###---------------------------------------------[ FILESYSTEM OVERVIEW ]---------------------------------------------###
"
lsblk -f|GREP_COLORS='mt=01;36' grep -E --color=always 'vfat|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'ext4|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'btrfs|$'|GREP_COLORS='mt=01;31' grep -E --color=always 'ntfs|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'swap|$'
YELLOW "
###-----------------------------------------------------------------------------------------------------------------###"
echo
sleep 1
return 0
fi
sleep 0.3 sleep 0.3
NC " NC "
@ -2823,6 +3038,10 @@ Enter a Mode number: "
################################################################################################### ###################################################################################################
auto_mode (){ auto_mode (){
sleep 0.3
NC "
${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}Auto Mode${nc} ${magenta}]${nc}----------------------------------------${magenta}###${nc}
"
sleep 0.3 sleep 0.3
YELLOW " YELLOW "
@ -2928,7 +3147,7 @@ auto_mode (){
skip skip
else else
invalid invalid
ask_homepart_form until ask_homepart_form; do : ; done
fi fi
fi fi
} }
@ -3168,7 +3387,7 @@ ask_homepart_form (){
return 0 return 0
else else
invalid invalid
ask_homepart_form until ask_homepart_form; do : ; done
fi fi
fi fi
} }
@ -3443,7 +3662,7 @@ ${magenta}###${nc}-------------------------------${magenta}[ ${bwhite}Confirm In
chroot_conf chroot_conf
elif [[ "${agree}" == "no" ]]; then elif [[ "${agree}" == "no" ]]; then
unmount unmount
revise until revise; do : ; done
else else
sleep 0.3 sleep 0.3
RED " RED "
@ -4878,4 +5097,4 @@ NVIDIA_HOOK
connection_check connection_check
upd_clock upd_clock
dtct_microcode dtct_microcode
main_menu until main_menu; do : ; done