Agent update
This commit is contained in:
parent
c195c0930b
commit
cc5f7bb90c
16 changed files with 474 additions and 85 deletions
|
|
@ -1,41 +1,79 @@
|
|||
@echo off
|
||||
@title OGP Agent
|
||||
FOR /f "tokens=2,3,4 delims=[.]" %%a IN ('ver') DO SET WVer=%%a
|
||||
FOR /f "tokens=2,3 delims= " %%a IN ('echo %WVer%') DO SET Ver=%%a
|
||||
setlocal EnableExtensions
|
||||
title GSP Windows Agent
|
||||
|
||||
whoami /groups | find "S-1-16-12288" >nul 2>&1
|
||||
if NOT %errorLevel% == 0 if %VER% GEQ 6 (
|
||||
echo Failure: Current permissions inadequate.
|
||||
echo[
|
||||
echo Run this script by using "Run as administrator" in the context menu.
|
||||
pause >nul
|
||||
exit
|
||||
if not "%errorLevel%" == "0" (
|
||||
echo Failure: current permissions are inadequate.
|
||||
echo.
|
||||
echo Run this script with "Run as administrator".
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
set WD=%~dp0
|
||||
pushd %WD%
|
||||
set path=%WD%bin;%WD%usr\sbin;%path%
|
||||
set CYGWIN=server ntsec
|
||||
set SHELL=/bin/bash
|
||||
set runAgentNormally=no
|
||||
|
||||
REM Stop any running agent
|
||||
if exist %WD%var\run\pure-ftpd.pid set /p PID1=<%WD%var\run\pure-ftpd.pid
|
||||
if exist %WD%OGP\ogp_agent.pid set /p PID2=<%WD%OGP\ogp_agent.pid
|
||||
if exist %WD%OGP\ogp_agent_run.pid set /p PID3=<%WD%OGP\ogp_agent_run.pid
|
||||
IF NOT [%PID1%] == [] kill -15 %PID1%
|
||||
IF NOT [%PID2%] == [] kill -15 %PID2%
|
||||
IF NOT [%PID3%] == [] kill -15 %PID3%
|
||||
set "WD=%~dp0"
|
||||
pushd "%WD%" >nul 2>&1
|
||||
|
||||
REM Check for gameserver user and if it exists and the user running this script matches, run it the normal way, else prompt for elevation
|
||||
if "%username%" == "" set runAgentNormally=yes
|
||||
if "%username%" == "gameserver" set runAgentNormally=yes
|
||||
|
||||
net user gameserver
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
if %runAgentNormally% == yes (
|
||||
bash ogp_agent -pidfile /OGP/ogp_agent_run.pid
|
||||
) else (
|
||||
cygstart mintty /c "runas /profile /user:gameserver \"%WD%\bin\bash.exe %WD%\bin\ogp_agent -pidfile /OGP/ogp_agent_run.pid\""
|
||||
set "CYGWIN_ROOT=%WD%"
|
||||
if not exist "%CYGWIN_ROOT%OGP\ogp_agent.pl" (
|
||||
if exist "%WD%..\OGP\ogp_agent.pl" (
|
||||
for %%I in ("%WD%..") do set "CYGWIN_ROOT=%%~fI\"
|
||||
)
|
||||
) else (
|
||||
bash ogp_agent -pidfile /OGP/ogp_agent_run.pid
|
||||
)
|
||||
|
||||
set "BASH_EXE="
|
||||
if exist "%CYGWIN_ROOT%bin\bash.exe" set "BASH_EXE=%CYGWIN_ROOT%bin\bash.exe"
|
||||
if not defined BASH_EXE if exist "C:\cygwin64\bin\bash.exe" set "BASH_EXE=C:\cygwin64\bin\bash.exe"
|
||||
if not defined BASH_EXE if exist "C:\cygwin\bin\bash.exe" set "BASH_EXE=C:\cygwin\bin\bash.exe"
|
||||
|
||||
if not defined BASH_EXE (
|
||||
echo Failure: Cygwin bash.exe was not found.
|
||||
echo.
|
||||
echo Checked:
|
||||
echo %CYGWIN_ROOT%bin\bash.exe
|
||||
echo C:\cygwin64\bin\bash.exe
|
||||
echo C:\cygwin\bin\bash.exe
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "PATH=%CYGWIN_ROOT%bin;%CYGWIN_ROOT%usr\sbin;%PATH%"
|
||||
set "CYGWIN=server ntsec"
|
||||
set "SHELL=/bin/bash"
|
||||
|
||||
set "HELPER=/Install/agent_start_cygwin.sh"
|
||||
if exist "%CYGWIN_ROOT%OGP\Install\agent_start_cygwin.sh" set "HELPER=/OGP/Install/agent_start_cygwin.sh"
|
||||
if not exist "%CYGWIN_ROOT%Install\agent_start_cygwin.sh" if not exist "%CYGWIN_ROOT%OGP\Install\agent_start_cygwin.sh" (
|
||||
echo Failure: agent_start_cygwin.sh was not found.
|
||||
echo.
|
||||
echo Expected one of:
|
||||
echo %CYGWIN_ROOT%Install\agent_start_cygwin.sh
|
||||
echo %CYGWIN_ROOT%OGP\Install\agent_start_cygwin.sh
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
rem Stop any existing agent processes whose PID files still exist.
|
||||
if exist "%CYGWIN_ROOT%var\run\pure-ftpd.pid" set /p PID1=<"%CYGWIN_ROOT%var\run\pure-ftpd.pid"
|
||||
if exist "%CYGWIN_ROOT%OGP\ogp_agent.pid" set /p PID2=<"%CYGWIN_ROOT%OGP\ogp_agent.pid"
|
||||
if exist "%CYGWIN_ROOT%OGP\ogp_agent_run.pid" set /p PID3=<"%CYGWIN_ROOT%OGP\ogp_agent_run.pid"
|
||||
if defined PID1 kill -15 %PID1% >nul 2>&1
|
||||
if defined PID2 kill -15 %PID2% >nul 2>&1
|
||||
if defined PID3 kill -15 %PID3% >nul 2>&1
|
||||
|
||||
echo Starting GSP Windows Agent with:
|
||||
echo %BASH_EXE%
|
||||
echo.
|
||||
"%BASH_EXE%" --login "%HELPER%" /OGP/ogp_agent_run.pid
|
||||
set "AGENT_EXIT=%ERRORLEVEL%"
|
||||
|
||||
if not "%AGENT_EXIT%" == "0" (
|
||||
echo.
|
||||
echo GSP Windows Agent exited with error code %AGENT_EXIT%.
|
||||
echo Review the messages above. The window is staying open so the failure is visible.
|
||||
pause
|
||||
exit /b %AGENT_EXIT%
|
||||
)
|
||||
|
||||
popd >nul 2>&1
|
||||
exit /b 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue