agent start fix
This commit is contained in:
parent
6a15b114e6
commit
f2dbfe5e4e
10 changed files with 110 additions and 62 deletions
|
|
@ -1,13 +0,0 @@
|
|||
%Cfg::Config = (
|
||||
logfile => '/OGP/ogp_agent.log',
|
||||
listen_port => '12679',
|
||||
listen_ip => '0.0.0.0',
|
||||
version => 'v1.4',
|
||||
key => 'CHANGE_ME_PANEL_AGENT_KEY',
|
||||
steam_license => 'Accept',
|
||||
sudo_password => '',
|
||||
web_admin_api_key => '',
|
||||
web_api_url => '',
|
||||
steam_dl_limit => '0',
|
||||
);
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
%Cfg::Preferences = (
|
||||
screen_log_local => '1',
|
||||
delete_logs_after => '30',
|
||||
ogp_manages_ftp => '1',
|
||||
ftp_method => 'PureFTPd',
|
||||
ogp_autorestart_server => '1',
|
||||
protocol_shutdown_waittime => '10',
|
||||
);
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
agent_auto_update=0
|
||||
agent_update_repo_url=http://forge.runlevelsystems.com/dev/GSP.git
|
||||
agent_update_branch=Panel-unstable
|
||||
agent_update_raw_url=http://forge.runlevelsystems.com/dev/GSP/raw/branch/Panel-unstable/Agent-Windows/OGP64/OGP/ogp_agent.pl
|
||||
run_pureftpd=0
|
||||
ftp_port=21
|
||||
ftp_ip=0.0.0.0
|
||||
ftp_pasv_range=
|
||||
|
||||
|
|
@ -7,33 +7,63 @@ if not "%errorLevel%" == "0" (
|
|||
echo Failure: current permissions are inadequate.
|
||||
echo.
|
||||
echo Run this script with "Run as administrator".
|
||||
pause
|
||||
call :pause_on_error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "WD=%~dp0"
|
||||
pushd "%WD%" >nul 2>&1
|
||||
|
||||
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\"
|
||||
)
|
||||
)
|
||||
|
||||
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"
|
||||
set "CYGWIN_ROOT="
|
||||
|
||||
if exist "%WD%bin\bash.exe" (
|
||||
set "BASH_EXE=%WD%bin\bash.exe"
|
||||
set "CYGWIN_ROOT=%WD%"
|
||||
)
|
||||
if not defined BASH_EXE if exist "%WD%..\bin\bash.exe" (
|
||||
set "BASH_EXE=%WD%..\bin\bash.exe"
|
||||
for %%I in ("%WD%..") do set "CYGWIN_ROOT=%%~fI\"
|
||||
)
|
||||
if not defined BASH_EXE if exist "%WD%..\..\bin\bash.exe" (
|
||||
set "BASH_EXE=%WD%..\..\bin\bash.exe"
|
||||
for %%I in ("%WD%..\..") do set "CYGWIN_ROOT=%%~fI\"
|
||||
)
|
||||
if not defined BASH_EXE if exist "C:\OGP64\bin\bash.exe" (
|
||||
set "BASH_EXE=C:\OGP64\bin\bash.exe"
|
||||
set "CYGWIN_ROOT=C:\OGP64\"
|
||||
)
|
||||
if not defined BASH_EXE if exist "C:\cygwin64\bin\bash.exe" (
|
||||
set "BASH_EXE=C:\cygwin64\bin\bash.exe"
|
||||
set "CYGWIN_ROOT=C:\cygwin64\"
|
||||
)
|
||||
if not defined BASH_EXE if exist "C:\cygwin\bin\bash.exe" (
|
||||
set "BASH_EXE=C:\cygwin\bin\bash.exe"
|
||||
set "CYGWIN_ROOT=C:\cygwin\"
|
||||
)
|
||||
|
||||
if not defined BASH_EXE (
|
||||
echo Failure: Cygwin bash.exe was not found.
|
||||
echo.
|
||||
echo Checked:
|
||||
echo %CYGWIN_ROOT%bin\bash.exe
|
||||
echo %WD%bin\bash.exe
|
||||
echo %WD%..\bin\bash.exe
|
||||
echo %WD%..\..\bin\bash.exe
|
||||
echo C:\OGP64\bin\bash.exe
|
||||
echo C:\cygwin64\bin\bash.exe
|
||||
echo C:\cygwin\bin\bash.exe
|
||||
pause
|
||||
call :pause_on_error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%CYGWIN_ROOT%OGP\ogp_agent.pl" (
|
||||
echo Failure: OGP agent root was not found for detected Cygwin root.
|
||||
echo.
|
||||
echo Detected Cygwin root:
|
||||
echo %CYGWIN_ROOT%
|
||||
echo Expected agent file:
|
||||
echo %CYGWIN_ROOT%OGP\ogp_agent.pl
|
||||
call :pause_on_error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
|
|
@ -49,7 +79,7 @@ if not exist "%CYGWIN_ROOT%Install\agent_start_cygwin.sh" if not exist "%CYGWIN_
|
|||
echo Expected one of:
|
||||
echo %CYGWIN_ROOT%Install\agent_start_cygwin.sh
|
||||
echo %CYGWIN_ROOT%OGP\Install\agent_start_cygwin.sh
|
||||
pause
|
||||
call :pause_on_error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
|
|
@ -71,9 +101,13 @@ 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
|
||||
call :pause_on_error
|
||||
exit /b %AGENT_EXIT%
|
||||
)
|
||||
|
||||
popd >nul 2>&1
|
||||
exit /b 0
|
||||
|
||||
:pause_on_error
|
||||
if /I not "%GSP_AGENT_NO_PAUSE%"=="1" pause
|
||||
exit /b 0
|
||||
|
|
|
|||
|
|
@ -62,6 +62,15 @@ ensure_default_configs() {
|
|||
normalize_bash_preferences
|
||||
}
|
||||
|
||||
validate_required_config() {
|
||||
if [ ! -f "$AGENT_DIR/Cfg/Config.pm" ]; then
|
||||
fail "Missing $AGENT_DIR/Cfg/Config.pm. Run agent_conf.sh or copy Config.pm.default and set the Panel agent key."
|
||||
fi
|
||||
if grep -Eq "CHANGE_ME_PANEL_AGENT_KEY|key[[:space:]]*=>[[:space:]]*''" "$AGENT_DIR/Cfg/Config.pm"; then
|
||||
fail "$AGENT_DIR/Cfg/Config.pm still contains placeholder values. Set key/listen settings to match the Panel remote server record."
|
||||
fi
|
||||
}
|
||||
|
||||
load_agent_preferences() {
|
||||
agent_auto_update=0
|
||||
agent_update_repo_url="$REPO_URL_DEFAULT"
|
||||
|
|
@ -166,26 +175,31 @@ auto_update_windows_agent() {
|
|||
return 0
|
||||
fi
|
||||
|
||||
if ! validate_agent_file "$target_file"; then
|
||||
if [ -f "$target_file" ] && ! validate_agent_file "$target_file"; then
|
||||
warn "Current Windows agent does not validate. Auto-update can still replace it if backup succeeds."
|
||||
fi
|
||||
|
||||
cp "$target_file" "$backup_file" 2>/dev/null || {
|
||||
warn "Could not backup $target_file; skipping auto-update."
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
}
|
||||
if [ -f "$target_file" ]; then
|
||||
cp "$target_file" "$backup_file" 2>/dev/null || {
|
||||
warn "Could not backup $target_file; skipping auto-update."
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
}
|
||||
else
|
||||
warn "$target_file is missing; installing validated agent without a local backup."
|
||||
backup_file=""
|
||||
fi
|
||||
|
||||
if ! cp "$candidate_file" "$target_file"; then
|
||||
warn "Could not copy updated Windows agent; restoring backup."
|
||||
cp "$backup_file" "$target_file" 2>/dev/null
|
||||
[ -n "$backup_file" ] && cp "$backup_file" "$target_file" 2>/dev/null
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! validate_agent_file "$target_file"; then
|
||||
warn "Updated Windows agent failed validation after install; restoring backup."
|
||||
cp "$backup_file" "$target_file" 2>/dev/null
|
||||
[ -n "$backup_file" ] && cp "$backup_file" "$target_file" 2>/dev/null
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
fi
|
||||
|
|
@ -202,6 +216,7 @@ normalize_text_files "/Install"
|
|||
ensure_default_configs
|
||||
load_agent_preferences
|
||||
auto_update_windows_agent
|
||||
validate_required_config
|
||||
|
||||
echo "Validating $AGENT_DIR/ogp_agent.pl..."
|
||||
validate_agent_file "$AGENT_DIR/ogp_agent.pl" || fail "Perl syntax/dependency validation failed. Install missing Cygwin Perl packages or restore a valid Windows agent file."
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ Cygwin-based agent that lets the GameServer Panel manage Windows Server 2019/202
|
|||
|
||||
## Startup and auto-update
|
||||
|
||||
Use `C:\\OGP64\\agent_start.bat` or `C:\\OGP\\Install\\agent_start.bat` to start the agent manually. The launcher detects the bundled Cygwin `bash.exe` first, then falls back to `C:\\cygwin64\\bin\\bash.exe` and `C:\\cygwin\\bin\\bash.exe`.
|
||||
Use `C:\\OGP64\\agent_start.bat` or `C:\\OGP64\\OGP\\Install\\agent_start.bat` to start the agent manually. The launcher checks the bundled Cygwin root, including `C:\\OGP64\\bin\\bash.exe`, then falls back to `C:\\cygwin64\\bin\\bash.exe` and `C:\\cygwin\\bin\\bash.exe`. Manual failures pause by default; set `GSP_AGENT_NO_PAUSE=1` for service wrappers that should not block.
|
||||
|
||||
`C:\\OGP\\Cfg\\bash_prefs.cfg` controls optional restart-time agent updates:
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ agent_update_branch=Panel-unstable
|
|||
agent_update_raw_url=http://forge.runlevelsystems.com/dev/GSP/raw/branch/Panel-unstable/Agent-Windows/OGP64/OGP/ogp_agent.pl
|
||||
```
|
||||
|
||||
When `agent_auto_update=1`, the launcher downloads to a temporary file, rejects HTML/404/empty/non-Perl content, validates with `perl -c`, backs up the current `ogp_agent.pl`, and rolls back if validation fails.
|
||||
When `agent_auto_update=1`, the launcher downloads to a temporary file, rejects HTML/404/empty/non-Perl content, validates with `perl -c`, backs up the current `ogp_agent.pl`, and rolls back if validation fails. This restart-time updater may replace only `/OGP/ogp_agent.pl`; it must not touch `Cfg/` files or other installer-generated state.
|
||||
|
||||
## Related repositories
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ Restart-time auto-update:
|
|||
agent_update_branch=Panel-unstable
|
||||
agent_update_raw_url=http://forge.runlevelsystems.com/dev/GSP/raw/branch/Panel-unstable/Agent-Windows/OGP64/OGP/ogp_agent.pl
|
||||
```
|
||||
4. Restart the agent with `C:\\OGP64\\agent_start.bat` or `C:\\OGP\\Install\\agent_start.bat`.
|
||||
4. Restart the agent with `C:\\OGP64\\agent_start.bat` or `C:\\OGP64\\OGP\\Install\\agent_start.bat`.
|
||||
|
||||
The updater downloads to a temporary file, rejects empty files, HTML error pages, `Not found` responses, and files without the expected Perl agent markers, then runs `perl -c` before replacing `/OGP/ogp_agent.pl`. Failed auto-update attempts are non-fatal and continue with the last known good agent.
|
||||
The updater downloads to a temporary file, rejects empty files, HTML error pages, `Not found` responses, and files without the expected Perl agent markers, then runs `perl -c` before replacing `/OGP/ogp_agent.pl`. Failed auto-update attempts are non-fatal and continue with the last known good agent. The restart-time updater is allowlisted to `/OGP/ogp_agent.pl` only and must not overwrite `/OGP/Cfg/*`, service settings, passwords, server data, or logs.
|
||||
|
||||
## Logging & troubleshooting
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,13 @@ if not exist "%INNER_START%" (
|
|||
echo %INNER_START%
|
||||
echo.
|
||||
echo This checkout should contain OGP\Install\agent_start.bat.
|
||||
pause
|
||||
call :pause_on_error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
call "%INNER_START%"
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
:pause_on_error
|
||||
if /I not "%GSP_AGENT_NO_PAUSE%"=="1" pause
|
||||
exit /b 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue