@echo off
:: LLIT NetBird bootstrap - MeshCentral-terminal install (no file upload needed).
:: Downloads the installer + enrollment script, prompts for the setup key,
:: writes it beside the kit files, runs nb-rollout.ps1 (installs + enrolls).
:: Terminal is already admin (agent service account) - no UAC involved.
set BASE=https://public.lafayettelocal.it
set DIR=C:\LLIT\Scripts
mkdir %DIR% 2>nul
echo === LLIT NetBird bootstrap ===
echo Downloading installer + enrollment script...
powershell -NoProfile -Command "$c=New-Object Net.WebClient; $c.DownloadFile('%BASE%/netbird_installer_0.80.0_windows_amd64.msi','%DIR%\netbird_installer_0.80.0_windows_amd64.msi'); $c.DownloadFile('%BASE%/nb-rollout.ps1','%DIR%\nb-rollout.ps1')"
if not exist %DIR%\netbird_installer_0.80.0_windows_amd64.msi goto FAIL
if not exist %DIR%\nb-rollout.ps1 goto FAIL
if "%~1"=="" (
  set /p NBKEY=Paste the setup key (from Tasks/netbird-terminal-install.MD): 
) else (
  set NBKEY=%~1
)
(echo %NBKEY%)>"%DIR%\nb-setupkey.txt"
echo Enrolling...
powershell -NoProfile -ExecutionPolicy Bypass -File %DIR%\nb-rollout.ps1 -KeyFile %DIR%\nb-setupkey.txt
echo === Bootstrap done. Leave the window open and tell LLIT. ===
exit /b 0
:FAIL
echo DOWNLOAD FAILED - no internet path to files.lafayettelocal.it
exit /b 1
