Changes to Config File Logic

This commit is contained in:
Michel Roegl-Brunner 2025-05-12 14:21:09 +02:00
parent 059260d0fd
commit 9bf653e876

View File

@ -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