#!/usr/bin/env bash
set -euo pipefail

AGENT_DIR="${HOME}/.local/share/powersearch-grid-agent"
CONF_DIR="${HOME}/.config/powersearch-grid"
UNIT_PATH="${HOME}/.config/systemd/user/powersearch-grid-agent.service"

if command -v systemctl >/dev/null 2>&1; then
  systemctl --user stop powersearch-grid-agent 2>/dev/null || true
  systemctl --user disable powersearch-grid-agent 2>/dev/null || true
  systemctl --user daemon-reload 2>/dev/null || true
fi

rm -f "$UNIT_PATH" || true
rm -rf "$AGENT_DIR" || true
rm -rf "$CONF_DIR" || true

echo "Uninstalled PowerSearch Grid edge agent."

