Ports cron/systemd task tracking across Debian/Raspbian servers, including the Linux push agent (install/report/uninstall scripts, rebranded from "schedule-task-manager-agent" to "homelab-manager-agent") and the manual-task-entry flow for things an agent can't see (Docker jobs, backups). The schema (servers/scheduled_tasks tables) was already in place from the foundation pass, so this is mostly a straight port of the original's services/routes. Deliberate change from the original: server/token management (which mints agent credentials) is now admin-only rather than open to any logged-in user, and manual task CRUD is gated to operator+ — consistent with how Secrets, IPAM, and DNS already split "configure credentials" from "everyday edits" across roles. All mutations are audit-logged. - server/src/services/tokens.ts, taskSync.ts: ported near-verbatim (agent token hashing, the agent-sync-marks-missing-as-stale-not-deleted logic). - server/src/routes/servers.ts, tasks.ts, agentReport.ts: same contract as the original (agent auth is a per-server bearer token, independent of the session-based requireAuth used everywhere else). - web: a single Servers & Tasks page (filter bar, task table grouped by server/schedule type, manual task form, and an admin-only server management panel with token reveal + copyable install/uninstall commands), replacing the original's two separate pages/apps. Verified: full build passes; a scripted HTTP test against a running server covers unauthenticated access, role gating at each tier (admin-only server mgmt, operator+ task mgmt), agent bearer-token auth (valid/invalid/rotated), manual-vs-agent task edit protection, stale-marking on re-sync, and cascade delete — 22/22 checks passing. Real agent installation on an actual Debian/Raspbian host still needs to be tried on the user's network. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
43 lines
1.4 KiB
Bash
43 lines
1.4 KiB
Bash
#!/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."
|