#!/bin/bash
# delinuxco-helper-scripts: version 0.1.4

set -euo pipefail  # Improved error handling

# 1. Inform the user BEFORE the action happens
echo "[INFO] Initiating syncthing service enablement for user: ${USER}"

# 2. Perform the action
# We use quotes around variables to prevent word splitting
if sudo systemctl enable --now "syncthing@${USER}"; then
    sleep 1
    echo "[OK] Syncthing service is now enabled and running."
else
    echo "[ERROR] Failed to enable syncthing service." >&2
    exit 1
fi

# 3. Final Instructions
echo "------------------------------------------------------------"
echo "To disable syncthing, run: disable-syncthing"
echo "------------------------------------------------------------"
