From a307bfc9f8666b6662a38493bfb2111a46f2c1ef Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sat, 13 Dec 2025 21:44:00 +0000 Subject: [PATCH] feat: thorough uninstall cleans up legacy agents and all artifacts The --uninstall flag now removes: - Unified pulse-agent (service, binary, logs) - Legacy pulse-host-agent (service, binary, logs) - Legacy pulse-docker-agent (service, binary, logs) - Agent state directory (/var/lib/pulse-agent) - All related log files Works on Linux (systemd), macOS (launchd), and other supported platforms. --- scripts/install.sh | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 1b1e46d..aed9e2b 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -135,21 +135,56 @@ done # --- Uninstall Logic --- if [[ "$UNINSTALL" == "true" ]]; then - log_info "Uninstalling ${AGENT_NAME}..." + log_info "Uninstalling ${AGENT_NAME} and cleaning up legacy agents..." - # Systemd + # Kill any running agent processes first + pkill -f "pulse-agent" 2>/dev/null || true + pkill -f "pulse-host-agent" 2>/dev/null || true + pkill -f "pulse-docker-agent" 2>/dev/null || true + sleep 1 + + # Systemd - unified agent if command -v systemctl >/dev/null 2>&1; then systemctl stop "${AGENT_NAME}" 2>/dev/null || true systemctl disable "${AGENT_NAME}" 2>/dev/null || true rm -f "/etc/systemd/system/${AGENT_NAME}.service" + + # Legacy agents cleanup + systemctl stop pulse-host-agent 2>/dev/null || true + systemctl disable pulse-host-agent 2>/dev/null || true + rm -f /etc/systemd/system/pulse-host-agent.service + + systemctl stop pulse-docker-agent 2>/dev/null || true + systemctl disable pulse-docker-agent 2>/dev/null || true + rm -f /etc/systemd/system/pulse-docker-agent.service + systemctl daemon-reload 2>/dev/null || true fi + # Remove legacy binaries + rm -f /usr/local/bin/pulse-host-agent + rm -f /usr/local/bin/pulse-docker-agent + + # Remove agent state directory (contains agent ID, proxmox registration state, etc.) + rm -rf /var/lib/pulse-agent + + # Remove log files + rm -f /var/log/pulse-agent.log + rm -f /var/log/pulse-host-agent.log + rm -f /var/log/pulse-docker-agent.log + # Launchd (macOS) if [[ "$(uname -s)" == "Darwin" ]]; then + # Unified agent PLIST="/Library/LaunchDaemons/com.pulse.agent.plist" launchctl unload "$PLIST" 2>/dev/null || true rm -f "$PLIST" + + # Legacy agents + launchctl unload /Library/LaunchDaemons/com.pulse.host-agent.plist 2>/dev/null || true + rm -f /Library/LaunchDaemons/com.pulse.host-agent.plist + launchctl unload /Library/LaunchDaemons/com.pulse.docker-agent.plist 2>/dev/null || true + rm -f /Library/LaunchDaemons/com.pulse.docker-agent.plist fi # Synology DSM (handles both DSM 7+ systemd and DSM 6.x upstart)