62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SERVICE_NAME="luxtools-client"
|
|
INSTALL_DIR="${HOME}/.local/share/${SERVICE_NAME}"
|
|
CONFIG_DIR="${HOME}/.config/${SERVICE_NAME}"
|
|
UNIT_FILE="${HOME}/.config/systemd/user/${SERVICE_NAME}.service"
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage: $0 [--keep-config]
|
|
|
|
Uninstalls ${SERVICE_NAME} systemd *user* service and removes installed files.
|
|
|
|
Options:
|
|
--keep-config Keep ${CONFIG_DIR} (token/config) on disk.
|
|
EOF
|
|
}
|
|
|
|
KEEP_CONFIG=0
|
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
|
usage
|
|
exit 0
|
|
fi
|
|
if [[ "${1:-}" == "--keep-config" ]]; then
|
|
KEEP_CONFIG=1
|
|
fi
|
|
|
|
# Stop/disable user service if present (best-effort).
|
|
systemctl --user stop "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
systemctl --user disable "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
systemctl --user reset-failed "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
|
|
# Also stop/disable any leftover system-wide service from older installs.
|
|
if systemctl list-unit-files 2>/dev/null | grep -q "^${SERVICE_NAME}\.service"; then
|
|
if [[ ${EUID} -eq 0 ]]; then
|
|
systemctl stop "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
systemctl disable "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
systemctl reset-failed "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
elif command -v sudo >/dev/null 2>&1; then
|
|
sudo systemctl stop "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
sudo systemctl disable "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
sudo systemctl reset-failed "$SERVICE_NAME" >/dev/null 2>&1 || true
|
|
else
|
|
echo "Note: a system service '${SERVICE_NAME}.service' exists; run with sudo to stop it." >&2
|
|
fi
|
|
fi
|
|
|
|
rm -f "$UNIT_FILE"
|
|
systemctl --user daemon-reload || true
|
|
|
|
rm -rf "$INSTALL_DIR"
|
|
|
|
if [[ $KEEP_CONFIG -eq 0 ]]; then
|
|
rm -rf "$CONFIG_DIR"
|
|
fi
|
|
|
|
echo "Uninstalled ${SERVICE_NAME}."
|
|
if [[ $KEEP_CONFIG -eq 1 ]]; then
|
|
echo "Kept config directory: ${CONFIG_DIR}"
|
|
fi
|