uninstall.sh 929 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. # Remove hthd units and binaries. Does not delete /var/lib/hth captures unless --purge.
  3. set -euo pipefail
  4. PREFIX="${PREFIX:-/usr/local}"
  5. BINDIR="${BINDIR:-${PREFIX}/bin}"
  6. LIBDIR="${LIBDIR:-/usr/lib}"
  7. SYSCONFDIR="${SYSCONFDIR:-/etc}"
  8. UNITDIR="${UNITDIR:-${SYSCONFDIR}/systemd/system}"
  9. ETCDIR="${ETCDIR:-${SYSCONFDIR}/hth}"
  10. PURGE=0
  11. if [[ "${1:-}" == "--purge" ]]; then
  12. PURGE=1
  13. fi
  14. if command -v systemctl >/dev/null 2>&1 && [[ "$(cat /proc/1/comm 2>/dev/null)" == systemd ]]; then
  15. systemctl disable --now hthd.service 2>/dev/null || true
  16. systemctl daemon-reload || true
  17. fi
  18. rm -f "${BINDIR}/hthd" "${BINDIR}/hthctl" "${BINDIR}/hth-capture"
  19. rm -f "${UNITDIR}/hthd.service" "${UNITDIR}/hthd@.service"
  20. rm -f "${LIBDIR}/sysusers.d/hth.conf" "${LIBDIR}/tmpfiles.d/hth.conf"
  21. if [[ "${PURGE}" -eq 1 ]]; then
  22. rm -rf "${ETCDIR}" /var/lib/hth /run/hth
  23. fi
  24. echo "uninstalled hthd binaries and units (purge=${PURGE})"