diff --git a/misc/build.func b/misc/build.func index b63449912..4ab48d8d8 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