@echo off
REM Ormur re-pair recovery. Regenerates a 6-digit pairing code using the SAME machine-wide state
REM the runtime agent serves from (%ProgramData%\Ormur\state) — so the re-paired node IS the one
REM tsnet-serve reconnects. Running bare `agent.exe pair` instead would write a NEW identity to the
REM per-user %LOCALAPPDATA% and the running agent would never see it. Mirrors the run_*.cmd pins.
cd /d "%~dp0"
set "DCSTATE=%ProgramData%\Ormur\state"
set "ARGUS_BETA_PAIRING_DIR=%DCSTATE%"
set "ARGUS_BETA_TSNET_DIR=%DCSTATE%\tsnet"
set "ARGUS_BETA_AGENT_KEY=%DCSTATE%\agent_ed25519"
if not exist "%DCSTATE%\tsnet" mkdir "%DCSTATE%\tsnet" 2>nul
REM dev.cmd (a dev box, gitignored) overrides the pins back to %LOCALAPPDATA%\ARGUS.
if exist "%~dp0dev.cmd" call "%~dp0dev.cmd"
"%~dp0agent.exe" pair
echo.
echo Enter the 6-digit PAIR-CODE shown above in the Ormur app on your phone (valid 10 minutes).
pause
