#!/usr/bin/env bash
set -euo pipefail

# The systemd service starts the actual manager. A desktop click only opens
# the already running local service and must not try to write /var/lib/voima
# as the desktop user.
if [[ "${VOIMA_SERVICE_MODE:-0}" != "1" && "$#" -eq 0 ]]; then
    exec xdg-open "https://localhost:${VOIMA_PORT:-5000}/?id=start"
fi

exec /opt/voima/VOIMA "$@"
