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

if [[ "${EUID}" -ne 0 ]]; then
  echo "Please run as root: sudo ./scripts/uninstall.sh"
  exit 1
fi

echo "Uninstalling GAL-2 Time Contract Linux service..."

if command -v systemctl >/dev/null 2>&1; then
  systemctl stop gal2d.service 2>/dev/null || true
  systemctl disable gal2d.service 2>/dev/null || true
  rm -f /etc/systemd/system/gal2d.service
  systemctl daemon-reload 2>/dev/null || true
fi

echo "Preserving /etc/gal2/daemon.env by default."
echo "Preserving /usr/local/gal2 by default."
echo "Remove manually if desired:"
echo "  sudo rm -rf /usr/local/gal2 /etc/gal2"
