openvidu-local-deployment/pro/configure_lan_private_ip_windows.bat
2024-04-24 16:29:52 +02:00

35 lines
762 B
Batchfile
Executable File

@echo off
call :getPrivateIp
if "%ip%"=="" (
echo No LAN private IP found
echo Specify the LAN private IP in the .env file
exit /b 1
)
:: Replace the LAN_PRIVATE_IP in the .env file
setlocal enabledelayedexpansion
set "tempFile=%temp%\temp_env_%random%.txt"
if exist "%tempFile%" del "%tempFile%"
(
for /f "delims=" %%i in ('findstr /n "^" ".env"') do (
set "line=%%i"
set "line=!line:*:=!"
if "!line:~0,15!"=="LAN_PRIVATE_IP=" (
echo LAN_PRIVATE_IP=%ip%
) else (
echo(!line!
)
)
) > "%tempFile%"
move /y "%tempFile%" ".env" >nul
endlocal
exit /b 0
:getPrivateIp
for /f "tokens=4" %%i in ('route print ^| findstr "\<0.0.0.0\>"') do (
set ip=%%i
goto :eof
)
goto :eof