Add build script
This commit is contained in:
52
build_agent.cmd
Normal file
52
build_agent.cmd
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
@echo off
|
||||||
|
cd /D "%~dp0"
|
||||||
|
echo This script downloads the Beszel repository and builds the Beszel agent for Windows (64 Bit only).
|
||||||
|
echo If not yet installed, Git and Go will be installed via Winget.
|
||||||
|
echo.
|
||||||
|
|
||||||
|
where winget.exe >nul 2>&1
|
||||||
|
if %errorlevel% NEQ 0 (
|
||||||
|
echo Winget not found, install Winget or use a compatible OS: Win 10 Client OS or later
|
||||||
|
goto end
|
||||||
|
) else (
|
||||||
|
echo Winget executable found
|
||||||
|
)
|
||||||
|
|
||||||
|
where go.exe >nul 2>&1
|
||||||
|
if %errorlevel% NEQ 0 (
|
||||||
|
echo Installing Go with Winget
|
||||||
|
winget install GoLang.Go >nul 2>&1
|
||||||
|
) else (
|
||||||
|
echo Go executable found
|
||||||
|
)
|
||||||
|
|
||||||
|
where git.exe >nul 2>&1
|
||||||
|
if %errorlevel% NEQ 0 (
|
||||||
|
echo Installing Git with Winget
|
||||||
|
winget install Git.Git >nul 2>&1
|
||||||
|
) else (
|
||||||
|
echo Git executable found
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Cloning Beszel repository
|
||||||
|
git clone https://github.com/henrygd/beszel.git >nul 2>&1
|
||||||
|
if %errorlevel% NEQ 0 (
|
||||||
|
echo Cloning the Beszel repository failed.
|
||||||
|
goto end
|
||||||
|
)
|
||||||
|
|
||||||
|
cd .\beszel\beszel\cmd\agent
|
||||||
|
|
||||||
|
echo Building agent
|
||||||
|
set GOOS=windows
|
||||||
|
set GOARCH=amd64
|
||||||
|
set CGO_ENABLED=0
|
||||||
|
go build -ldflags "-w -s" . >nul 2>&1
|
||||||
|
if %errorlevel% NEQ 0 (
|
||||||
|
echo Something went wrong
|
||||||
|
) else (
|
||||||
|
echo Build successful:
|
||||||
|
dir agent.exe
|
||||||
|
)
|
||||||
|
|
||||||
|
:end
|
@@ -11,7 +11,7 @@ set AGENTEXE=%DESTINATIONDIR%\agent.exe
|
|||||||
set NSSMEXE=nssm.exe
|
set NSSMEXE=nssm.exe
|
||||||
|
|
||||||
where nssm.exe >nul 2>&1
|
where nssm.exe >nul 2>&1
|
||||||
if %errorlevel%==1 goto installnssm
|
if %errorlevel% NEQ 0 goto installnssm
|
||||||
goto proceed
|
goto proceed
|
||||||
|
|
||||||
:installnssm
|
:installnssm
|
||||||
@@ -42,21 +42,21 @@ netsh advfirewall firewall add rule name="%SERVICENAME%" dir=in action=allow pro
|
|||||||
|
|
||||||
echo Installing service %SERVICENAME%
|
echo Installing service %SERVICENAME%
|
||||||
%NSSMEXE% install %SERVICENAME% "%AGENTEXE%" >nul 2>&1
|
%NSSMEXE% install %SERVICENAME% "%AGENTEXE%" >nul 2>&1
|
||||||
if %errorlevel%==1 (
|
if %errorlevel% NEQ 0 (
|
||||||
echo Failed to install the service.
|
echo Failed to install the service.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Setting environment for %SERVICENAME%
|
echo Setting environment for %SERVICENAME%
|
||||||
%NSSMEXE% set %SERVICENAME% AppEnvironmentExtra "KEY=%BESZELKEYPREFIX% %BESZELKEY%" >nul 2>&1
|
%NSSMEXE% set %SERVICENAME% AppEnvironmentExtra "KEY=%BESZELKEYPREFIX% %BESZELKEY%" >nul 2>&1
|
||||||
if %errorlevel%==1 (
|
if %errorlevel% NEQ 0 (
|
||||||
echo Failed to set the service environment.
|
echo Failed to set the service environment.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
echo Starting %SERVICENAME%
|
echo Starting %SERVICENAME%
|
||||||
%NSSMEXE% start %SERVICENAME% >nul 2>&1
|
%NSSMEXE% start %SERVICENAME% >nul 2>&1
|
||||||
if %errorlevel%==1 (
|
if %errorlevel% NEQ 0 (
|
||||||
echo Failed to start service.
|
echo Failed to start service.
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user