Add: The'Partition Manager' stage has been fully revamped, and now consists of 2 Modes:

An 'Auto Mode' that offers ready-made compatible Partition Layout Presets with sane defaults to select from,
and a 'Manual Mode', (which now shows extended info about the supported partition types and mountpoints that the installer expects), where 'cgdisk' is used, with its easy and and intuitive ncurses TUI.
This commit is contained in:
Jane Doe 2024-06-15 22:57:43 +00:00
parent a109cffd1f
commit 3a04b5bb25

187
Amelia.sh
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Amelia Installer # Amelia Installer
# Version: 5.4 # Version: 5.5
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
@ -1126,7 +1126,7 @@ set_swapsize (){
local prompt="Swapsize" local prompt="Swapsize"
BLUE " BLUE "
Enter Swapfile size ${bwhite}(in GiB)${blue}: " Enter Swap size ${bwhite}(in GB)${blue}: "
read -r -p " read -r -p "
==> " swapsize ==> " swapsize
echo echo
@ -2227,7 +2227,8 @@ ______________________________________________
sleep 0.3 sleep 0.3
NC " NC "
==> [${green}${gptdrive} OK${nc}] " ==> [${green}${gptdrive} OK${nc}]
"
else else
invalid invalid
return 1 return 1
@ -2247,17 +2248,186 @@ ______________________________________________
################################################################################################### ###################################################################################################
disk_mngr (){ disk_mngr (){
local prompt="Disks"
sleep 0.3 sleep 0.3
NC " NC "
${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Partition Manager${nc} ${magenta}]${nc}------------------------------------${magenta}###${nc} ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Partition Manager${nc} ${magenta}]${nc}------------------------------------${magenta}###${nc}
"
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.3
RED "
[!] Please select a Mode "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
}
###################################################################################################
auto_part(){
local prompt="Disks"
local stage_prompt="Auto-Partitioning"
sleep 0.3
NC "
${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}Automatic Partitioning${nc} ${magenta}]${nc}---------------------------------${magenta}###${nc}
"
sgdsk_nmbr=" "
while [[ -n "${sgdsk_nmbr}" ]]; do
YELLOW "
> Select a disk to Manage: "
NC "
${disks}"
BLUE "
Enter a disk number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " sgdsk_nmbr
echo
if [[ -n "${sgdsk_nmbr}" ]]; then
drive="$(echo "${disks}" | awk "\$1 == ${sgdsk_nmbr} {print \$2}")"
partsize="$(fdisk -l "${drive}" | grep -E 'bytes'| grep -E 'Disk'| awk "{print \$5}")"
rootsize="$((partsize*25/100/1024000000))"
if [[ -e "${drive}" ]]; then
if [[ "${run_as}" != "root" ]]; then
sleep 0.3
RED "
[!] Root Privileges Missing.. "
reload
until dsks_submn; do : ; done
fi
YELLOW "
> Select a Partition Layout Preset: "
RED "
[!] WARNING: All data on selected disk will be ${nc}INSTANTLY ${red}destroyed [!]
"
NC "
[1] Create 'ESP' and '/Root'
[2] Create 'ESP', '/Root' and '/Swap'
[3] Create 'ESP', '/Root' and '/Home'
[4] Create 'ESP', '/Root', '/Home' and '/Swap' "
BLUE "
Enter a number: "
read -r -p "
==> " preset
echo
case "${preset}" in
1)
sgdisk -o "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 1:0:+512M -t 1:ef00 -c 1:ESP "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 2:0:0 -t 2:8304 -c 2:Root "${drive}" > /dev/null 2>&1 || stage_fail ;;
2)
until set_swapsize; do : ; done
sgdisk -o "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 1:0:+512M -t 1:ef00 -c 1:ESP "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 2:0:+"${swapsize}"G -t 2:8200 -c 2:Swap "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 3:0:0 -t 3:8304 -c 3:Root "${drive}" > /dev/null 2>&1 || stage_fail ;;
3)
sgdisk -o "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 1:0:+512M -t 1:ef00 -c 1:ESP "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 2:0:+"${rootsize}"G -t 2:8304 -c 2:Root "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 3:0:0 -t 3:8302 -c 3:Home "${drive}" > /dev/null 2>&1 || stage_fail ;;
4)
until set_swapsize; do : ; done
sgdisk -o "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 1:0:+512M -t 1:ef00 -c 1:ESP "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 2:0:+"${swapsize}"G -t 2:8200 -c 2:Swap "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 3:0:+"${rootsize}"G -t 3:8304 -c 3:Root "${drive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 4:0:0 -t 4:8302 -c 4:Home "${drive}" > /dev/null 2>&1 || stage_fail ;;
"")
sleep 0.3
RED "
[!] Please select a Preset "
reload
return 1 ;;
*)
invalid
return 1 ;;
esac
sleep 0.3
NC "
==> [${green}Disk ${drive} OK${nc}]
"
else
invalid
return 1
fi
else
skip
ok
if [[ -z "${sanity}" ]]; then
until dsks_submn; do : ; done
elif [[ "${sanity}" == "no" ]]; then
until instl_dsk; do : ; done
elif [[ "${revision}" == "yes" ]]; then
return 0
elif [[ "${sanity}" == "ok" ]]; then
if [[ "${install}" == "yes" ]]; then
return 0
fi
until dsks_submn; do : ; done
fi
fi
done
}
###################################################################################################
manual_part(){
local prompt="Disks"
sleep 0.3
NC "
${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}Manual Partitioning${nc} ${magenta}]${nc}-----------------------------------${magenta}###${nc}
" "
cgdsk_nmbr=" " cgdsk_nmbr=" "
while [[ -n "${cgdsk_nmbr}" ]]; do while [[ -n "${cgdsk_nmbr}" ]]; do
line3 line3
NC " [ SUPPORTED PARTITION TYPES & MOUNTPOINTS: ]" NC " SUPPORTED PARTITION TYPES & MOUNTPOINTS: "
line2 line2
REDBG " ------------------------------------------------------------------------------------------- " REDBG " ------------------------------------------------------------------------------------------- "
REDBG " ### Linux /Root x86-64 Partition [ GUID Code: 8304 ] Mountpoint: / ### " REDBG " ### Linux /Root x86-64 Partition [ GUID Code: 8304 ] Mountpoint: / ### "
@ -2648,7 +2818,9 @@ ${multi_swap}
fi fi
local prompt="Installation Disk" local prompt="Installation Disk"
if [[ -e "${boot_dev}" ]]; then
bootsize="$(lsblk -b "${boot_dev}" --noheadings --output=size)" bootsize="$(lsblk -b "${boot_dev}" --noheadings --output=size)"
fi
if [[ ! -e "${root_dev}" && ! -e "${boot_dev}" ]]; then if [[ ! -e "${root_dev}" && ! -e "${boot_dev}" ]]; then
sanity="no" sanity="no"
@ -5180,6 +5352,11 @@ NVIDIA_HOOK
autoswap="" autoswap=""
bootsize="" bootsize=""
retry_boot="" retry_boot=""
sgdsk_nmbr=""
part_mode=""
preset=""
partsize=""
rootsize=""
clear clear
first_check first_check