diff --git a/defaults.inc b/defaults.inc index 8d60755..fef0e04 100755 --- a/defaults.inc +++ b/defaults.inc @@ -3,7 +3,7 @@ action="${1:-}" FOLDER='/opt/idssys/ta-proxmenu' -VERS='2026.7.25-37' +VERS='2026.7.25-38' noupdate=' ' diff --git a/inc/deploy-iso-nfs-lxc.sh b/inc/deploy-iso-nfs-lxc.sh index a36132f..ba7b967 100644 --- a/inc/deploy-iso-nfs-lxc.sh +++ b/inc/deploy-iso-nfs-lxc.sh @@ -49,20 +49,47 @@ TAPM_ISO_NFS_SELECT_STORAGE() { local variable="$1" local label="$2" local default_value="$3" - local value + local storage type status index + local default_found=0 + local -a storage_ids=() + local -a storage_types=() + local -a labels=() + local -a values=() - echo - echo " Active storages that support LXC volumes:" - pvesm status --content rootdir 2>/dev/null | - awk 'NR == 1 || $3 == "active" { printf " %s\n", $1 }' - TAPM_ISO_NFS_PROMPT value "$label" "$default_value" - if ! pvesm status --content rootdir 2>/dev/null | - awk 'NR > 1 && $3 == "active" { print $1 }' | - grep -Fxq -- "$value"; then - TAPM_ISO_NFS_FAIL "Storage '${value}' is not active here or does not support LXC volumes." + while read -r storage type status _; do + [[ "$storage" != 'Name' && "$status" == 'active' ]] || continue + storage_ids+=("$storage") + storage_types+=("$type") + [[ "$storage" == "$default_value" ]] && default_found=1 + done < <(pvesm status --content rootdir --enabled 1 2>/dev/null) + + if (( ${#storage_ids[@]} == 0 )); then + TAPM_ISO_NFS_FAIL "No active, enabled storage supports LXC volumes." return 1 fi - printf -v "$variable" '%s' "$value" + + # Put the suggested storage first so pressing ENTER retains the default. + if (( default_found == 1 )); then + for index in "${!storage_ids[@]}"; do + [[ "${storage_ids[$index]}" == "$default_value" ]] || continue + labels+=("${storage_ids[$index]} (${storage_types[$index]}) — default") + values+=("storage:${storage_ids[$index]}") + break + done + fi + for index in "${!storage_ids[@]}"; do + [[ $default_found == 1 && "${storage_ids[$index]}" == "$default_value" ]] && + continue + labels+=("${storage_ids[$index]} (${storage_types[$index]})") + values+=("storage:${storage_ids[$index]}") + done + + SELECT_MENU "$label" labels values + case "$MENU_SELECTION" in + storage:*) printf -v "$variable" '%s' "${MENU_SELECTION#storage:}";; + quit) EXIT1; exit 0;; + *) return 1;; + esac } TAPM_DEPLOY_ISO_NFS_LXC() {