From 9bf653e876b1bd584997251282c52f4da51a5979 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Mon, 12 May 2025 14:21:09 +0200 Subject: [PATCH] Changes to Config File Logic --- misc/build.func | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/misc/build.func b/misc/build.func index b634499..4ab48d8 100644 --- a/misc/build.func +++ b/misc/build.func @@ -706,7 +706,11 @@ config_file() { msg_error "Invalid Container ID range. The first number must be smaller than the second number, was ${CT_ID}" exit fi - LIST_OF_IDS=$(pvesh get /cluster/resources --type vm --output-format json | grep -oP '"vmid":\s*\K\d+') + LIST_OF_IDS="" + OUTPUT=$(pvesh get /cluster/resources --type vm --output-format json 2>/dev/null) || true + if [[ -n "$OUTPUT" ]]; then + LIST_OF_IDS=$(echo "$OUTPUT" | grep -oP '"vmid":\s*\K\d+') + fi if [[ ! -z "$LIST_OF_IDS" ]]; then for ((ID = MIN_ID; ID <= MAX_ID; ID++)); do if ! grep -q "^$ID$" <<<"$LIST_OF_IDS"; then @@ -719,8 +723,11 @@ config_file() { elif [[ "$CT_ID" =~ ^[0-9]+$ ]]; then echo "Befor LIST_OF_IDS" - pvesh get /cluster/resources --type vm --output-format json - LIST_OF_IDS=$(pvesh get /cluster/resources --type vm --output-format json | grep -oP '"vmid":\s*\K\d+') + LIST_OF_IDS="" + OUTPUT=$(pvesh get /cluster/resources --type vm --output-format json 2>/dev/null) || true + if [[ -n "$OUTPUT" ]]; then + LIST_OF_IDS=$(echo "$OUTPUT" | grep -oP '"vmid":\s*\K\d+') + fi if [[ -n "$LIST_OF_IDS" ]]; then if ! grep -q "^$CT_ID$" <<<"$LIST_OF_IDS"; then