Files
ScheduleTaskManager/agent/linux/uninstall.sh
T
bobban 0615866311 Add agent uninstall script and UI reveal
Lets a server be cleanly removed from agent management: uninstall.sh
stops/disables the systemd timer and deletes the unit files, the
installed script, and the credentials env file, without touching the
server's entry or task history in the app. install.sh now prints the
uninstall command on success, and the Servers page has an "Uninstall"
button that reveals the same command (safe to show anytime since it
carries no secret).
2026-09-02 22:21:05 +02:00

39 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Removes the Schedule Task Manager agent from this server: stops and deletes
# its systemd timer/service, the installed script, and its credentials file.
#
# Usage:
# curl -fsSL https://schedule.example.lan/agent/linux/uninstall.sh | 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
exit 1
fi
echo "Removing Schedule Task Manager agent..."
if command -v systemctl >/dev/null 2>&1; then
systemctl disable --now schedule-task-manager-agent.timer >/dev/null 2>&1 || true
fi
rm -f \
"$SYSTEMD_DIR/schedule-task-manager-agent.timer" \
"$SYSTEMD_DIR/schedule-task-manager-agent.service" \
"$CONFIG_DIR/schedule-task-manager-agent.env" \
"$INSTALL_DIR/schedule-task-manager-agent.sh" \
/tmp/stm-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 Schedule Task Manager is untouched —" \
"delete it from the Servers page if you no longer want it tracked."