@echo off
rem PcCafe monitoring server setup.
rem Installs the required .NET runtimes when missing, then downloads and starts the monitoring server.
setlocal
set "PS=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
set "SETUP=%TEMP%\pccafe-monitor-setup.ps1"
echo PcCafe monitoring server setup
echo Downloading the setup script...
"%PS%" -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; try { Invoke-WebRequest -Uri 'https://pc.flexx.kr/downloads/monitor-agent/setup.ps1' -OutFile '%SETUP%' -UseBasicParsing -TimeoutSec 30 -ErrorAction Stop } catch { Invoke-WebRequest -Uri 'https://pc.flexx.kr/downloads/monitor-agent/setup.ps1?source=central' -OutFile '%SETUP%' -UseBasicParsing -TimeoutSec 120 -ErrorAction Stop }"
if errorlevel 1 goto fail
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%SETUP%" -BaseUrl "https://pc.flexx.kr"
if errorlevel 1 goto fail
del "%SETUP%" >nul 2>&1
exit /b 0
:fail
echo.
echo [PcCafe] Setup failed. Check the internet connection and run this file again.
echo.
pause
exit /b 1
