#!/bin/sh
set -eu

SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

show_help() {
    cat <<'EOF'
Usage: sudo scripts/update-systemd [options]

Refresh an existing native pobsync systemd install from the current checkout.

This is a thin, safer update wrapper around scripts/install-systemd. It keeps
the install non-interactive, preserves the existing environment file, skips
superuser creation, and skips OS package installation by default.

Common options are forwarded to install-systemd, for example:
  --source-dir PATH
  --app-dir PATH
  --venv-dir PATH
  --env-file PATH
  --service-user USER
  --service-group GROUP
  --install-extras mariadb
  --verbose

If OS packages need to be refreshed, run scripts/install-systemd directly.
EOF
}

case "${1:-}" in
    -h|--help)
        show_help
        exit 0
        ;;
esac

exec "$SCRIPT_DIR/install-systemd" \
    --non-interactive \
    --no-install-os-packages \
    --no-create-superuser \
    "$@"
