Use grep for Pimox showcmd validation
Homelab Main / validate (push) Waiting to run Details
Homelab Main / deploy (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-09-25 13:09:48 -06:00
parent c60413e2e2
commit 3c10516ab7
2 changed files with 6 additions and 22 deletions

View File

@ -312,21 +312,13 @@ cleanup() {
trap cleanup 0
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
if ! awk -v vmid=\"\$vmid\" '
{
for (i = 1; i <= NF; i++) {
qemu_suffix = \"qemu-system-aarch64\"
if ($i == "/usr/bin/kvm" || $i == "qemu-system-aarch64" || substr($i, length($i) - length(qemu_suffix) + 1) == qemu_suffix) kvm = 1
if ($i == "-id" && (i + 1) <= NF && $(i + 1) == 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 '{ for (i = 1; i <= NF; i++) if ($i == "-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

View File

@ -1552,21 +1552,13 @@ cleanup() {
trap cleanup 0
sudo \"\$qm_bin\" showcmd \"\$vmid\" --pretty >\"\$start_script\"
if ! awk -v vmid=\"\$vmid\" '
{
for (i = 1; i <= NF; i++) {
qemu_suffix = \"qemu-system-aarch64\"
if (\$i == "/usr/bin/kvm" || \$i == "qemu-system-aarch64" || substr(\$i, length(\$i) - length(qemu_suffix) + 1) == qemu_suffix) kvm = 1
if (\$i == "-id" && (i + 1) <= NF && \$(i + 1) == 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 '{ for (i = 1; i <= NF; i++) if (\$i == "-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