From f06e084e2f6de095a2d083e3d82aa51f282da789 Mon Sep 17 00:00:00 2001 From: defiQUG Date: Sun, 12 Apr 2026 06:44:13 -0700 Subject: [PATCH] fix(health): verify-lxc-configs-on-hosts optional --vmid filter Add usage/help and limit checks to specific VMIDs when iterating hosts. Made-with: Cursor --- scripts/health/verify-lxc-configs-on-hosts.sh | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/scripts/health/verify-lxc-configs-on-hosts.sh b/scripts/health/verify-lxc-configs-on-hosts.sh index a39a92e1..5ce0cfc7 100644 --- a/scripts/health/verify-lxc-configs-on-hosts.sh +++ b/scripts/health/verify-lxc-configs-on-hosts.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash -# Verify every RPC (and optionally other) VM has an LXC config file on its Proxmox host. +# Verify every RPC VM has an LXC config file on its Proxmox host. # SSHs to each host and checks pct config for expected VMIDs on that host. # Run from project root. -# Usage: ./scripts/health/verify-lxc-configs-on-hosts.sh +# Usage: +# ./scripts/health/verify-lxc-configs-on-hosts.sh +# ./scripts/health/verify-lxc-configs-on-hosts.sh --vmid 2301 set -euo pipefail @@ -26,6 +28,45 @@ RED='\033[0;31m' GREEN='\033[0;32m' CYAN='\033[0;36m' NC='\033[0m' +TARGET_VMIDS=() + +usage() { + cat <<'EOF' +Usage: ./scripts/health/verify-lxc-configs-on-hosts.sh [--vmid ] + +Options: + --vmid Limit to one VMID; repeatable +EOF +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --vmid) + [[ $# -ge 2 ]] || { usage >&2; exit 2; } + TARGET_VMIDS+=("$2") + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown argument: $1" >&2 + usage >&2 + exit 2 + ;; + esac +done + +selected_vmid() { + local vmid="$1" + [[ ${#TARGET_VMIDS[@]} -eq 0 ]] && return 0 + local wanted + for wanted in "${TARGET_VMIDS[@]}"; do + [[ "$vmid" == "$wanted" ]] && return 0 + done + return 1 +} echo -e "${CYAN}=== Verify LXC config files on Proxmox hosts ===${NC}" echo "" @@ -34,6 +75,7 @@ ok=0 fail=0 for entry in "${RPC_NODES[@]}"; do IFS=: read -r vmid host <<< "$entry" + selected_vmid "$vmid" || continue ssh_target="${PROXMOX_SSH_USER}@${host}" out=$(ssh $SSH_OPTS "$ssh_target" "pct config $vmid 2>&1" || true) if echo "$out" | grep -q "Configuration file.*does not exist\|No such file"; then