#!/bin/bash
# Removes the RootManage Security Audit only. Other RootManage agents and /etc/rootmanage/agent.env are left alone.
set -u
if [[ "$(id -u)" -ne 0 ]]; then echo "Run as root: sudo bash" >&2; exit 1; fi
if command -v systemctl >/dev/null 2>&1; then
  systemctl disable --now rootmanage-audit.timer >/dev/null 2>&1 || true
  systemctl disable --now rootmanage-audit-poll.timer >/dev/null 2>&1 || true
  rm -f /etc/systemd/system/rootmanage-audit.timer /etc/systemd/system/rootmanage-audit.service /etc/systemd/system/rootmanage-audit-poll.timer /etc/systemd/system/rootmanage-audit-poll.service
  systemctl daemon-reload >/dev/null 2>&1 || true
fi
rm -f /etc/cron.d/rootmanage-audit /usr/local/bin/rootmanage-audit /usr/bin/rootmanage-audit /var/lib/rootmanage/audit.body.json /var/lib/rootmanage/audit.resp.json
echo "RootManage Security Audit was removed. Other RootManage agents were not changed."
