Files
otaman/start.sh
T
catarrh d2c292e5b8 Merge pysim-otaman-server into otaman (monorepo, v1.7.0)
- Move PWA into frontend/; server package at pysim_otaman_server/
- Server now serves the PWA (same origin -> no CORS/PNA): static file handler
  + --web-dir flag + injects window.PYSIM_EMBEDDED marker into index.html
- Frontend defaults to relative API base when embedded (pysimBase = '')
- Version 1.7.0 aligned: server.py VERSION, pyproject.toml, PWA header
- SW cache bump otaman-v7 -> otaman-v8
- Docs: combined README + docs/api.md endpoint reference; update links
- Fix stale package.json repository URL
2026-08-14 15:48:38 +03:00

37 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# pysim-otaman-server start script
# Starts the server, preferring the venv if it exists.
# Auto-detects PC/SC reader if available.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VENV_DIR="$SCRIPT_DIR/.venv"
# Auto-detect reader
READER_ARGS=""
if command -v pcscd > /dev/null 2>&1 && pgrep -x pcscd > /dev/null 2>&1; then
READER_ARGS="-p 0"
elif [ -e /dev/ttyUSB0 ]; then
READER_ARGS="-d /dev/ttyUSB0"
fi
SERVER=""
if [ -f "$VENV_DIR/bin/pysim-otaman-server" ]; then
SERVER="$VENV_DIR/bin/pysim-otaman-server"
elif command -v pysim-otaman-server &> /dev/null; then
SERVER="pysim-otaman-server"
elif [ -f "$SCRIPT_DIR/pysim_otaman_server/__main__.py" ]; then
echo "Starting pysim-otaman-server from source on http://127.0.0.1:8080"
cd "$SCRIPT_DIR" && python3 -m pysim_otaman_server --http-port 8080 $READER_ARGS
exit $?
else
echo "Error: pysim-otaman-server not installed."
echo "Run setup.sh first or install manually:"
echo " pip install pysim-otaman-server"
exit 1
fi
echo "Starting pysim-otaman-server on http://127.0.0.1:8080"
echo "Press Ctrl+C to stop."
$SERVER --http-port 8080 $READER_ARGS