diff --git a/docs/OPERATOR_GUIDE.md b/docs/OPERATOR_GUIDE.md index d6abe3a..ae208c0 100644 --- a/docs/OPERATOR_GUIDE.md +++ b/docs/OPERATOR_GUIDE.md @@ -144,7 +144,14 @@ rotating the old log to `content\parked_relay.log.1` so you can still see what h the window (or Ctrl-C) stops the relay for good. To have it come back after a reboot, put a *shortcut* to `park_relay.cmd` in your Startup folder (Win+R → `shell:startup`) — no admin needed. -Leave it running. Note the port it prints for operator control (**1507** = console port + 7) and +Leave it running. + +> **If you log in from a second account** (a dedicated remote-admin login over SSH/RDP), always +> park the relay with `park_relay.cmd` rather than typing `python ...` yourself. `python` only +> works for the main account here — it resolves through pyenv shims driven by `PYENV*` variables +> that are scoped to that user, and the one machine-wide Python entry points at a folder that no +> longer exists. The `.cmd` finds a real interpreter explicitly and prints which one it used; +> a bare `python` command from the other account just says "not recognized". Note the port it prints for operator control (**1507** = console port + 7) and copy `content\operator_secret.txt` — that string is what any console needs to connect, and it grants full mission control, so hand it out deliberately. diff --git a/tools/park_relay.cmd b/tools/park_relay.cmd index 47edb18..8e97176 100644 --- a/tools/park_relay.cmd +++ b/tools/park_relay.cmd @@ -8,10 +8,57 @@ REM itself after a reboot. No admin rights needed either way. REM REM The window stays open: it is the supervisor. Closing it (or Ctrl-C) REM stops the relay for good. +REM +REM WHY THIS HUNTS FOR AN INTERPRETER INSTEAD OF JUST SAYING "python" +REM (2026-07-26): on the operator's machine `python` resolves through +REM pyenv SHIMS that need PYENV/PYENV_HOME/PYENV_ROOT -- and those are +REM USER-scoped to the operator's own account. A second account (e.g. a +REM dedicated remote-admin login over SSH/RDP) gets NO working python at +REM all: the one machine-wide PATH entry points at a Python39-32 folder +REM that no longer exists. Parking the relay would then fail with +REM "python is not recognized" -- from the road, at night, with players +REM waiting. So: resolve a real interpreter explicitly, and say which. REM =================================================================== +setlocal title BattleTech relay (parked) cd /d "%~dp0.." -python "tools\btrelay_park.py" %* + +set "BTPY=" + +REM 1. explicit override always wins +if defined BT_PYTHON if exist "%BT_PYTHON%" set "BTPY=%BT_PYTHON%" + +REM 2. the interpreter this project is developed against (has PySide6). +REM Check the CALLING account's profile first, then the operator's -- +REM a second admin account can read it (Administrators has access). +if not defined BTPY if exist "%USERPROFILE%\.pyenv\pyenv-win\versions\3.11.4\python.exe" set "BTPY=%USERPROFILE%\.pyenv\pyenv-win\versions\3.11.4\python.exe" +if not defined BTPY if exist "C:\Users\epilectrik\.pyenv\pyenv-win\versions\3.11.4\python.exe" set "BTPY=C:\Users\epilectrik\.pyenv\pyenv-win\versions\3.11.4\python.exe" + +REM 3. the machine-wide launcher (works for ANY account) +if not defined BTPY ( + if exist "C:\Windows\py.exe" set "BTPY=C:\Windows\py.exe -3" +) + +REM 4. whatever is on PATH, if anything +if not defined BTPY ( + for /f "delims=" %%P in ('where python 2^>nul') do ( + if not defined BTPY set "BTPY=%%P" + ) +) + +if not defined BTPY ( + echo. + echo ERROR: no Python interpreter found. + echo. + echo Set BT_PYTHON to a python.exe and run this again, e.g.: + echo set "BT_PYTHON=C:\Users\epilectrik\.pyenv\pyenv-win\versions\3.11.4\python.exe" + echo. + pause + exit /b 1 +) + +echo Using interpreter: %BTPY% +%BTPY% "tools\btrelay_park.py" %* echo. echo The parked relay has stopped. pause