@echo off setlocal enabledelayedexpansion REM This script will ask the user for a branch on the NCPA GitHub REM it will then build NCPA from that branch. It will also sign the resulted EXEs REM and then move them to NCPA-Cent-9 and the sinkhole REM Author: Cody Byers REM Date: 5/22/2024 REM Version: 1.0.0 if not exist "C:\Users\vwork\Documents\ncpa" ( if "%~1"=="" ( set /p branch="Please enter the branch to build from: " ) else ( set "branch=%~1" ) if "!branch!" == "" ( echo You need to specify the branch to build from echo Usage: build-ncpa ^ echo Example: build-ncpa dev-v3.1 pause exit /b 1 ) echo Moving to the Documents folder cd /d "C:\Users\vwork\Documents\" || ( echo Failed to change directory to Documents pause exit /b 1 ) echo. echo Cloning NCPA echo ============ git clone https://github.com/NagiosEnterprises/ncpa || ( echo Failed to clone the repository pause exit /b 1 ) cd ncpa\build || ( echo Failed to change directory to ncpa\build pause exit /b 1 ) git checkout "!branch!" || ( echo Failed to checkout branch !branch! pause exit /b 1 ) echo. echo Running the build_windows script echo ================================ echo. REM Runs the script for the first time to set up the environment build_windows.bat || ( echo Failed to run build_windows.bat pause exit /b 1 ) REM Reboots the machine to finish setting up the environment shutdown /r )else ( cd /d "C:\Users\vwork\Documents\ncpa\build" || ( echo Failed to change directory to ncpa\build pause exit /b 1 ) REM Runs the script a second time to build NCPA build_windows.bat || ( echo Failed to run build_windows.bat pause exit /b 1 ) REM Copies the NCPA and renames it to latest cd C:\Users\vwork\Documents\ncpa\build copy ncpa-* .. cd .. move ncpa-* build\ncpa-latest.exe cd build :input_loop echo Have you plugged in the Sectigo usb? (y/n/e) set /p userInput= if /i "%userInput%"=="y" ( echo Confirmed drive is plugged in rem Add the commands you want to run after the user presses 'y' here ) else if /i "%userInput%"=="n" ( echo Please plug in the Sectigo drive goto input_loop ) else if /i "%userInput%"=="e" ( echo Now exiting, NOTE: The EXEs have not been signed or moved pause exit /b ) else ( echo Invalid input. Please press 'y' to continue,'n' if you haven't plugged it in yet, or 'e' to exit. goto input_loop ) for %%f in ("C:\Users\vwork\Documents\ncpa\build\ncpa-*") do ( echo Signing %%f signtool sign /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /a %%f ) echo Copying to NCPA-Cent-9 and assets scp ncpa-*.exe root@192.168.5.110:/ofiler/assets/ncpa3/dev || ( echo Failed to copy files to assets via SCP pause exit /b 1 ) echo Copying to QA File server scp ncpa-*.exe root@192.168.5.110:/web/assets/ncpa/ || ( echo Failed to copy files to QA file server via SCP pause exit /b 1 ) echo NCPA is ready to test REM Add slack integration maybe ) endlocal