Add healthcheck.sh and update managed-windrose files
This commit is contained in:
1 parent
cdd3810bd4
commit
ee7c49b533
3 files changed
+259
-139
No files matched your search
+179
-75
@@ -1,87 +1,191 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
WINEPREFIX=${WINEPREFIX:-/data/wine/wineprefix}
|
||||
WINDROSE_HOME=${WINDROSE_HOME:-/server}
|
||||
WINDROSE_R5=${WINDROSE_R5:-/server/R5}
|
||||
SAVED_DIR=${SAVED_DIR:-/data/Saved}
|
||||
APPID=${WINDROSE_APP_ID:-4129620}
|
||||
SERVERDIR=${SERVERDIR:-/data}
|
||||
STEAM_HOME=${STEAM_HOME:-/home/steam}
|
||||
WINEPREFIX=${WINEPREFIX:-$STEAM_HOME/.wine}
|
||||
STEAM_LOGIN=${STEAM_LOGIN:-anonymous}
|
||||
STEAM_PASS=${STEAM_PASS:-}
|
||||
UPDATE_ON_START=${UPDATE_ON_START:-true}
|
||||
GENERATE_SETTINGS=${GENERATE_SETTINGS:-true}
|
||||
PUID=${PUID:-1000}
|
||||
PGID=${PGID:-1000}
|
||||
|
||||
SERVER_EXE="${WINDROSE_R5}/Binaries/Win64/WindroseServer-Win64-Shipping.exe"
|
||||
PORT=${PORT:-7777}
|
||||
QUERYPORT=${QUERYPORT:-7778}
|
||||
MULTIHOME=${MULTIHOME:-0.0.0.0}
|
||||
|
||||
export WINEDEBUG=-all
|
||||
export DISPLAY=
|
||||
export XDG_RUNTIME_DIR=/tmp/runtime-wine
|
||||
mkdir -p "$XDG_RUNTIME_DIR"
|
||||
INVITE_CODE=${INVITE_CODE:-}
|
||||
SERVER_NAME=${SERVER_NAME:-}
|
||||
SERVER_NOTE=${SERVER_NOTE:-}
|
||||
SERVER_PASSWORD=${SERVER_PASSWORD:-}
|
||||
MAX_PLAYERS=${MAX_PLAYERS:-4}
|
||||
P2P_PROXY_ADDRESS=${P2P_PROXY_ADDRESS:-127.0.0.1}
|
||||
FIRST_RUN_TIMEOUT=${FIRST_RUN_TIMEOUT:-180}
|
||||
|
||||
# Intel ARC Vulkan ICDs
|
||||
export VK_ICD_FILENAMES="/usr/share/vulkan/icd.d/intel_icd.x86_64.json:/usr/share/vulkan/icd.i686.json"
|
||||
export LIBVA_DRIVER_NAME=iHD
|
||||
SERVER_DESC="$SERVERDIR/R5/ServerDescription.json"
|
||||
SERVER_PID=""
|
||||
XVFB_PID=""
|
||||
|
||||
DXVK_32="/opt/dxvk/x32"
|
||||
DXVK_64="/opt/dxvk/x64"
|
||||
log() { echo "[windrose] $*"; }
|
||||
quote() { printf '%q' "$1"; }
|
||||
run_as_steam() { su -s /bin/bash steam -c "$*"; }
|
||||
|
||||
# Initialize wineprefix if missing
|
||||
if [ ! -d "$WINEPREFIX" ] || [ ! -f "$WINEPREFIX/system.reg" ]; then
|
||||
echo "Initializing wineprefix at $WINEPREFIX"
|
||||
mkdir -p "$WINEPREFIX"
|
||||
wineboot --init || true
|
||||
ensure_user_mapping() {
|
||||
groupmod -o -g "$PGID" steam 2>/dev/null || true
|
||||
usermod -o -u "$PUID" steam 2>/dev/null || true
|
||||
mkdir -p "$SERVERDIR" "$STEAM_HOME"
|
||||
chown -R steam:steam /opt/steamcmd "$STEAM_HOME" "$SERVERDIR" 2>/dev/null || true
|
||||
}
|
||||
|
||||
echo "Installing DXVK DLLs into wineprefix..."
|
||||
WIN_SYS32="$WINEPREFIX/drive_c/windows/system32"
|
||||
WIN_SYSWOW64="$WINEPREFIX/drive_c/windows/syswow64"
|
||||
cleanup_xvfb() {
|
||||
if [ -n "$XVFB_PID" ] && kill -0 "$XVFB_PID" 2>/dev/null; then
|
||||
kill "$XVFB_PID" 2>/dev/null || true
|
||||
fi
|
||||
rm -f /tmp/.X99-lock 2>/dev/null || true
|
||||
}
|
||||
|
||||
mkdir -p "$WIN_SYS32" "$WIN_SYSWOW64"
|
||||
shutdown_server() {
|
||||
log "Stopping Windrose dedicated server"
|
||||
pkill -TERM -u steam -f 'WindroseServer-Win64-Shipping.exe' 2>/dev/null || true
|
||||
pkill -TERM -u steam -f 'wineserver' 2>/dev/null || true
|
||||
for _ in $(seq 1 60); do
|
||||
if ! pgrep -u steam -f 'WindroseServer-Win64-Shipping.exe|wineserver' >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
pkill -KILL -u steam -f 'WindroseServer-Win64-Shipping.exe|wineserver' 2>/dev/null || true
|
||||
}
|
||||
|
||||
cp "$DXVK_64"/*.dll "$WIN_SYS32"/
|
||||
cp "$DXVK_32"/*.dll "$WIN_SYSWOW64"/
|
||||
trap 'shutdown_server; exit 0' TERM INT
|
||||
trap 'cleanup_xvfb' EXIT
|
||||
|
||||
init_xvfb() {
|
||||
rm -f /tmp/.X99-lock 2>/dev/null || true
|
||||
Xvfb :99 -screen 0 1024x768x16 -nolisten tcp >/dev/null 2>&1 &
|
||||
XVFB_PID=$!
|
||||
sleep 1
|
||||
}
|
||||
|
||||
init_wine() {
|
||||
mkdir -p "$WINEPREFIX"
|
||||
chown -R steam:steam "$STEAM_HOME" 2>/dev/null || true
|
||||
if [ ! -f "$WINEPREFIX/system.reg" ]; then
|
||||
log "Initializing Wine prefix"
|
||||
run_as_steam "WINEPREFIX=$(quote "$WINEPREFIX") wineboot -i >/dev/null 2>&1 || true"
|
||||
fi
|
||||
}
|
||||
|
||||
update_server() {
|
||||
if [ "$UPDATE_ON_START" != "true" ]; then
|
||||
log "UPDATE_ON_START=false, skipping SteamCMD update"
|
||||
return
|
||||
fi
|
||||
|
||||
local login_cmd
|
||||
if [ "$STEAM_LOGIN" = "anonymous" ]; then
|
||||
login_cmd='+login anonymous'
|
||||
elif [ -n "$STEAM_PASS" ]; then
|
||||
login_cmd="+login $(quote "$STEAM_LOGIN") $(quote "$STEAM_PASS")"
|
||||
else
|
||||
login_cmd="+login $(quote "$STEAM_LOGIN")"
|
||||
fi
|
||||
|
||||
log "Updating or validating server files via SteamCMD (AppID $APPID)"
|
||||
run_as_steam "mkdir -p $(quote "$SERVERDIR") && /opt/steamcmd/steamcmd.sh +force_install_dir $(quote "$SERVERDIR") $login_cmd +app_update $(quote "$APPID") validate +quit"
|
||||
}
|
||||
|
||||
find_server_exe() {
|
||||
find "$SERVERDIR" -iname 'WindroseServer-Win64-Shipping.exe' 2>/dev/null | head -n 1 || true
|
||||
}
|
||||
|
||||
first_run_generate_config() {
|
||||
local exe="$1"
|
||||
if [ "$GENERATE_SETTINGS" != "true" ] || [ -f "$SERVER_DESC" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
log "First run detected, generating default server config"
|
||||
run_as_steam "WINEPREFIX=$(quote "$WINEPREFIX") wine $(quote "$exe") -log -MULTIHOME=$(quote "$MULTIHOME") -PORT=$(quote "$PORT") -QUERYPORT=$(quote "$QUERYPORT") >/tmp/windrose-first-run.log 2>&1" &
|
||||
local warmup_pid=$!
|
||||
|
||||
local count=0
|
||||
while [ ! -f "$SERVER_DESC" ] && [ "$count" -lt "$FIRST_RUN_TIMEOUT" ]; do
|
||||
sleep 1
|
||||
count=$((count + 1))
|
||||
done
|
||||
|
||||
kill "$warmup_pid" 2>/dev/null || true
|
||||
wait "$warmup_pid" 2>/dev/null || true
|
||||
pkill -TERM -u steam -f 'wineserver' 2>/dev/null || true
|
||||
|
||||
if [ ! -f "$SERVER_DESC" ]; then
|
||||
log "WARNING: ServerDescription.json was not generated within ${FIRST_RUN_TIMEOUT}s"
|
||||
log "Wine output:"
|
||||
tail -n 40 /tmp/windrose-first-run.log 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
patch_server_config() {
|
||||
if [ "$GENERATE_SETTINGS" != "true" ]; then
|
||||
log "GENERATE_SETTINGS=false, skipping JSON patching"
|
||||
return
|
||||
fi
|
||||
if [ ! -f "$SERVER_DESC" ]; then
|
||||
log "ServerDescription.json not found, skipping patch"
|
||||
return
|
||||
fi
|
||||
|
||||
log "Patching ServerDescription.json from environment"
|
||||
tr -d '\r' < "$SERVER_DESC" | jq \
|
||||
--arg invite "$INVITE_CODE" \
|
||||
--arg name "$SERVER_NAME" \
|
||||
--arg note "$SERVER_NOTE" \
|
||||
--arg password "$SERVER_PASSWORD" \
|
||||
--arg proxy "$P2P_PROXY_ADDRESS" \
|
||||
--argjson maxplayers "$MAX_PLAYERS" \
|
||||
'
|
||||
.ServerDescription_Persistent.P2pProxyAddress = $proxy |
|
||||
if $invite != "" then .ServerDescription_Persistent.InviteCode = $invite else . end |
|
||||
if $name != "" then .ServerDescription_Persistent.ServerName = $name else . end |
|
||||
if $note != "" then .ServerDescription_Persistent.Note = $note else . end |
|
||||
if $password != "" then
|
||||
.ServerDescription_Persistent.IsPasswordProtected = true |
|
||||
.ServerDescription_Persistent.Password = $password
|
||||
else
|
||||
.ServerDescription_Persistent.IsPasswordProtected = false |
|
||||
.ServerDescription_Persistent.Password = ""
|
||||
end |
|
||||
.ServerDescription_Persistent.MaxPlayerCount = $maxplayers
|
||||
' > "$SERVER_DESC.tmp"
|
||||
mv "$SERVER_DESC.tmp" "$SERVER_DESC"
|
||||
chown steam:steam "$SERVER_DESC" 2>/dev/null || true
|
||||
}
|
||||
|
||||
start_server() {
|
||||
local exe="$1"
|
||||
log "Starting Windrose dedicated server"
|
||||
log "Executable: $exe"
|
||||
log "Bind: $MULTIHOME Port: $PORT QueryPort: $QUERYPORT"
|
||||
run_as_steam "WINEPREFIX=$(quote "$WINEPREFIX") wine $(quote "$exe") -log -MULTIHOME=$(quote "$MULTIHOME") -PORT=$(quote "$PORT") -QUERYPORT=$(quote "$QUERYPORT")" &
|
||||
SERVER_PID=$!
|
||||
wait "$SERVER_PID"
|
||||
}
|
||||
|
||||
ensure_user_mapping
|
||||
init_xvfb
|
||||
init_wine
|
||||
update_server
|
||||
|
||||
SERVER_EXE=$(find_server_exe)
|
||||
if [ -z "$SERVER_EXE" ]; then
|
||||
log "ERROR: Windrose server executable not found under $SERVERDIR"
|
||||
find "$SERVERDIR" -maxdepth 4 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Force DXVK to be used
|
||||
export WINEDLLOVERRIDES="d3d11,dxgi,d3d10core,d3d9=native,builtin"
|
||||
|
||||
mkdir -p "$SAVED_DIR"
|
||||
|
||||
case "${1:-}" in
|
||||
run-server)
|
||||
echo "Starting Windrose dedicated server..."
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# AUTOMATIC INSTALLER: Install Windrose if missing
|
||||
# ---------------------------------------------------------
|
||||
if [ ! -f "$SERVER_EXE" ]; then
|
||||
echo "Windrose server binary missing — installing via SteamCMD..."
|
||||
mkdir -p "$WINDROSE_R5"
|
||||
|
||||
/root/steamcmd/steamcmd.sh \
|
||||
+login anonymous \
|
||||
+force_install_dir "$WINDROSE_R5" \
|
||||
+app_update 4129620 validate \
|
||||
+quit
|
||||
|
||||
echo "Windrose server installation complete."
|
||||
fi
|
||||
# ---------------------------------------------------------
|
||||
|
||||
if [ ! -f "$SERVER_EXE" ]; then
|
||||
echo "ERROR: Windrose server binary still not found after install:"
|
||||
echo " $SERVER_EXE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$(dirname "$SERVER_EXE")"
|
||||
|
||||
exec wine "$SERVER_EXE" \
|
||||
-log \
|
||||
-unattended \
|
||||
-nosteam \
|
||||
-savedir "$SAVED_DIR"
|
||||
;;
|
||||
|
||||
bash)
|
||||
exec /bin/bash
|
||||
;;
|
||||
|
||||
*)
|
||||
exec "$@"
|
||||
;;
|
||||
esac
|
||||
first_run_generate_config "$SERVER_EXE"
|
||||
patch_server_config
|
||||
start_server "$SERVER_EXE"
|
||||
Reference in new issue
Block a user