#!/usr/bin/env bash
# Used by systemd ga-dashboard.service. Pick venv python, else system python3.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
if [[ -x "$ROOT/.venv/bin/python" ]]; then
  exec "$ROOT/.venv/bin/python" "$ROOT/dashboard.py"
fi
echo "run_dashboard.sh: missing $ROOT/.venv/bin/python" >&2
echo "On the server run: cd $ROOT && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt" >&2
exec /usr/bin/python3 "$ROOT/dashboard.py"
