diff --git a/agents/proxmox_auto_enroll.sh b/agents/proxmox_auto_enroll.sh index 809b72e..1381452 100755 --- a/agents/proxmox_auto_enroll.sh +++ b/agents/proxmox_auto_enroll.sh @@ -197,6 +197,40 @@ while IFS= read -r line; do continue fi + # Check if agent is already installed and working BEFORE enrollment + info " Checking if agent is already configured..." + config_check=$(timeout 10 pct exec "$vmid" -- bash -c " + if [[ -f /etc/patchmon/config.yml ]] && [[ -f /etc/patchmon/credentials.yml ]]; then + if [[ -f /usr/local/bin/patchmon-agent ]]; then + # Try to ping using existing configuration + if /usr/local/bin/patchmon-agent ping >/dev/null 2>&1; then + echo 'ping_success' + else + echo 'ping_failed' + fi + else + echo 'binary_missing' + fi + else + echo 'not_configured' + fi + " 2>/dev/null /dev/null 2>&1; then - echo 'ping_success' - else - echo 'ping_failed' - fi - else - echo 'binary_missing' - fi - else - echo 'not_configured' - fi - " 2>/dev/null /dev/null 2>&1 && echo 'installed' || echo 'missing'" 2>/dev/null