@echo off
REM ===================================================================
REM  Connect this machine to ZanPOS.
REM
REM  Run it once, on the machine itself, as an administrator. It does one
REM  thing that matters: it lets the shop's hub log in to this machine
REM  without a password, using a key rather than one.
REM
REM  That is not a convenience. Kawa never logs into a screen and cannot -
REM  the screens sit on the shop's own network behind somebody else's
REM  router. The hub is the only machine with a way out, so every
REM  screenshot, every status, every update and every "put the ordering
REM  app back on that screen" is the hub going in with this key. Without
REM  it the machine pairs, takes orders and prints, and then refuses all
REM  of those for ever, silently.
REM
REM  This file is the same for every shop and is worth nothing on its own.
REM  Which shop this machine belongs to, which hub key it is given and
REM  which network its firewall is opened to are all decided by the code -
REM  or the open door - made in the panel. Choose the shop there, not here.
REM
REM  If the panel says the door is open for that shop, there is nothing to
REM  type: press Enter when it asks for a code. A code and an open door
REM  both last thirty minutes and both shut behind one machine.
REM
REM  Afterwards, in the Kawa panel: New machine -> Let it in -> install the
REM  app. Then pair it in the ZanPOS panel, which is what gives it its role
REM  and its menu.
REM ===================================================================

net session >nul 2>&1
if errorlevel 1 (
  echo.
  echo   This has to run as an administrator.
  echo   Right-click the file and choose "Run as administrator".
  echo.
  pause
  exit /b 1
)

echo.
echo   Fetching the setup script...
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; $s='%~dp0connect-to-zanpos.ps1'; if (Test-Path $s) { & $s } else { iex ((New-Object Net.WebClient).DownloadString('http://kawa.mobiki.uk/connect.ps1')) }"

echo.
pause
