Add: 'Partition Manager' > 'Automatic Partitioning' > 'Preset Selection' :

Now, when presets [3] & [4] are selected (create ESP, /Root, /Home & ESP, /Root, /Home, /Swap)
the user can set a custom percentage for the '/Root' partition's size to be created.
Default percentage is 25% of the Disk's total detected capacity.
Aesthetic adjustments/ polishing the TUI in the 'Automatic Partitioning' stage.
Indentation.
This commit is contained in:
Elementrick 2024-06-28 21:51:27 +00:00
parent ff7bb93f86
commit 7d55f08ae3

113
Amelia.sh
View file

@ -1,7 +1,7 @@
#!/bin/bash
# Amelia Installer
# Version: 6.2
# Amelia Installer by elementrick
# Version: 6.3
set -euo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
@ -1161,7 +1161,6 @@ set_swapsize (){
Enter Swap size ${bwhite}(in GB)${blue}: "
read -r -p "
==> " swapsize
echo
if [[ -z "${swapsize}" ]]; then
sleep 0.3
@ -2305,7 +2304,7 @@ Enter a number: "
###################################################################################################
auto_part (){
local prompt="Disks"
local prompt="Disk Partitions"
local stage_prompt="Auto-Partitioning"
sleep 0.3
NC "
@ -2313,13 +2312,14 @@ auto_part(){
${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}Automatic Partitioning${nc} ${magenta}]${nc}---------------------------------${magenta}###${nc}
"
sleep 0.3
line2
REDBG " ------------------------------------------------------------ "
REDBG " [!] WARNING: All data on selected disk will be destroyed [!] "
REDBG " ------------------------------------------------------------ "
line2
YELLOW "
> Select a disk for Auto-Partitioning: "
RED "
[!] WARNING: All data on selected disk will be destroyed [!]
"
NC "
${disks}"
@ -2334,8 +2334,9 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
if [[ -n "${sgdsk_nmbr}" ]]; then
sgdrive="$(echo "${disks}" | awk "\$1 == ${sgdsk_nmbr} {print \$2}")"
if [[ -e "${sgdrive}" ]]; then
partsize="$(fdisk -l "${sgdrive}" | grep -E 'bytes'| grep -E 'Disk'| awk "{print \$5}")"
rootsize="$((partsize*25/100/1024000000))"
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.3
RED "
@ -2360,31 +2361,92 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
preset="1"
fi
else
sleep 0.3
NC "
${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Preset Selection${nc} ${magenta}]${nc}------------------------------------${magenta}###${nc}
"
YELLOW "
> Select a Partition Layout Preset: "
NC "
* [${cyan}Ext4${nc}] filesystem support Layout
${cyan}* Ext4${nc} filesystem support Layout
* [${magenta}Btrfs${nc}] filesystem support Layout
${magenta}* Btrfs${nc} filesystem support Layout
[1] Create 'ESP' and '/Root' [${cyan}Ext4${nc},${magenta}Btrfs${nc}]
[1] Create 'ESP' and '/Root' (${cyan}Ext4${nc},${magenta}Btrfs${nc})
[2] Create 'ESP', '/Root' and '/Swap' [${cyan}Ext4${nc},${magenta}Btrfs${nc}]
[2] Create 'ESP', '/Root' and '/Swap' (${cyan}Ext4${nc},${magenta}Btrfs${nc})
[3] Create 'ESP', '/Root' and '/Home' [${cyan}Ext4${nc}]
[3] Create 'ESP', '/Root' and '/Home' (${cyan}Ext4${nc})
[4] Create 'ESP', '/Root', '/Home' and '/Swap' [${cyan}Ext4${nc}]"
[4] Create 'ESP', '/Root', '/Home' and '/Swap' (${cyan}Ext4${nc}) "
BLUE "
Enter a Preset number: "
Enter a Preset number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " preset
echo
fi
if [[ "${preset}" == "3" || "${preset}" == "4" ]] ; then
sleep 0.3
YELLOW "
### Total detected capacity of disk ${nc}${sgdrive} ${yellow}is ${nc}${cap_gib} GiB${yellow}
### Default /Root Partition's size is aprox. 25% of total disk capacity ${nc}[${rootsize} GiB]${yellow}
> Set /Root Partition's Percentage to a custom value ? "
BLUE "
Enter a Custom Percentage number ${nc}${cyan}(e.g. 30) ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " prcnt
echo
fi
if [[ "${preset}" == "3" || "${preset}" == "4" ]] ; then
if [[ "${prcnt}" == [[:alpha:]] ]]; then
sleep 0.3
RED "
[!] Please use only digits as a value "
reload
return 1
elif [[ -z "${prcnt}" ]]; then
sleep 0.3
YELLOW "
### Default /Root Partition size ${nc}[${rootsize} GiB]
"
elif [[ "${prcnt}" -gt "0" && "${prcnt}" -lt "100" ]]; then
rootsize="$((capacity*"${prcnt}"/100/1024000000))"
sleep 0.3
YELLOW "
### Custom /Root Partition size ${nc}[${rootsize} GiB]
"
elif [[ "${prcnt}" == "100" ]]; then
sleep 0.3
RED "
[!] WARNING: No space left for other partitions [!] "
reload
return 1
else
invalid
return 1
fi
fi
case "${preset}" in
@ -2399,6 +2461,7 @@ Enter a Preset number: "
sgdisk -o "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 1:0:+512M -t 1:ef00 -c 1:ESP "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 2:0:0 -t 2:8304 -c 2:Root "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;;
2)
if [[ "${install}" == "yes" ]] ; then
@ -2415,6 +2478,7 @@ Enter a Preset number: "
sgdisk -n 1:0:+512M -t 1:ef00 -c 1:ESP "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 2:0:+"${swapsize}"G -t 2:8200 -c 2:Swap "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 3:0:0 -t 3:8304 -c 3:Root "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;;
3)
if [[ "${install}" == "yes" ]] ; then
@ -2429,6 +2493,7 @@ Enter a Preset number: "
sgdisk -n 1:0:+512M -t 1:ef00 -c 1:ESP "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 2:0:+"${rootsize}"G -t 2:8304 -c 2:Root "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 3:0:0 -t 3:8302 -c 3:Home "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;;
4)
if [[ "${install}" == "yes" ]] ; then
@ -2447,6 +2512,7 @@ Enter a Preset number: "
sgdisk -n 2:0:+"${swapsize}"G -t 2:8200 -c 2:Swap "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 3:0:+"${rootsize}"G -t 3:8304 -c 3:Root "${sgdrive}" > /dev/null 2>&1 || stage_fail
sgdisk -n 4:0:0 -t 4:8302 -c 4:Home "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;;
"")
sleep 0.3
@ -2470,7 +2536,7 @@ Enter a Preset number: "
fi
else
skip
ok
reload
if [[ -z "${sanity}" ]]; then
until dsks_submn; do : ; done
@ -3011,7 +3077,7 @@ ${multi_swap}
==> [EFI System Partition ${green}OK${nc}] "
fi
if [[ -e "${home_dev}" ]]; then
if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then
if [[ "${autohome}" != "y" ]]; then
sleep 0.3
NC "
@ -3456,8 +3522,7 @@ ${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}A
if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then
BLUE "
> A${nc} ${cyan}/Home ${blue}partition has been detected. Format as${nc} ${cyan}${fsname}${blue}? [y/n]
> A${nc} /Home ${blue}partition has been detected. Format as${nc} ${fsname}${blue} ? [y/n]
"
read -r -p "
@ -5385,12 +5450,14 @@ NVIDIA_HOOK
sgdsk_nmbr=""
part_mode=""
preset=""
partsize=""
capacity=""
cap_gib=""
rootsize=""
sgdrive=""
cgdrive=""
sep_home=""
autopart=""
prcnt=""
clear
first_check