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

123
Amelia.sh
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Amelia Installer # Amelia Installer by elementrick
# Version: 6.2 # Version: 6.3
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
@ -1161,7 +1161,6 @@ set_swapsize (){
Enter Swap size ${bwhite}(in GB)${blue}: " Enter Swap size ${bwhite}(in GB)${blue}: "
read -r -p " read -r -p "
==> " swapsize ==> " swapsize
echo
if [[ -z "${swapsize}" ]]; then if [[ -z "${swapsize}" ]]; then
sleep 0.3 sleep 0.3
@ -2303,9 +2302,9 @@ Enter a number: "
esac esac
} }
################################################################################################### ###################################################################################################
auto_part(){ auto_part (){
local prompt="Disks" local prompt="Disk Partitions"
local stage_prompt="Auto-Partitioning" local stage_prompt="Auto-Partitioning"
sleep 0.3 sleep 0.3
NC " NC "
@ -2313,13 +2312,14 @@ auto_part(){
${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}Automatic Partitioning${nc} ${magenta}]${nc}---------------------------------${magenta}###${nc} ${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 " YELLOW "
> Select a disk for Auto-Partitioning: " > Select a disk for Auto-Partitioning: "
RED "
[!] WARNING: All data on selected disk will be destroyed [!]
"
NC " NC "
${disks}" ${disks}"
@ -2334,8 +2334,9 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
if [[ -n "${sgdsk_nmbr}" ]]; then if [[ -n "${sgdsk_nmbr}" ]]; then
sgdrive="$(echo "${disks}" | awk "\$1 == ${sgdsk_nmbr} {print \$2}")" sgdrive="$(echo "${disks}" | awk "\$1 == ${sgdsk_nmbr} {print \$2}")"
if [[ -e "${sgdrive}" ]]; then if [[ -e "${sgdrive}" ]]; then
partsize="$(fdisk -l "${sgdrive}" | grep -E 'bytes'| grep -E 'Disk'| awk "{print \$5}")" capacity="$(fdisk -l "${sgdrive}" | grep -E 'bytes'| grep -E 'Disk'| awk "{print \$5}")"
rootsize="$((partsize*25/100/1024000000))" cap_gib="$((capacity/1024000000))"
rootsize="$((capacity*25/100/1024000000))"
if [[ "${run_as}" != "root" ]]; then if [[ "${run_as}" != "root" ]]; then
sleep 0.3 sleep 0.3
RED " RED "
@ -2360,33 +2361,94 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
preset="1" preset="1"
fi fi
else else
YELLOW " sleep 0.3
NC "
${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Preset Selection${nc} ${magenta}]${nc}------------------------------------${magenta}###${nc}
"
YELLOW "
> Select a Partition Layout Preset: " > Select a Partition Layout Preset: "
NC " 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 " BLUE "
Enter a Preset number: " Enter a Preset number ${bwhite}(empty to skip)${blue}: "
read -r -p " read -r -p "
==> " preset ==> " preset
echo
fi 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 case "${preset}" in
1) 1)
if [[ "${install}" == "yes" ]] ; then if [[ "${install}" == "yes" ]] ; then
@ -2399,6 +2461,7 @@ Enter a Preset number: "
sgdisk -o "${sgdrive}" > /dev/null 2>&1 || stage_fail 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 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 sgdisk -n 2:0:0 -t 2:8304 -c 2:Root "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;; fi ;;
2) 2)
if [[ "${install}" == "yes" ]] ; then 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 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 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 sgdisk -n 3:0:0 -t 3:8304 -c 3:Root "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;; fi ;;
3) 3)
if [[ "${install}" == "yes" ]] ; then 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 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 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 sgdisk -n 3:0:0 -t 3:8302 -c 3:Home "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;; fi ;;
4) 4)
if [[ "${install}" == "yes" ]] ; then 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 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 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 sgdisk -n 4:0:0 -t 4:8302 -c 4:Home "${sgdrive}" > /dev/null 2>&1 || stage_fail
ok
fi ;; fi ;;
"") "")
sleep 0.3 sleep 0.3
@ -2470,7 +2536,7 @@ Enter a Preset number: "
fi fi
else else
skip skip
ok reload
if [[ -z "${sanity}" ]]; then if [[ -z "${sanity}" ]]; then
until dsks_submn; do : ; done until dsks_submn; do : ; done
@ -3011,7 +3077,7 @@ ${multi_swap}
==> [EFI System Partition ${green}OK${nc}] " ==> [EFI System Partition ${green}OK${nc}] "
fi fi
if [[ -e "${home_dev}" ]]; then if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then
if [[ "${autohome}" != "y" ]]; then if [[ "${autohome}" != "y" ]]; then
sleep 0.3 sleep 0.3
NC " NC "
@ -3456,8 +3522,7 @@ ${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}A
if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then
BLUE " 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 " read -r -p "
@ -5385,12 +5450,14 @@ NVIDIA_HOOK
sgdsk_nmbr="" sgdsk_nmbr=""
part_mode="" part_mode=""
preset="" preset=""
partsize="" capacity=""
cap_gib=""
rootsize="" rootsize=""
sgdrive="" sgdrive=""
cgdrive="" cgdrive=""
sep_home="" sep_home=""
autopart="" autopart=""
prcnt=""
clear clear
first_check first_check