Fixed disk selection recap logic.
This commit is contained in:
@@ -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"
|
||||||
@@ -330,7 +330,7 @@ disk_config_generation() {
|
|||||||
"
|
"
|
||||||
gum confirm "Do you understand and wish to proceed?" || { echo -e "\n\n❌ Aborting as requested."; exit 1; }
|
gum confirm "Do you understand and wish to proceed?" || { echo -e "\n\n❌ Aborting as requested."; exit 1; }
|
||||||
|
|
||||||
echo -e "\n\n 🔎 Fetching and analyzing disks from target host... (This may take a moment)"
|
echo -e "\n\n🔎 Fetching and analyzing disks from target host... (This may take a moment)"
|
||||||
### Disk wiping warning <--
|
### Disk wiping warning <--
|
||||||
|
|
||||||
### --> Get disk information
|
### --> Get disk information
|
||||||
@@ -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[@]}")
|
||||||
@@ -412,13 +413,13 @@ EOF
|
|||||||
echo -e "\n\n❌ No boot disk selected. Aborting."
|
echo -e "\n\n❌ No boot disk selected. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "${#BOOT_DISKS_ID[@]}" -eq 1 ]]; then
|
elif [[ "${#BOOT_DISKS_ID[@]}" -eq 1 ]]; then
|
||||||
echo -e "\n\n ⚠️ One boot disk selected, continuing with striped boot disk configuration."
|
echo -e "\n\n⚠️ One boot disk selected, continuing with striped boot disk configuration."
|
||||||
echo -e " Consider using 2 boot disks instead to get data protection features on the boot disks."
|
echo -e "Consider using 2 boot disks instead to get data protection features on the boot disks."
|
||||||
export BOOT_DISK_1_ID=${BOOT_DISKS_ID[0]}
|
export BOOT_DISK_1_ID=${BOOT_DISKS_ID[0]}
|
||||||
elif [[ "${#BOOT_DISKS_ID[@]}" -eq 2 ]]; then
|
elif [[ "${#BOOT_DISKS_ID[@]}" -eq 2 ]]; then
|
||||||
echo -e "\n\n✅ Two boot disks selected, continuing with mirrored boot disks configuration."
|
echo -e "\n\n✅ Two boot disks selected, continuing with mirrored boot disks configuration."
|
||||||
echo -e "\n\n ⚠️ If the two disks are different sizes, the resulting usable space size will be \
|
echo -e "\n\n⚠️ If the two disks are different sizes, the resulting usable space size will be \
|
||||||
the one of the smallest disk."
|
the one of the smallest disk."
|
||||||
export BOOT_DISK_1_ID=${BOOT_DISKS_ID[0]}
|
export BOOT_DISK_1_ID=${BOOT_DISKS_ID[0]}
|
||||||
export BOOT_DISK_2_ID=${BOOT_DISKS_ID[1]}
|
export BOOT_DISK_2_ID=${BOOT_DISKS_ID[1]}
|
||||||
else
|
else
|
||||||
@@ -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
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -494,7 +496,7 @@ EOF
|
|||||||
EOF
|
EOF
|
||||||
j=0
|
j=0
|
||||||
for i in $(seq 0 $(($CONTENT_DISK_NUMBER - 1))); do
|
for i in $(seq 0 $(($CONTENT_DISK_NUMBER - 1))); do
|
||||||
export j=$((j+1))
|
export j=$((j + 1))
|
||||||
export CONTENT_DISK_ID="${DATA_DISKS_ID[${i}]}"
|
export CONTENT_DISK_ID="${DATA_DISKS_ID[${i}]}"
|
||||||
(envsubst < "templates/nix-config/disks/content.nix") >> final-nix-config/etc/nixos/disks/disko.nix
|
(envsubst < "templates/nix-config/disks/content.nix") >> final-nix-config/etc/nixos/disks/disko.nix
|
||||||
cat << EOF >> final-nix-config/etc/nixos/disks/snapraid.nix
|
cat << EOF >> final-nix-config/etc/nixos/disks/snapraid.nix
|
||||||
@@ -507,7 +509,7 @@ EOF
|
|||||||
echo -e "\n✅ Generated $CONTENT_DISK_NUMBER data disk configuration(s)."
|
echo -e "\n✅ Generated $CONTENT_DISK_NUMBER data disk configuration(s)."
|
||||||
j=0
|
j=0
|
||||||
for i in $(seq $PARITY_DISK_NUMBER $((${#DATA_DISKS_ID[@]} - 1))); do
|
for i in $(seq $PARITY_DISK_NUMBER $((${#DATA_DISKS_ID[@]} - 1))); do
|
||||||
export j=$((j+1))
|
export j=$((j + 1))
|
||||||
export PARITY_DISK_ID="${DATA_DISKS_ID[${i}]}"
|
export PARITY_DISK_ID="${DATA_DISKS_ID[${i}]}"
|
||||||
(envsubst < "templates/nix-config/disks/parity.nix") >> final-nix-config/etc/nixos/disks/disko.nix
|
(envsubst < "templates/nix-config/disks/parity.nix") >> final-nix-config/etc/nixos/disks/disko.nix
|
||||||
cat << EOF >> final-nix-config/etc/nixos/disks/snapraid.nix
|
cat << EOF >> final-nix-config/etc/nixos/disks/snapraid.nix
|
||||||
|
|||||||
Reference in New Issue
Block a user