#!/usr/bin/env bash
set -euo pipefail
case "${1:-}" in
  uninstall)
    if [[ "${2:-}" == "--full" ]]; then
      systemctl disable --now scpanel-admin scpanel-user 2>/dev/null || true
      rm -f /etc/systemd/system/scpanel-admin.service /etc/systemd/system/scpanel-user.service
      systemctl daemon-reload
      rm -rf /opt/scpanel /etc/scpanel /var/lib/scpanel
      rm -f /usr/local/bin/scpanelctl
      echo "SIKON Cpanel fully removed."
    else
      echo "Use: scpanelctl uninstall --full"
    fi
    ;;
  version)
    cat /opt/scpanel/RELEASE_VERSION 2>/dev/null || echo "not installed"
    ;;
  status)
    systemctl --no-pager --full status scpanel-admin scpanel-user
    ;;
  reset-admin)
    echo "Use Admin User > Settings to change the scroot password."
    ;;
  *)
    echo "Usage: scpanelctl {version|status|reset-admin|uninstall --full}"
    exit 1
    ;;
esac
