From 6eb26944707e8535766d2a02276edb2479e6374b Mon Sep 17 00:00:00 2001 From: rekushi <1+rekushi@noreply.flipnote.world> Date: Thu, 29 Oct 2026 04:40:14 +0000 Subject: [PATCH] feat(deploy): automate Linux and macOS startup Prepare the virtual environment, refresh changed dependencies and launch the configured server. --- start-ose.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 start-ose.sh diff --git a/start-ose.sh b/start-ose.sh new file mode 100644 index 0000000..2991022 --- /dev/null +++ b/start-ose.sh @@ -0,0 +1,28 @@ +#!/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 "$@"