fix(truenas-vm): let a failed ISO lookup reach its own error

When download.truenas.com did not answer, the lookup handed an empty
path to an associative array (bad array subscript) and the pipeline
failed under pipefail, so the run ended with exit 1 at the SELECTED_ISO
line instead of the "Could not find a stable ISO" message. The index
fetch now fails on HTTP errors and retries, empty lines are skipped, and
the assignment no longer aborts on an empty result.
This commit is contained in:
MickLesk
2026-11-05 13:03:16 +01:00
parent 215f9be228
commit 2bd0387247
+3 -2
View File
@@ -39,7 +39,7 @@ function truenas_iso_lookup() {
local pre_releases=()
local all_paths=$(
curl -sL "$BASE_URL" |
curl -fsSL --retry 3 --retry-delay 2 --connect-timeout 15 --max-time 90 "$BASE_URL" |
grep -oE 'href="[^"]+\.iso"' |
sed 's/href="//; s/"$//' |
grep -vE '(MASTER|ALPHA)' |
@@ -47,6 +47,7 @@ function truenas_iso_lookup() {
)
while read -r path; do
[[ -n "$path" ]] || continue
local filename=$(basename "$path")
local version=$(echo "$filename" | sed -E 's/.*TrueNAS-SCALE-([0-9]{2}\.[0-9]{2}(\.[0-9]+)*(-RC[0-9]|-BETA[0-9])?)\.iso.*/\1/')
if [[ "$version" =~ (RC|BETA) ]]; then
@@ -139,7 +140,7 @@ post_to_api_vm
vm_select_storage "$HN"
if [ -z "${SELECTED_ISO:-}" ]; then
SELECTED_ISO=$(truenas_iso_lookup | grep -vE 'RC|BETA' | sort -V | tail -n 1)
SELECTED_ISO=$(truenas_iso_lookup | grep -vE 'RC|BETA' | sort -V | tail -n 1) || true
if [ -z "$SELECTED_ISO" ]; then
msg_error "Could not find a stable ISO for fallback."