#!/bin/sh # Roundtable host agent installer # Generated for: {{ host_name }} ({{ host_address }}) # Roundtable URL: {{ url }} set -e ROUNDTABLE_URL="{{ url }}" AGENT_TOKEN="{{ token }}" AGENT_VERSION="{{ agent_version }}" AGENT_USER="roundtable-agent" AGENT_DIR="/usr/local/lib/roundtable-agent" CONF_FILE="/etc/roundtable-agent.conf" UNIT_FILE="/etc/systemd/system/roundtable-agent.service" # ── preflight ──────────────────────────────────────────────────────────────── [ "$(id -u)" = "0" ] || { echo "must run as root (use sudo)"; exit 1; } command -v systemctl >/dev/null 2>&1 || { echo "systemd not found — unsupported init system"; exit 1; } command -v python3 >/dev/null 2>&1 || { echo "python3 not found — install python3 first"; exit 1; } # Handle --uninstall if [ "${1:-}" = "--uninstall" ]; then systemctl disable --now roundtable-agent.service 2>/dev/null || true rm -f "$UNIT_FILE" "$CONF_FILE" rm -rf "$AGENT_DIR" systemctl daemon-reload # keep the system user — removing it risks orphaned files elsewhere echo "uninstalled" exit 0 fi # ── create system user ─────────────────────────────────────────────────────── if ! id "$AGENT_USER" >/dev/null 2>&1; then useradd --system --no-create-home --shell /usr/sbin/nologin "$AGENT_USER" fi # ── drop the agent file ────────────────────────────────────────────────────── mkdir -p "$AGENT_DIR" curl -sSL "${ROUNDTABLE_URL}/plugins/host_agent/agent.py" -o "$AGENT_DIR/agent.py" chmod 0755 "$AGENT_DIR/agent.py" chown root:root "$AGENT_DIR/agent.py" # ── write config ───────────────────────────────────────────────────────────── cat > "$CONF_FILE" < "$UNIT_FILE" <