Fixed disk selection recap logic.

This commit is contained in:
Raphaël Numbus
2025-12-31 15:20:50 +01:00
parent 59ec9fd170
commit 593fa66e0a
+11 -9
View File
@@ -59,9 +59,9 @@ necessary_credentials() {
#TARGET SETTINGS #TARGET SETTINGS
echo -e "\n\n➡️ This script needs information about the target you want to install NixOS on\n" echo -e "\n\n➡️ This script needs information about the target you want to install NixOS on\n"
user_input "TARGET_HOST" "➡️ Please provide the IP address of the target host :" "For example : 192.168.1.100" "${IP_REGEX}" "Invalid IP address format." user_input "TARGET_HOST" " Please provide the IP address of the target host :" "For example : 192.168.1.100" "${IP_REGEX}" "Invalid IP address format."
user_input "REMOTE_PASS" "➡️ Please enter the password for '${TARGET_USER}@${TARGET_HOST}' :" "${TARGET_HOST}'s password" "" "" "true" user_input "REMOTE_PASS" " Please enter the password for '${TARGET_USER}@${TARGET_HOST}' :" "${TARGET_HOST}'s password" "" "" "true"
user_input "SSH_PUBLIC_KEY" "➡️ Please provide the public SSH key of an authorized device :" "For example : ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGhcYDmjMo5YApLkk/3P3HZCnOSzm0uYewNAbxL8Fci8 user@your-pc" "${SSH_KEY_REGEX}" "Invalid SSH key format (must start with ssh-...)." "true" user_input "SSH_PUBLIC_KEY" " Please provide the public SSH key of an authorized device :" "For example : ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGhcYDmjMo5YApLkk/3P3HZCnOSzm0uYewNAbxL8Fci8 user@your-pc" "${SSH_KEY_REGEX}" "Invalid SSH key format (must start with ssh-...)." "true"
# TRAEFIK SETTINGS # TRAEFIK SETTINGS
echo -e "\n\n➡️ You will access your services via a domain name (e.g. cloud.mydomain.com) and containers need credentials to create those subdomains\n" echo -e "\n\n➡️ You will access your services via a domain name (e.g. cloud.mydomain.com) and containers need credentials to create those subdomains\n"
@@ -384,7 +384,7 @@ EOF
### --> Disk selection ### --> Disk selection
if [[ "${#DISK_NAME[@]}" -eq 0 ]]; then if [[ "${#DISK_NAME[@]}" -eq 0 ]]; then
echo -e "\n\n❌ No disks found on the target host. Aborting." echo -e "\n❌ No disks found on the target host. Aborting."
exit 1 exit 1
fi fi
@@ -397,6 +397,7 @@ EOF
local GUM_PRINTED_ELEMENTS+=("$GUM_PRINTED_ELEMENT") local GUM_PRINTED_ELEMENTS+=("$GUM_PRINTED_ELEMENT")
done done
echo ""
gum style --foreground 212 "➡️ Please choose one (stripe) or two (mirror) disks for your NixOS boot installation :" gum style --foreground 212 "➡️ Please choose one (stripe) or two (mirror) disks for your NixOS boot installation :"
local SELECTED_BOOT_DISK=$(gum choose --limit 2 --header "$HEADER" "${GUM_PRINTED_ELEMENTS[@]}") local SELECTED_BOOT_DISK=$(gum choose --limit 2 --header "$HEADER" "${GUM_PRINTED_ELEMENTS[@]}")
@@ -426,6 +427,7 @@ the one of the smallest disk."
exit 1 exit 1
fi fi
echo ""
gum style --foreground 212 "➡️ Please choose data and parity disks (up to 9 total) :" gum style --foreground 212 "➡️ Please choose data and parity disks (up to 9 total) :"
local SELECTED_DATA_DISK=$(gum choose --limit 9 --header "$HEADER" "${GUM_PRINTED_ELEMENTS[@]}") local SELECTED_DATA_DISK=$(gum choose --limit 9 --header "$HEADER" "${GUM_PRINTED_ELEMENTS[@]}")
@@ -451,13 +453,13 @@ Please review the selected disk layout before proceeding.
* **Boot 1:** \`${BOOT_DISKS_ID[0]}\` * **Boot 1:** \`${BOOT_DISKS_ID[0]}\`
$( [[ -n "${BOOT_DISKS_ID[1]:-}" ]] && echo "* **Boot 2:** \`${BOOT_DISKS_ID[1]}\`" || echo "* **Boot 2:** *Not configured*") $( [[ -n "${BOOT_DISKS_ID[1]:-}" ]] && echo "* **Boot 2:** \`${BOOT_DISKS_ID[1]}\`" || echo "* **Boot 2:** *Not configured*")
**Parity Disks ($PARITY_DISK_NUMBER):**
$(for i in $(seq 0 $((${#DATA_DISKS_ID[@]} - CONTENT_DISK_NUMBER))); do echo "* **Parity ${i}:** `${DATA_DISKS_ID[${i}]}`"; done)
$( [[ $PARITY_DISK_NUMBER -eq 0 ]] && echo "* *Not configured*")
**Data Disks ($CONTENT_DISK_NUMBER):** **Data Disks ($CONTENT_DISK_NUMBER):**
$(for i in $(seq $PARITY_DISK_NUMBER $((${#DATA_DISKS_ID[@]} - 1))); do echo "* **Data ${i}:** `${DATA_DISKS_ID[${i}]}`"; done) $(for i in $(seq 0 $(($CONTENT_DISK_NUMBER - 1))); do echo "* **Data ${i}:** `${DATA_DISKS_ID[${i}]}`"; done)
$( [[ $CONTENT_DISK_NUMBER -eq 0 ]] && echo "* *Not configured*") $( [[ $CONTENT_DISK_NUMBER -eq 0 ]] && echo "* *Not configured*")
**Parity Disks ($PARITY_DISK_NUMBER):**
$(for i in $(seq $CONTENT_DISK_NUMBER $((${#DATA_DISKS_ID[@]} - 1))); do echo "* **Parity ${i}:** `${DATA_DISKS_ID[${i}]}`"; done)
$( [[ $PARITY_DISK_NUMBER -eq 0 ]] && echo "* *Not configured*")
EOF EOF
) )