mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-11-08 22:40:45 +01:00
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:
+3
-2
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user