Files
ScheduleTaskManager/agent/linux/uninstall.sh
T
bobban 329dcab936 Fix agent install/uninstall sudo placement, add dependency install hints
curl ... | API_URL=... bash runs as the invoking user, not root, so
"sudo" has to go right after the pipe (elevating bash) rather than
before curl — the old commands in the app UI, README, and scripts'
own usage comments put it in a spot that still failed the root check.
Also have install.sh/report-tasks.sh suggest the right package-manager
command (apt/dnf/yum/apk/pacman/zypper) when curl or jq is missing
instead of just failing, and bring the README up to date with both.
2026-09-02 23:12:12 +02:00

42 lines
1.4 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 (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://schedule.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 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."