#!/bin/sh set -eu cd "$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" if ! command -v python3 >/dev/null 2>&1; then echo 'Install Python 3.10 or newer, then run this script again.' >&2 exit 1 fi if [ ! -x .venv/bin/python ]; then echo 'Preparing the Python environment...' if ! python3 -m venv .venv; then echo 'Could not create .venv. Install Python venv support through your operating system, then try again.' >&2 exit 1 fi fi PYTHON=.venv/bin/python "$PYTHON" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3,10) else "Python 3.10 or newer is required.")' FINGERPRINT=$("$PYTHON" -c 'from pathlib import Path; import hashlib; print(hashlib.sha256(Path("requirements.txt").read_bytes()).hexdigest())') PREVIOUS=$(cat .venv/ose-requirements.sha256 2>/dev/null || true) if [ "$FINGERPRINT" != "$PREVIOUS" ]; then echo 'Installing the server dependencies. The first run may take a few minutes...' "$PYTHON" -m pip install -r requirements.txt printf '%s\n' "$FINGERPRINT" > .venv/ose-requirements.sha256 fi if ! "$PYTHON" -c 'from server_config import load_config; raise SystemExit(0 if load_config()["setup_complete"] else 1)'; then "$PYTHON" manage.py setup fi echo 'Starting OSE. Press Ctrl+C to stop it.' exec "$PYTHON" -u server.py "$@"