#!/usr/bin/env bash # Removes the Homelab Manager task-reporting agent from this server: stops # and deletes its systemd timer/service, the installed script, and its # credentials file. # # Usage (must run as root — if not already root, put sudo right after the # pipe so it applies to bash, not to curl): # curl -fsSL https://homelab.example.lan/agent/linux/uninstall.sh | sudo bash # set -euo pipefail INSTALL_DIR="/usr/local/bin" CONFIG_DIR="/etc" SYSTEMD_DIR="/etc/systemd/system" if [[ "$EUID" -ne 0 ]]; then echo "This uninstaller must be run as root." >&2 echo "If you're piping from curl, put sudo right after the pipe so it elevates bash, not curl:" >&2 echo " curl -fsSL ... | sudo bash" >&2 exit 1 fi echo "Removing Homelab Manager agent..." if command -v systemctl >/dev/null 2>&1; then systemctl disable --now homelab-manager-agent.timer >/dev/null 2>&1 || true fi rm -f \ "$SYSTEMD_DIR/homelab-manager-agent.timer" \ "$SYSTEMD_DIR/homelab-manager-agent.service" \ "$CONFIG_DIR/homelab-manager-agent.env" \ "$INSTALL_DIR/homelab-manager-agent.sh" \ /tmp/hlm-agent-response.json if command -v systemctl >/dev/null 2>&1; then systemctl daemon-reload fi echo "Done. The agent no longer runs or reports from this server." echo "Its entry (and task history) in Homelab Manager is untouched —" \ "delete it from the Servers & Tasks page if you no longer want it tracked."