#!/usr/bin/env bash
set -u
BASE="${NORAX_BASE:-https://noraxdev.org}"
TMP="${TMPDIR:-/tmp}/norax-connect-lite.py"
echo "Starting Norax Connect from $BASE ..."
if ! command -v python3 >/dev/null 2>&1; then
  echo "Python 3 is required. Most Linux desktops include it by default."
  exit 1
fi
if command -v curl >/dev/null 2>&1; then
  curl -fL "$BASE/connect-lite.py" -o "$TMP"
elif command -v wget >/dev/null 2>&1; then
  wget -O "$TMP" "$BASE/connect-lite.py"
else
  python3 - <<PY
import urllib.request
urllib.request.urlretrieve('$BASE/connect-lite.py', '$TMP')
PY
fi
exec python3 "$TMP" "$@"
