Files
otaman/start.sh
T
catarrh 8c41655e18 v1.9.23: auto-detect PC/SC reader with retry on startup
__main__.py:
- Probe smartcard.System.readers() before init_reader when no reader
  was explicitly specified
- Retry 3 times with 2s delay to handle late pcscd startup and
  USB enumeration delays

start.sh:
- Also match pcscd.bin process name (some distros)
- Wait 1s for pcscd if not running yet
2026-08-31 22:49:52 +03:00

42 lines
1.3 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; then
# Give pcscd a moment if it's not running yet (USB enumeration delay)
if ! pgrep -x pcscd > /dev/null 2>&1 && ! pgrep -x pcscd.bin > /dev/null 2>&1; then
sleep 1
fi
if pgrep -x pcscd > /dev/null 2>&1 || pgrep -x pcscd.bin > /dev/null 2>&1; then
READER_ARGS="-p 0"
fi
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