From 28ca7469e87d4bb275b3b1f0fb564d60ed320780 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Sun, 20 Apr 2025 21:35:31 +0100 Subject: [PATCH] fix: Use pvesh and jq for more robust storage detection --- scripts/setup-proxmox-lxc.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/setup-proxmox-lxc.sh b/scripts/setup-proxmox-lxc.sh index 9d33af70c..8cfee4583 100644 --- a/scripts/setup-proxmox-lxc.sh +++ b/scripts/setup-proxmox-lxc.sh @@ -84,9 +84,19 @@ gather_lxc_config() { print_info "Password set." # --- Storage --- - print_info "Available storage locations:" + print_info "Attempting to list suitable storage locations..." local storage_options - storage_options=$(pvesm status --content rootdir,images | awk 'NR>1 {print $1}') + # Try using pvesh get storage + jq (requires jq to be installed) + if command -v jq &> /dev/null; then + # Get storage IDs where content includes rootdir or images + storage_options=$(pvesh get /storage --output-format json | jq -r '.[] | select(.content | contains("rootdir") or contains("images")) | .storage') + else + print_warning "'jq' command not found. Attempting fallback method for storage detection." + print_warning "Please install jq (`apt update && apt install jq`) for more reliable storage detection." + # Fallback using grep/awk on json output (less robust) + storage_options=$(pvesh get /storage --output-format json | grep -B 1 -E '("content":.*"rootdir"|\"content\":.*"images")' | grep '"storage":' | awk -F'"' '{print $4}') + fi + # Check if any storage found if [ -z "$storage_options" ]; then print_error "No suitable storage locations found for LXC containers (content type 'rootdir' or 'images')."