last fix
This commit is contained in:
parent
44f37dfaff
commit
8f5ad2984a
5 changed files with 106 additions and 73 deletions
|
|
@ -91,7 +91,7 @@ use constant FD_PID_FILE => Path::Class::File->new(FD_DIR, 'fd.pid');
|
|||
use constant SCHED_PID => Path::Class::File->new(AGENT_RUN_DIR, 'scheduler.pid');
|
||||
use constant SCHED_TASKS => Path::Class::File->new(AGENT_RUN_DIR, 'scheduler.tasks');
|
||||
use constant SCHED_LOG_FILE => Path::Class::File->new(AGENT_RUN_DIR, 'scheduler.log');
|
||||
use constant USER_RUNNING_SCRIPT => getlogin || getpwuid($<) || "cyg_server";
|
||||
use constant USER_RUNNING_SCRIPT => getlogin || getpwuid($<) || "gameserver";
|
||||
|
||||
my $no_startups = 0;
|
||||
my $clear_startups = 0;
|
||||
|
|
|
|||
|
|
@ -1,24 +1,68 @@
|
|||
@echo off
|
||||
setlocal EnableExtensions
|
||||
title GSP Windows Agent
|
||||
setlocal
|
||||
|
||||
set "ROOT=%~dp0"
|
||||
set "INNER_START=%ROOT%OGP\Install\agent_start.bat"
|
||||
REM GSP / OGP Windows Agent start script
|
||||
REM Cygwin root is the folder containing this BAT file, usually C:\OGP64
|
||||
|
||||
if not exist "%INNER_START%" (
|
||||
echo Failure: maintained agent launcher was not found.
|
||||
echo.
|
||||
echo Expected:
|
||||
echo %INNER_START%
|
||||
echo.
|
||||
echo This checkout should contain OGP\Install\agent_start.bat.
|
||||
call :pause_on_error
|
||||
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 "AGENT_USER=gameserver"
|
||||
|
||||
echo Starting GSP Windows Agent...
|
||||
echo Cygwin root: %WD%
|
||||
echo Agent user: %AGENT_USER%
|
||||
|
||||
if not exist "%WD%bin\bash.exe" (
|
||||
echo ERROR: bash.exe not found at "%WD%bin\bash.exe"
|
||||
echo This script must be run from the Cygwin root folder, for example C:\OGP64
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
call "%INNER_START%"
|
||||
exit /b %ERRORLEVEL%
|
||||
if not exist "%WD%OGP\ogp_agent.pl" (
|
||||
echo ERROR: "%WD%OGP\ogp_agent.pl" not found.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:pause_on_error
|
||||
if /I not "%GSP_AGENT_NO_PAUSE%"=="1" pause
|
||||
exit /b 0
|
||||
REM Verify gameserver user exists
|
||||
net user %AGENT_USER%
|
||||
if errorlevel 1 (
|
||||
echo ERROR: Windows user "%AGENT_USER%" was not found.
|
||||
echo Create the gameserver user or update AGENT_USER in this script.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Normalize line endings for known text files only
|
||||
"%WD%bin\bash.exe" -lc "cd /OGP && find . -type f \( -name '*.pl' -o -name '*.pm' -o -name '*.sh' -o -name '*.cfg' \) -exec sed -i 's/\r$//' {} \;"
|
||||
|
||||
REM Validate Perl before starting
|
||||
"%WD%bin\bash.exe" -lc "cd /OGP && perl -c ./ogp_agent.pl"
|
||||
if errorlevel 1 (
|
||||
echo ERROR: ogp_agent.pl failed Perl validation.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Stop stale PID processes if present
|
||||
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%"=="" "%WD%bin\kill.exe" -15 %PID1%
|
||||
if not "%PID2%"=="" "%WD%bin\kill.exe" -15 %PID2%
|
||||
if not "%PID3%"=="" "%WD%bin\kill.exe" -15 %PID3%
|
||||
|
||||
echo Launching agent...
|
||||
"%WD%bin\bash.exe" -lc "cd /OGP && ./ogp_agent.pl -pidfile /OGP/ogp_agent_run.pid"
|
||||
|
||||
echo.
|
||||
echo GSP Windows Agent exited with error code %ERRORLEVEL%.
|
||||
echo Review the messages above.
|
||||
pause
|
||||
exit /b %ERRORLEVEL%
|
||||
|
|
|
|||
|
|
@ -1,24 +1,20 @@
|
|||
@echo off
|
||||
@title Stop OGP Agent
|
||||
net session >nul 2>&1
|
||||
if NOT %errorLevel% == 0 (
|
||||
echo Failure: Current permissions inadequate.
|
||||
echo[
|
||||
echo Run this script by using "Run as administrator" in the context menu.
|
||||
pause >nul
|
||||
exit
|
||||
)
|
||||
set WD=%~dp0
|
||||
pushd %WD%
|
||||
set path=%WD%bin;%WD%usr\sbin;%path%
|
||||
set CYGWIN=server ntsec
|
||||
set SHELL=/bin/bash
|
||||
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 exist %WD%OGP\scheduler.pid set /p PID4=<%WD%OGP\scheduler.pid
|
||||
IF NOT [%PID1%] == [] kill -15 %PID1%
|
||||
IF NOT [%PID2%] == [] kill -15 %PID2%
|
||||
IF NOT [%PID3%] == [] kill -15 %PID3%
|
||||
IF NOT [%PID4%] == [] kill -15 %PID4%
|
||||
taskkill /IM perl.exe /F
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set "WD=%~dp0"
|
||||
pushd "%WD%"
|
||||
|
||||
set "PATH=%WD%bin;%WD%usr\sbin;%PATH%"
|
||||
|
||||
echo Stopping GSP Windows 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%"=="" "%WD%bin\kill.exe" -15 %PID1%
|
||||
if not "%PID2%"=="" "%WD%bin\kill.exe" -15 %PID2%
|
||||
if not "%PID3%"=="" "%WD%bin\kill.exe" -15 %PID3%
|
||||
|
||||
echo Done.
|
||||
pause
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue