From 0b36e21a38620ce25ac77d933180a0ad57f909e6 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Fri, 25 Sep 2026 13:39:14 -0600 Subject: [PATCH] Use grep for Pimox template showcmd validation --- bootstrap/provisioning/main.tf | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bootstrap/provisioning/main.tf b/bootstrap/provisioning/main.tf index 2a0da2d..bbeca34 100644 --- a/bootstrap/provisioning/main.tf +++ b/bootstrap/provisioning/main.tf @@ -195,15 +195,13 @@ start_vm() { trap 'rm -f "$start_script"' 0 sudo "$qm_cmd" showcmd "$vmid" --pretty >"$start_script" - if ! awk -v vmid="$vmid" ' - NR == 1 && ($1 == "/usr/bin/kvm" || $1 ~ /qemu-system-aarch64$/) { kvm = 1 } - $1 == "-id" && $2 == vmid { id = 1 } - END { exit (kvm && id) ? 0 : 1 } - ' "$start_script"; then + if ! { grep -Fq -- '/usr/bin/kvm' "$start_script" || grep -Fq -- 'qemu-system-aarch64' "$start_script"; } || + ! grep -Fq -- "-id $vmid" "$start_script"; then echo "qm showcmd for VM $vmid did not produce the expected KVM command" >&2 + sed 's/^/ showcmd: /' "$start_script" >&2 exit 1 fi - smp_count="$(awk '$1 == "-smp" { count++ } END { print count + 0 }' "$start_script")" + smp_count="$(grep -c '^[[:space:]]*-smp[[:space:]]' "$start_script" || true)" if [ "$smp_count" -ne 1 ]; then echo "Expected one native -smp argument for VM $vmid, found $smp_count. Remove stale qm args before starting." >&2 exit 1