Change: Revamped 'Sanity Check' stage code

Add: 'Auto-Guided Installation' > 'Sanity Check' > 'Partitioning' > Installer now smartly suggests necessary stages (Smart Partitioning / Partition Layout Preset Selection / Manual Partitioning) to accomplish partitioning.
Prompts / visuals added
Indentation
This commit is contained in:
elementrick 2024-07-02 21:12:07 +00:00
parent 172bffb754
commit d80de009ef

502
Amelia.sh
View file

@ -1,7 +1,7 @@
#!/bin/bash
# Amelia Installer by elementrick
# Version: 6.4
# Amelia Installer
# Version: 6.5
set -euo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
@ -254,30 +254,30 @@ arch (){
}
cnfg (){
line3
YELLOWBGBL "------------------------------------------------------------------------------------------------- "
YELLOWBGBL " ### Configuring... ### "
YELLOWBGBL "------------------------------------------------------------------------------------------------- "
YELLOWBG "------------------------------------------------------------------------------------------------- "
YELLOWBG " ### Configuring... ### "
YELLOWBG "------------------------------------------------------------------------------------------------- "
echo
sleep 0.3
}
completion (){
sleep 0.3
line3
GREENBGBL "************************************************************************************************* "
GREENBGBL " "
GREENBGBL " ### Installation Completed ### "
GREENBGBL " "
GREENBGBL "************************************************************************************************* "
GREENBG "************************************************************************************************* "
GREENBG " "
GREENBG " ### Installation Completed ### "
GREENBG " "
GREENBG "************************************************************************************************* "
line3
}
failure (){
sleep 0.3
line3
REDBGBL "************************************************************************************************* "
REDBGBL " "
REDBGBL " ### Installation Failed ### "
REDBGBL " "
REDBGBL "************************************************************************************************* "
REDBG "************************************************************************************************* "
REDBG " "
REDBG " ### Installation Failed ### "
REDBG " "
REDBG "************************************************************************************************* "
line3
exit
}
@ -432,11 +432,11 @@ ${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}M
"
YELLOW "
> Make a selection:
[!] Select ${nc}[4] ${yellow}for Guided Navigation and 'Smart' Auto-Partitioning [!]
"
> Make a selection: "
CYAN "
--------------------------------------------------------------------------
### Select ${nc}[4] ${cyan}for ${nc}'Guided Navigation'${cyan} and ${nc}'Smart Auto-Partitioning'${cyan} ###
--------------------------------------------------------------------------"
NC "
[1] Personalization
@ -2302,6 +2302,39 @@ Enter a number: "
esac
}
###################################################################################################
man_preset (){
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
${magenta}* Btrfs${nc} filesystem support Layout
[1] Create 'ESP' and '/Root' (${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})
[4] Create 'ESP', '/Root', '/Home' and '/Swap' (${cyan}Ext4${nc}) "
BLUE "
Enter a Preset number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " preset
echo
}
###################################################################################################
auto_part (){
local prompt="Disk Partitions"
@ -2318,6 +2351,26 @@ ${magenta}###${nc}---------------------------------${magenta}[ ${bwhite}Automati
REDBG " [!] WARNING: All data on selected disk will be destroyed [!] "
REDBG " ------------------------------------------------------------ "
line2
if [[ -e "${instl_drive}" && "${use_man}" != "yes" ]]; then
BLUE "
> Use ${nc}${cyan}Smart ${blue}Auto-Partitioning on disk${nc} ${cyan}'${instl_drive}'${blue} ? [y/n]
"
read -r -p "
==> " smartpart
if [[ "${smartpart}" == "y" ]]; then
sgdsk_nmbr="${instl_dsk_nmbr}"
elif [[ "${smartpart}" == "n" ]]; then
sgdsk_nmbr="${instl_dsk_nmbr}"
use_man="yes"
until man_preset; do : ; done
else
invalid
return 1
fi
else
YELLOW "
> Select a disk for Auto-Partitioning: "
NC "
@ -2330,6 +2383,7 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " sgdsk_nmbr
echo
fi
if [[ -n "${sgdsk_nmbr}" ]]; then
sgdrive="$(echo "${disks}" | awk "\$1 == ${sgdsk_nmbr} {print \$2}")"
@ -2346,51 +2400,27 @@ Enter a disk number ${bwhite}(empty to skip)${blue}: "
until dsks_submn; do : ; done
fi
if [[ "${fs}" == "2" && "${swapmode}" == "1" ]] ; then
preset="2"
elif [[ "${fs}" == "2" && "${swapmode}" == "2" ]] || [[ "${fs}" == "2" && "${swapmode}" == "3" ]] ; then
preset="1"
elif [[ "${fs}" == "1" ]] ; then
if [[ "${sep_home}" == "y" && "${swapmode}" == "1" ]] ; then
preset="4"
elif [[ "${sep_home}" == "y" && "${swapmode}" == "2" ]] || [[ "${sep_home}" == "y" && "${swapmode}" == "3" ]]; then
preset="3"
elif [[ "${sep_home}" == "n" && "${swapmode}" == "1" ]] ; then
if [[ -z "${use_man}" ]] ; then
if [[ "${fs}" == "2" && "${swapmode}" == "1" ]]; then
preset="2"
elif [[ "${sep_home}" == "n" && "${swapmode}" == "2" ]] || [[ "${sep_home}" == "n" && "${swapmode}" == "3" ]]; then
elif [[ "${fs}" == "2" && "${swapmode}" == "2" ]] || [[ "${fs}" == "2" && "${swapmode}" == "3" ]]; then
preset="1"
elif [[ "${fs}" == "1" ]] ; then
if [[ "${sep_home}" == "y" && "${swapmode}" == "1" ]] ; then
preset="4"
elif [[ "${sep_home}" == "y" && "${swapmode}" == "2" ]] || [[ "${sep_home}" == "y" && "${swapmode}" == "3" ]]; then
preset="3"
elif [[ "${sep_home}" == "n" && "${swapmode}" == "1" ]] ; then
preset="2"
elif [[ "${sep_home}" == "n" && "${swapmode}" == "2" ]] || [[ "${sep_home}" == "n" && "${swapmode}" == "3" ]]; then
preset="1"
fi
else
until man_preset; do : ; done
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
${magenta}* Btrfs${nc} filesystem support Layout
[1] Create 'ESP' and '/Root' (${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})
[4] Create 'ESP', '/Root', '/Home' and '/Swap' (${cyan}Ext4${nc}) "
BLUE "
Enter a Preset number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " preset
echo
elif [[ -z "${preset}" ]] ; then
until manual_part; do : ; done
return 0
fi
if [[ "${preset}" == "3" || "${preset}" == "4" ]] ; then
@ -2448,7 +2478,7 @@ Enter a Custom Percentage number ${nc}${cyan}(e.g. 30) ${bwhite}(empty to skip)$
return 1
fi
fi
#-----------------------------------------------------------------------------------------------------------------
case "${preset}" in
1)
if [[ "${install}" == "yes" ]] ; then
@ -2515,6 +2545,11 @@ Enter a Custom Percentage number ${nc}${cyan}(e.g. 30) ${bwhite}(empty to skip)$
ok
fi ;;
"")
if [[ "${smartpart}" == "n" ]]; then
reload
until disk_mngr; do : ; done
return 0
fi
sleep 0.3
RED "
@ -2553,9 +2588,10 @@ Enter a Custom Percentage number ${nc}${cyan}(e.g. 30) ${bwhite}(empty to skip)$
fi
}
###################################################################################################
manual_part(){
manual_part (){
local prompt="Disks"
manpart="yes"
sleep 0.3
NC "
@ -2704,7 +2740,6 @@ Enter a disk number: "
###################################################################################################
sanity_check (){
local prompt="Installation Disk"
sleep 0.3
NC "
@ -2728,7 +2763,6 @@ ${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}San
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 "
@ -2742,7 +2776,7 @@ ${magenta}###${nc}--------------------------------------${magenta}[ ${bwhite}San
"
lsblk -f "${instl_drive}"|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 "
YELLOW "
###-----------------------------------------------------------------------------------------------------------------###"
NC "
@ -2769,7 +2803,6 @@ ${multi_root}
if [[ "${autoroot}" == "y" ]]; then
root_dev="${root_comply}"
multiroot_opts="root=PARTUUID=$(blkid -s PARTUUID -o value "${root_dev}") "
ok
elif [[ "${autoroot}" == "n" ]]; then
stage_fail
else
@ -2780,7 +2813,6 @@ ${multi_root}
fi
if [[ "${bootcount}" -gt "1" ]]; then
local prompt="Confirm /Boot Partition"
local stage_prompt="Partition"
sleep 0.3
RED "
@ -2820,25 +2852,6 @@ ${multi_boot}
if [[ "${autoboot}" == "y" ]]; then
boot_dev="${boot_comply}"
bootsize="$(lsblk -b "${boot_dev}" --noheadings --output=size)"
if [[ "${bootsize}" -lt "209715200" ]]; then
sanity="no"
sleep 0.3
RED "
[!] WARNING: EFI Partition's size is not adequate. Create a ${nc}200M ${red}EFI Partition at minimum "
sleep 3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
retry_boot="yes"
return 0
else
ok
fi
elif [[ "${autoboot}" == "n" ]]; then
stage_fail
else
@ -2849,7 +2862,6 @@ ${multi_boot}
fi
if [[ ${fs} == "1" && ${sep_home} == "y" && "${homecount}" -gt "1" ]]; then
local prompt="Confirm /Home Partition"
local stage_prompt="Partition"
sleep 0.3
RED "
@ -2889,7 +2901,6 @@ ${multi_home}
if [[ "${autohome}" == "y" ]]; then
home_dev="${home_comply}"
ok
elif [[ "${autohome}" == "n" ]]; then
stage_fail
else
@ -2900,7 +2911,6 @@ ${multi_home}
fi
if [[ ${swapmode} == "1" && "${swapcount}" -gt "1" ]]; then
local prompt="Confirm /Swap Partition"
local stage_prompt="Partition"
sleep 0.3
RED "
@ -2940,7 +2950,6 @@ ${multi_swap}
if [[ "${autoswap}" == "y" ]]; then
swap_dev="${swap_comply}"
ok
elif [[ "${autoswap}" == "n" ]]; then
stage_fail
else
@ -2949,175 +2958,106 @@ ${multi_swap}
return 1
fi
fi
#--------------------------------------------------------------------------------------------------
if [[ -e "${root_dev}" ]]; then
rootprt="ok"
if [[ "${autoroot}" == "y" ]]; then
local prompt="Confirm /Root Partition"
ok
else
sleep 0.3
NC "
==> [Linux x86-64 /Root ${green}OK${nc}] "
fi
else
sleep 0.3
RED "
[!] Linux x86-64 /Root Partition not detected "
rootprt="fail"
fi
local prompt="Installation Disk"
if [[ -e "${boot_dev}" ]]; then
bootsize="$(lsblk -b "${boot_dev}" --noheadings --output=size)"
fi
if [[ ! -e "${root_dev}" && ! -e "${boot_dev}" ]]; then
sanity="no"
sleep 0.3
RED "
[!] Linux x86-64 /Root Partition not detected "
sleep 0.3
RED "
[!] EFI System Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that a Linux x86-64 /Root Partition with a valid GUID code ${nc}(8304)${yellow} is present on disk
### Ensure that an EFI System Partition with a valid GUID code ${nc}(ef00)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
elif [[ ! -e "${root_dev}" && -e "${boot_dev}" ]]; then
if [[ "${bootsize}" -lt "209715200" ]]; then
sanity="no"
sleep 0.3
RED "
[!] WARNING: EFI Partition's size is not adequate. Create a ${nc}200M ${red}EFI Partition at minimum "
sleep 3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
bootprt="fail"
else
sanity="no"
sleep 0.3
NC "
==> [EFI System Partition ${green}OK${nc}] "
sleep 0.3
RED "
[!] Linux x86-64 /Root Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that a Linux x86-64 /Root Partition with a valid GUID code ${nc}(8304)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
fi
elif [[ -e "${root_dev}" && ! -e "${boot_dev}" ]]; then
sanity="no"
sleep 0.3
NC "
==> [Linux x86-64 /Root ${green}OK${nc}] "
sleep 0.3
RED "
[!] EFI Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that an EFI System Partition with a valid GUID code ${nc}(ef00)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
elif [[ -e "${root_dev}" && -e "${boot_dev}" ]]; then
if [[ "${bootsize}" -lt "209715200" ]]; then
sanity="no"
sleep 0.3
RED "
[!] WARNING: EFI Partition's size is not adequate. Create a ${nc}200M ${red}EFI Partition at minimum "
sleep 3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
fi
sanity="ok"
if [[ "${autoroot}" != "y" ]]; then
sleep 0.3
NC "
==> [Linux x86-64 /Root ${green}OK${nc}] "
fi
if [[ "${autoboot}" != "y" ]]; then
sleep 0.3
NC "
==> [EFI System Partition ${green}OK${nc}] "
elif [[ "${autoboot}" == "y" && "${retry_boot}" == "yes" ]]; then
sleep 0.3
NC "
==> [EFI System Partition ${green}OK${nc}] "
fi
if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then
if [[ "${autohome}" != "y" ]]; then
bootprt="ok"
if [[ "${autoboot}" == "y" ]]; then
local prompt="Confirm /Boot Partition"
ok
else
sleep 0.3
NC "
==> [Linux /Home ${green}OK${nc}] "
==> [EFI System Partition ${green}OK${nc}] "
fi
fi
else
sleep 0.3
RED "
if [[ "${swapmode}" == "1" ]]; then
if [[ -e "${swap_dev}" ]]; then
if [[ "${autoswap}" != "y" ]]; then
sanity="ok"
[!] EFI System Partition not detected "
bootprt="fail"
fi
if [[ ${fs} == "1" ]]; then
if [[ "${sep_home}" == "y" ]]; then
if [[ -e "${home_dev}" ]]; then
homeprt="ok"
if [[ "${autohome}" == "y" ]]; then
local prompt="Confirm /Home Partition"
ok
else
sleep 0.3
NC "
==> [Linux /Swap ${green}OK${nc}] "
fi
==> [Linux /Home ${green}OK${nc}] "
fi
else
sanity="no"
sleep 0.3
RED "
[!] Linux /Swap Partition not detected "
sleep 0.3
YELLOW "
--> Please comply with the Discoverable Partitions Specification to continue..
### Ensure that a Linux /Swap Partition with a valid GUID code ${nc}(8200)${yellow} is present on disk "
sleep 0.3
RED "
[!] Sanity Check Failed [!] "
sleep 2
reload
until disk_mngr; do : ; done
return 0
[!] Linux /Home Partition not detected "
homeprt="fail"
fi
fi
fi
if [[ "${swapmode}" == "1" ]]; then
if [[ -e "${swap_dev}" ]]; then
swapprt="ok"
if [[ "${autoswap}" == "y" ]]; then
local prompt="Confirm /Swap Partition"
ok
else
sleep 0.3
NC "
==> [Linux /Swap ${green}OK${nc}] "
fi
else
sleep 0.3
RED "
[!] Linux /Swap Partition not detected "
swapprt="fail"
fi
fi
local prompt="Installation Disk"
if [[ ${rootprt} == "fail" ]] || [[ "${bootprt}" == "fail" ]] || [[ ${homeprt} == "fail" ]] || [[ ${swapprt} == "fail" ]]; then
sanity="no"
else
sanity="ok"
fi
if [[ "${sanity}" == "ok" ]]; then
if [[ "${autopart}" == "yes" ]]; then
sleep 0.3
@ -3126,7 +3066,61 @@ ${multi_swap}
==> [${green}Disk ${sgdrive} Auto-Partitioned OK${nc}] "
else
ok
sleep 0.3
YELLOW "
###------------------------------------------------[ DISK OVERVIEW ]------------------------------------------------###
"
fdisk -l "${instl_drive}" | grep -E --color=no 'Dev|dev' |GREP_COLORS='mt=01;36' grep -E --color=always 'EFI System|$'|GREP_COLORS='mt=01;32' grep -E --color=always 'Linux root|$'|GREP_COLORS='mt=01;35' grep -E --color=always 'Linux home|$'|GREP_COLORS='mt=01;33' grep -E --color=always 'Linux swap|$'
YELLOW "
###-----------------------------------------------------------------------------------------------------------------### "
BLUE "
> Proceed ? [y/n]${nc}
"
read -r -p "
==> " partok
local prompt="Confirm Disk"
local stage_prompt="Partitioning"
if [[ "${partok}" == "y" ]]; then
ok
elif [[ "${partok}" == "n" ]]; then
if [[ "${manpart}" == "yes" ]]; then
stage_fail
else
reload
until disk_mngr; do : ; done
return 0
fi
else
invalid
return 1
fi
fi
elif [[ "${sanity}" == "no" ]]; then
sleep 0.3
RED "
---------------------------
### ${yellow}SANITY CHECK FAILED${red} ###
---------------------------"
if [[ "${smartpart}" == "n" && -z "${preset}" ]] ; then
reload
until manual_part; do : ; done
return 0
elif [[ "${smartpart}" == "n" && -n "${preset}" ]] ; then
local stage_prompt="Partitioning"
line2
stage_fail
fi
reload
until auto_part; do : ; done
return 0
fi
}
###################################################################################################
@ -3519,10 +3513,10 @@ ${magenta}###${nc}----------------------------------------${magenta}[ ${bwhite}A
fi
sleep 0.3
#--------------------------------------------------------------------------------------------------
if [[ -e "${home_dev}" && "${sep_home}" == "y" ]]; then
if [[ ${fs} == "1" && -e "${home_dev}" && "${sep_home}" == "y" ]]; then
BLUE "
> A${nc} /Home ${blue}partition has been detected. Format as${nc} ${fsname}${blue} ? [y/n]
> A${nc} ${cyan}/Home ${blue}partition has been detected. Format as${nc} ${cyan}${fsname}${blue} ? [y/n]
"
read -r -p "
@ -5447,7 +5441,15 @@ NVIDIA_HOOK
autohome=""
autoswap=""
bootsize=""
retry_boot=""
rootprt=""
bootprt=""
homeprt=""
swapprt=""
smartpart=""
partok=""
use_man=""
manpart=""
instl_drive=""
sgdsk_nmbr=""
part_mode=""
preset=""
@ -5461,15 +5463,15 @@ NVIDIA_HOOK
prcnt=""
clear
first_check
sleep 1
#first_check
#sleep 1
line3
CYANBG "************************************************************************************************* "
CYANBG " "
CYANBG " ### Amelia Installer ### "
CYANBG " "
CYANBG "************************************************************************************************* "
NC "
#NC "
@ -5478,12 +5480,12 @@ NVIDIA_HOOK
${bwhite}Press any key to start${nc} "
read -r -s -n 1
clear
arch
uefi_check
connection_check
upd_clock
dtct_microcode
#${bwhite}Press any key to start${nc} "
#read -r -s -n 1
#clear
#arch
#uefi_check
#connection_check
#upd_clock
#dtct_microcode
until main_menu; do : ; done