Initial Windows agent repository
This commit is contained in:
commit
a0db0c2e5b
10589 changed files with 3844063 additions and 0 deletions
BIN
OGP64/OGP/Install/Cygwin-Terminal.ico
Normal file
BIN
OGP64/OGP/Install/Cygwin-Terminal.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
4
OGP64/OGP/Install/Cygwin.bat
Normal file
4
OGP64/OGP/Install/Cygwin.bat
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
@echo off
|
||||
setlocal enableextensions
|
||||
set TERM=
|
||||
cd /d "%~dp0bin" && .\bash --login -i
|
||||
BIN
OGP64/OGP/Install/Cygwin.ico
Normal file
BIN
OGP64/OGP/Install/Cygwin.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
138
OGP64/OGP/Install/agent_start.bat
Normal file
138
OGP64/OGP/Install/agent_start.bat
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
@echo off
|
||||
setlocal EnableExtensions
|
||||
title GSP Windows Agent
|
||||
|
||||
whoami /groups | find "S-1-16-12288" >nul 2>&1
|
||||
if not "%errorLevel%" == "0" (
|
||||
echo Failure: current permissions are inadequate.
|
||||
echo.
|
||||
echo Run this script with "Run as administrator".
|
||||
call :pause_on_error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "WD=%~dp0"
|
||||
pushd "%WD%" >nul 2>&1
|
||||
set "START_LOG_NATIVE="
|
||||
|
||||
set "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 %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
|
||||
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
|
||||
)
|
||||
|
||||
set "START_LOG_NATIVE=%CYGWIN_ROOT%var\log\gsp_agent_start.log"
|
||||
if not exist "%CYGWIN_ROOT%var\log" mkdir "%CYGWIN_ROOT%var\log" >nul 2>&1
|
||||
|
||||
set "PATH=%CYGWIN_ROOT%bin;%CYGWIN_ROOT%usr\sbin;%PATH%"
|
||||
set "CYGWIN=server ntsec"
|
||||
set "SHELL=/bin/bash"
|
||||
set "GSP_AGENT_START_LOG_NATIVE=%START_LOG_NATIVE%"
|
||||
set "GSP_AGENT_CYGWIN_ROOT=%CYGWIN_ROOT%"
|
||||
|
||||
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
|
||||
call :pause_on_error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Detected startup paths:
|
||||
echo Script directory: %WD%
|
||||
echo Cygwin root: %CYGWIN_ROOT%
|
||||
echo bash.exe: %BASH_EXE%
|
||||
echo OGP path: %CYGWIN_ROOT%OGP
|
||||
echo ogp_agent.pl: %CYGWIN_ROOT%OGP\ogp_agent.pl
|
||||
echo Config path: %CYGWIN_ROOT%OGP\Cfg
|
||||
echo Startup log: %START_LOG_NATIVE%
|
||||
echo.
|
||||
if exist "%START_LOG_NATIVE%" (
|
||||
del /q "%START_LOG_NATIVE%" >nul 2>&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.
|
||||
echo ===== Last 100 lines of startup log: %START_LOG_NATIVE% =====
|
||||
if exist "%START_LOG_NATIVE%" (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "Get-Content -LiteralPath '%START_LOG_NATIVE%' -Tail 100" 2>nul
|
||||
) else (
|
||||
echo Startup log was not created.
|
||||
)
|
||||
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
|
||||
244
OGP64/OGP/Install/agent_start_cygwin.sh
Normal file
244
OGP64/OGP/Install/agent_start_cygwin.sh
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -u
|
||||
|
||||
AGENT_DIR="/OGP"
|
||||
PIDFILE="${1:-/OGP/ogp_agent_run.pid}"
|
||||
PREFS_FILE="$AGENT_DIR/Cfg/bash_prefs.cfg"
|
||||
START_LOG_NATIVE="${GSP_AGENT_START_LOG_NATIVE:-}"
|
||||
REPO_URL_DEFAULT="http://forge.runlevelsystems.com/dev/GSP.git"
|
||||
REPO_BRANCH_DEFAULT="Panel-unstable"
|
||||
RAW_AGENT_URL_DEFAULT="http://forge.runlevelsystems.com/dev/GSP/raw/branch/Panel-unstable/Agent-Windows/OGP64/OGP/ogp_agent.pl"
|
||||
REPO_AGENT_PATH="Agent-Windows/OGP64/OGP/ogp_agent.pl"
|
||||
|
||||
warn() {
|
||||
printf 'WARNING: %s\n' "$*" >&2
|
||||
}
|
||||
|
||||
fail() {
|
||||
printf 'ERROR: %s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
setup_startup_log() {
|
||||
local default_log="/var/log/gsp_agent_start.log"
|
||||
local log_path="${default_log}"
|
||||
|
||||
if [ -n "$START_LOG_NATIVE" ] && command -v cygpath >/dev/null 2>&1; then
|
||||
log_path="$(cygpath -u "$START_LOG_NATIVE" 2>/dev/null || printf '%s' "$default_log")"
|
||||
elif [ -n "$START_LOG_NATIVE" ]; then
|
||||
log_path="$START_LOG_NATIVE"
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "$log_path")" 2>/dev/null || true
|
||||
touch "$log_path" 2>/dev/null || true
|
||||
exec > >(tee -a "$log_path") 2>&1
|
||||
printf 'GSP Windows Agent startup log: %s\n' "$log_path"
|
||||
printf 'Cygwin root detected by batch: %s\n' "${GSP_AGENT_CYGWIN_ROOT:-unknown}"
|
||||
}
|
||||
|
||||
normalize_text_files() {
|
||||
local root="$1"
|
||||
[ -d "$root" ] || return 0
|
||||
find "$root" -type f \( -name '*.pl' -o -name '*.pm' -o -name '*.sh' -o -name '*.cfg' \) -print0 2>/dev/null |
|
||||
while IFS= read -r -d '' file; do
|
||||
sed -i 's/\r$//' "$file" 2>/dev/null || warn "Could not normalize line endings for $file"
|
||||
done
|
||||
}
|
||||
|
||||
normalize_bash_preferences() {
|
||||
[ -f "$PREFS_FILE" ] || return 0
|
||||
sed -i 's/\r$//' "$PREFS_FILE" 2>/dev/null || warn "Could not normalize CRLF in $PREFS_FILE"
|
||||
sed -i -E 's/^[[:space:]]+([A-Za-z_][A-Za-z0-9_]*=)/\1/' "$PREFS_FILE" 2>/dev/null || warn "Could not normalize assignments in $PREFS_FILE"
|
||||
}
|
||||
|
||||
install_default_config_if_missing() {
|
||||
local target="$1"
|
||||
local template="$2"
|
||||
if [ -f "$target" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ ! -f "$template" ]; then
|
||||
warn "Missing template $template; cannot create $target"
|
||||
return 0
|
||||
fi
|
||||
mkdir -p "$(dirname "$target")" 2>/dev/null || {
|
||||
warn "Cannot create config directory for $target"
|
||||
return 0
|
||||
}
|
||||
cp "$template" "$target" 2>/dev/null || {
|
||||
warn "Cannot create default config $target from $template"
|
||||
return 0
|
||||
}
|
||||
sed -i 's/\r$//' "$target" 2>/dev/null || true
|
||||
}
|
||||
|
||||
ensure_default_configs() {
|
||||
install_default_config_if_missing "$AGENT_DIR/Cfg/Config.pm" "$AGENT_DIR/Cfg/Config.pm.default"
|
||||
install_default_config_if_missing "$AGENT_DIR/Cfg/Preferences.pm" "$AGENT_DIR/Cfg/Preferences.pm.default"
|
||||
install_default_config_if_missing "$AGENT_DIR/Cfg/bash_prefs.cfg" "$AGENT_DIR/Cfg/bash_prefs.cfg.default"
|
||||
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"
|
||||
agent_update_branch="$REPO_BRANCH_DEFAULT"
|
||||
agent_update_raw_url="$RAW_AGENT_URL_DEFAULT"
|
||||
|
||||
if [ -f "$PREFS_FILE" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$PREFS_FILE"
|
||||
fi
|
||||
|
||||
agent_auto_update="${agent_auto_update:-0}"
|
||||
agent_update_repo_url="${agent_update_repo_url:-$REPO_URL_DEFAULT}"
|
||||
agent_update_branch="${agent_update_branch:-$REPO_BRANCH_DEFAULT}"
|
||||
agent_update_raw_url="${agent_update_raw_url:-$RAW_AGENT_URL_DEFAULT}"
|
||||
}
|
||||
|
||||
validate_agent_file() {
|
||||
local candidate="$1"
|
||||
[ -s "$candidate" ] || {
|
||||
warn "Candidate agent file is empty: $candidate"
|
||||
return 1
|
||||
}
|
||||
if head -5 "$candidate" | grep -Eiq '(<html|<!doctype|not found|404|forbidden|error)'; then
|
||||
warn "Candidate agent file looks like an HTTP error page or text response: $candidate"
|
||||
return 1
|
||||
fi
|
||||
if ! head -1 "$candidate" | grep -Eq '^#!.*perl'; then
|
||||
warn "Candidate agent file does not start with a Perl shebang: $candidate"
|
||||
return 1
|
||||
fi
|
||||
if ! grep -q 'use Cfg::Config' "$candidate"; then
|
||||
warn "Candidate agent file does not look like the GSP/OGP Perl agent: $candidate"
|
||||
return 1
|
||||
fi
|
||||
sed -i 's/\r$//' "$candidate" 2>/dev/null || true
|
||||
perl -c "$candidate" >/tmp/gsp-agent-perl-check.log 2>&1 || {
|
||||
warn "Candidate agent failed perl validation:"
|
||||
cat /tmp/gsp-agent-perl-check.log >&2 2>/dev/null || true
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
download_agent_with_curl() {
|
||||
local target="$1"
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
return 1
|
||||
fi
|
||||
echo "Downloading Windows agent from $agent_update_raw_url..."
|
||||
curl -fsSL "$agent_update_raw_url" -o "$target"
|
||||
}
|
||||
|
||||
download_agent_with_git() {
|
||||
local target="$1"
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local repo_dir source_file
|
||||
repo_dir="$(dirname "$target")/repo"
|
||||
echo "Checking for Windows agent update from $agent_update_repo_url ($agent_update_branch)..."
|
||||
if ! git clone --depth 1 --branch "$agent_update_branch" "$agent_update_repo_url" "$repo_dir"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
source_file="$repo_dir/$REPO_AGENT_PATH"
|
||||
if [ ! -f "$source_file" ]; then
|
||||
warn "Updated Windows agent source was not found at $REPO_AGENT_PATH"
|
||||
return 1
|
||||
fi
|
||||
cp "$source_file" "$target"
|
||||
}
|
||||
|
||||
auto_update_windows_agent() {
|
||||
[ "$agent_auto_update" = "1" ] || {
|
||||
echo "Agent auto-update is disabled."
|
||||
return 0
|
||||
}
|
||||
|
||||
local tmp_dir candidate_file target_file backup_file
|
||||
tmp_dir="$(mktemp -d /tmp/gsp-agent-update.XXXXXX 2>/dev/null)" || {
|
||||
warn "Could not create temporary update directory; skipping auto-update."
|
||||
return 0
|
||||
}
|
||||
candidate_file="$tmp_dir/ogp_agent.pl"
|
||||
target_file="$AGENT_DIR/ogp_agent.pl"
|
||||
backup_file="$AGENT_DIR/ogp_agent.pl.bak.$(date +%Y%m%d%H%M%S)"
|
||||
|
||||
if ! download_agent_with_curl "$candidate_file"; then
|
||||
warn "curl download failed or curl is unavailable; trying git fallback."
|
||||
if ! download_agent_with_git "$candidate_file"; then
|
||||
warn "Agent auto-update download failed; using the current agent."
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! validate_agent_file "$candidate_file"; then
|
||||
warn "Downloaded Windows agent was rejected; using the current agent."
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
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."
|
||||
[ -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."
|
||||
[ -n "$backup_file" ] && cp "$backup_file" "$target_file" 2>/dev/null
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Windows agent auto-update completed."
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
}
|
||||
|
||||
cd "$AGENT_DIR" || fail "Could not enter $AGENT_DIR. Is the Windows agent installed under Cygwin /OGP?"
|
||||
|
||||
setup_startup_log
|
||||
normalize_text_files "$AGENT_DIR"
|
||||
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."
|
||||
|
||||
echo "Launching GSP Windows Agent..."
|
||||
exec perl "$AGENT_DIR/ogp_agent.pl" -pidfile "$PIDFILE"
|
||||
21
OGP64/OGP/Install/agent_stop.bat
Normal file
21
OGP64/OGP/Install/agent_stop.bat
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
@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 NOT [%PID1%] == [] kill -15 %PID1%
|
||||
IF NOT [%PID2%] == [] kill -15 %PID2%
|
||||
IF NOT [%PID3%] == [] kill -15 %PID3%
|
||||
BIN
OGP64/OGP/Install/grant.exe
Normal file
BIN
OGP64/OGP/Install/grant.exe
Normal file
Binary file not shown.
5
OGP64/OGP/Install/install_apache.sh
Normal file
5
OGP64/OGP/Install/install_apache.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Installs Apache for Windows on Cygwin
|
||||
/etc/rc.d/init.d/httpd install
|
||||
cygrunsrv -S httpd
|
||||
/etc/rc.d/init.d/httpd reload
|
||||
107
OGP64/OGP/Install/onceinstall_agent.bat
Normal file
107
OGP64/OGP/Install/onceinstall_agent.bat
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
@echo off
|
||||
net session >nul 2>&1
|
||||
IF %ERRORLEVEL% neq 0 (
|
||||
echo Failure: Current permissions inadequate.
|
||||
echo[
|
||||
echo Run this script by using "Run as administrator" in the context menu.
|
||||
pause >nul
|
||||
exit
|
||||
)
|
||||
REM Remove the trailing \ in the path or else Cygwin will flip when it's enclosed in double quotes (http://stackoverflow.com/questions/3160058/how-to-get-the-path-of-a-batch-script-without-the-trailing-backslash-in-a-single && https://cygwin.com/ml/cygwin/2016-11/msg00178.html)
|
||||
set WD=%~dp0
|
||||
pushd %WD%
|
||||
set WD=%WD:~0,-1%
|
||||
REM Set the needed enviroment variables to run Cygwin executables without writing the full path
|
||||
set CYGWIN=server ntsec
|
||||
REM PATH CANNOT BE DOUBLE QUOTED (http://serverfault.com/questions/349179/path-variable-and-quotation-marks-windows)
|
||||
set path=%WD%\bin;%WD%\usr\sbin;%path%
|
||||
set SHELL=/bin/bash
|
||||
REM Advice
|
||||
echo DO NOT CLOSE THIS WINDOW YET.
|
||||
echo The setup process will continue once cygwin installation ends.
|
||||
REM Download latest Cygwin
|
||||
tools\wget.exe -N "https://cygwin.com/setup-x86_64.exe" -O "setup-x86_64.exe" --no-check-certificate
|
||||
REM start the setup for cygwin with the requiered repositories, paths and packages
|
||||
REM OLD WAY:
|
||||
REM setup-x86_64.exe --local-install --quiet-mode --root %WD% --local-package-dir %WD%cygTemp --packages "screen,perl,perl-HTTP-Daemon,perl-Path-Class,perl-XML-Parser,perl-Archive-Zip,perl-XML-Simple,wget,unzip,rsync,curl,bzip2,zip,cygrunsrv,dos2unix,mutt,ssmtp,nano,git,subversion" > Cygwin64_Agent_Setup.log
|
||||
IF EXIST "setup-x86_64.exe" setup-x86_64.exe --site "http://cygwin.mirror.constant.com/" --quiet-mode --root "%WD%" --local-package-dir "%WD%\cygTemp" --packages "screen,perl,perl-HTTP-Daemon,perl_vendor,perl-Path-Class,perl-XML-Parser,perl-Archive-Zip,perl-XML-Simple,wget,unzip,gawk,rsync,curl,bzip2,zip,cygrunsrv,dos2unix,mutt,ssmtp,nano,git,subversion,perl-Archive-Extract" > Cygwin64_Agent_Setup.log
|
||||
IF NOT EXIST "setup-x86_64.exe" setup-x86_64_local.exe --site "http://cygwin.mirror.constant.com/" --quiet-mode --root "%WD%" --local-package-dir "%WD%\cygTemp" --packages "screen,perl,perl-HTTP-Daemon,perl_vendor,perl-Path-Class,perl-XML-Parser,perl-Archive-Zip,perl-XML-Simple,wget,unzip,gawk,rsync,curl,bzip2,zip,cygrunsrv,dos2unix,mutt,ssmtp,nano,git,subversion,perl-Archive-Extract" > Cygwin64_Agent_Setup.log
|
||||
IF EXIST "setup-x86_64.exe" DEL setup-x86_64_local.exe
|
||||
cls
|
||||
REM Creating administrator account
|
||||
:gameserver_exists
|
||||
cls
|
||||
NET USER | FINDSTR gameserver >nul
|
||||
IF %ERRORLEVEL% neq 0 (
|
||||
echo In order to run the agent on boot,
|
||||
echo we need an administrator account named 'gameserver'.
|
||||
echo Please, create a new administrator account named 'gameserver'
|
||||
echo from the control panel of Windows and press any key to continue.
|
||||
pause >nul
|
||||
goto :gameserver_exists
|
||||
)
|
||||
cls
|
||||
color C
|
||||
echo Please, make sure the user 'gameserver' is an administrator account
|
||||
echo and press any key to continue.
|
||||
pause >nul
|
||||
cls
|
||||
color 7
|
||||
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
|
||||
set alpha=MNOPQRSTUVW
|
||||
set DRIVE=M
|
||||
:set_free_drive
|
||||
IF EXIST %DRIVE%: (
|
||||
call set beta=%%alpha:*%DRIVE%=%%
|
||||
set DRIVE=%beta:~,1%
|
||||
goto :set_free_drive
|
||||
)
|
||||
:gameserver_pass_ok
|
||||
set /p PASS=Please, enter the password for user 'gameserver':
|
||||
IF %VER% LSS 6 (
|
||||
grant del SeDenyNetworkLogonRight %USERDOMAIN%\gameserver
|
||||
net use %DRIVE%: \\%USERDOMAIN%\c$ %PASS% /user:gameserver >nul
|
||||
) ELSE (
|
||||
schtasks /Create /RU "gameserver" /SC ONSTART /TN "testtask" /TR "calc.exe" /F /RL highest /RP %PASS% >nul
|
||||
)
|
||||
IF %ERRORLEVEL% NEQ 0 (
|
||||
goto :gameserver_pass_ok
|
||||
) ELSE (
|
||||
IF %VER% LSS 6 (
|
||||
net use %DRIVE%: /DELETE >nul
|
||||
grant add SeDenyNetworkLogonRight %USERDOMAIN%\gameserver
|
||||
) ELSE (
|
||||
schtasks /Delete /TN "testtask" /f >nul
|
||||
)
|
||||
)
|
||||
cls
|
||||
REM Old way from SVN
|
||||
REM tools\wget.exe -N "http://master.dl.sourceforge.net/project/ogpextras/Installer-Snapshot/latest_win_agent_files.zip" -O "agent_files.zip"
|
||||
tools\wget.exe -N "https://github.com/OpenGamePanel/OGP-Agent-Windows/archive/master.zip" -O "agent_files.zip" --no-check-certificate
|
||||
unzip -q agent_files_old.zip
|
||||
unzip -q -o agent_files.zip
|
||||
IF NOT EXIST "OGP-Agent-Windows-master" unzip -q agent_files_local_copy.zip
|
||||
cd "OGP-Agent-Windows-master"
|
||||
IF EXIST OGP/COPYING xcopy /Y /E * ..\
|
||||
IF EXIST OGP/COPYING cd ..
|
||||
rm -rf "OGP-Agent-Windows-master"
|
||||
rm -f agent_files.zip
|
||||
rm -f agent_files_old.zip
|
||||
rm -f agent_files_local_copy.zip
|
||||
chmod +x /OGP/agent_conf.sh
|
||||
chmod +x /bin/ogp_agent
|
||||
REM Run OGP Agent configuration script
|
||||
bash /OGP/agent_conf.sh -p %PASS%
|
||||
REM adding OGP Agent to the system startup
|
||||
tools\fart.exe "%WD%\service_settings.xml" "{COMMAND}" "%WD%\agent_start.bat"
|
||||
tools\fart.exe "%WD%\service_settings.xml" "{COMMAND_WORK_DIR}" "%WD%"
|
||||
schtasks /create /tn "OGP agent start on boot" /XML "%WD%\service_settings.xml" /ru "gameserver" /rp "%PASS%"
|
||||
REM Rebase files
|
||||
call "%WD%\rebase_post_ins.bat"
|
||||
echo.
|
||||
REM Start OGP Agent
|
||||
schtasks /Run /tn "OGP agent start on boot"
|
||||
REM Grant logon as a service for FTP / other cyg_win services... needed for FileZilla for sure in x64 installer... not sure about here, but why not put it in.
|
||||
tools\ntrights.exe +r SeServiceLogonRight -u gameserver -m \\%COMPUTERNAME%
|
||||
exit 0
|
||||
1
OGP64/OGP/Install/open_home_path.bat
Normal file
1
OGP64/OGP/Install/open_home_path.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
explorer .\home\%USERNAME%
|
||||
13
OGP64/OGP/Install/preuninstall_agent.bat
Normal file
13
OGP64/OGP/Install/preuninstall_agent.bat
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
@echo off
|
||||
set WD=%~dp0
|
||||
pushd %WD%
|
||||
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
|
||||
)
|
||||
net stop ogp_agent
|
||||
sc delete ogp_agent
|
||||
20
OGP64/OGP/Install/rebase_post_ins.bat
Normal file
20
OGP64/OGP/Install/rebase_post_ins.bat
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
@echo off
|
||||
echo.
|
||||
echo Stopping OGP Agent if exists...
|
||||
SET mypath=%~dp0
|
||||
IF EXIST "%mypath%\agent_stop.bat" call "%mypath%\agent_stop.bat"
|
||||
echo.
|
||||
echo Stopping CygWin Services...
|
||||
echo.
|
||||
net stop mysqld
|
||||
net stop cygserver
|
||||
net stop httpd
|
||||
net stop cron
|
||||
echo.
|
||||
echo Running CygWin rebaseall command to prevent errors...
|
||||
echo .
|
||||
C:
|
||||
cd "%mypath%\bin"
|
||||
ash.exe /bin/rebaseall
|
||||
echo.
|
||||
|
||||
37
OGP64/OGP/Install/service_settings.xml
Normal file
37
OGP64/OGP/Install/service_settings.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-16"?>
|
||||
<Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
||||
<RegistrationInfo>
|
||||
<Author></Author>
|
||||
<URI>\OGP agent start on boot</URI>
|
||||
</RegistrationInfo>
|
||||
<Triggers>
|
||||
<BootTrigger>
|
||||
<Enabled>true</Enabled>
|
||||
</BootTrigger>
|
||||
</Triggers>
|
||||
<Principals>
|
||||
<Principal id="Author">
|
||||
<RunLevel>HighestAvailable</RunLevel>
|
||||
</Principal>
|
||||
</Principals>
|
||||
<Settings>
|
||||
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
||||
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
||||
<IdleSettings>
|
||||
<StopOnIdleEnd>false</StopOnIdleEnd>
|
||||
<RestartOnIdle>false</RestartOnIdle>
|
||||
</IdleSettings>
|
||||
<Enabled>true</Enabled>
|
||||
<Hidden>false</Hidden>
|
||||
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
||||
<WakeToRun>false</WakeToRun>
|
||||
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
||||
<Priority>5</Priority>
|
||||
</Settings>
|
||||
<Actions Context="Author">
|
||||
<Exec>
|
||||
<Command>C:\OGP64\agent_start.bat</Command>
|
||||
<WorkingDirectory>C:\OGP64</WorkingDirectory>
|
||||
</Exec>
|
||||
</Actions>
|
||||
</Task>
|
||||
BIN
OGP64/OGP/Install/setup-x86_64.exe
Normal file
BIN
OGP64/OGP/Install/setup-x86_64.exe
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue