openvibers/source.openvibe.games Commits

Harden local SRCDS shard startup

CO Copilot committed 3 Jul 2026 · 83c7c78497 · 9 files, +54 −17


Changes

ddiff --git a/game/openvibe.games/cfg/openvibe_common.cfg b/game/openvibe.games/cfg/openvibe_common.cfg
iindex 59e8980..f461fb9 100644
---- a/game/openvibe.games/cfg/openvibe_common.cfg
++++ b/game/openvibe.games/cfg/openvibe_common.cfg
@@@ -1,5 +1,6 @@
// Shared local development defaults for OpenVibe: Source.
sv_lan 1
++sv_master_share_game_socket 1
sv_cheats 0
sv_pure 0
developer 1
ddiff --git a/tools/run-deathrun.sh b/tools/run-deathrun.sh
iindex 3be32a0..0ce46c3 100755
---- a/tools/run-deathrun.sh
++++ b/tools/run-deathrun.sh
@@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
--exec "$(dirname "$0")/run-server.sh" deathrun 27017 dr_openvibe_dev 24 openvibe_deathrun.cfg
++exec "$(dirname "$0")/run-server.sh" deathrun "${OPENVIBE_DEATHRUN_PORT:-27017}" dr_openvibe_dev "${OPENVIBE_DEATHRUN_MAXPLAYERS:-24}" openvibe_deathrun.cfg
ddiff --git a/tools/run-fortwars.sh b/tools/run-fortwars.sh
iindex 4775f89..58f0fb3 100755
---- a/tools/run-fortwars.sh
++++ b/tools/run-fortwars.sh
@@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
--exec "$(dirname "$0")/run-server.sh" fortwars 27018 fw_openvibe_dev 32 openvibe_fortwars.cfg
++exec "$(dirname "$0")/run-server.sh" fortwars "${OPENVIBE_FORTWARS_PORT:-27018}" fw_openvibe_dev "${OPENVIBE_FORTWARS_MAXPLAYERS:-32}" openvibe_fortwars.cfg
ddiff --git a/tools/run-hub.sh b/tools/run-hub.sh
iindex 09bdf51..96216ba 100755
---- a/tools/run-hub.sh
++++ b/tools/run-hub.sh
@@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
--exec "$(dirname "$0")/run-server.sh" hub 27015 ov_hub 48 openvibe_hub.cfg
++exec "$(dirname "$0")/run-server.sh" hub "${OPENVIBE_HUB_PORT:-27015}" ov_hub "${OPENVIBE_HUB_MAXPLAYERS:-48}" openvibe_hub.cfg
ddiff --git a/tools/run-prophunt.sh b/tools/run-prophunt.sh
iindex 297bbf7..010fc55 100755
---- a/tools/run-prophunt.sh
++++ b/tools/run-prophunt.sh
@@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
--exec "$(dirname "$0")/run-server.sh" prophunt 27016 ph_openvibe_dev 24 openvibe_prophunt.cfg
++exec "$(dirname "$0")/run-server.sh" prophunt "${OPENVIBE_PROPHUNT_PORT:-27016}" ph_openvibe_dev "${OPENVIBE_PROPHUNT_MAXPLAYERS:-24}" openvibe_prophunt.cfg
ddiff --git a/tools/run-sandbox.sh b/tools/run-sandbox.sh
iindex 9b30b50..ae83d7f 100755
---- a/tools/run-sandbox.sh
++++ b/tools/run-sandbox.sh
@@@ -16,6 +16,9 @@ PORT="${OPENVIBE_SANDBOX_PORT:-27020}"
MAP="${OPENVIBE_SANDBOX_MAP:-ov_hub}"
MAXPLAYERS="${OPENVIBE_SANDBOX_MAXPLAYERS:-24}"
BIND_IP="${OPENVIBE_BIND_IP:-127.0.0.1}"
++CLIENTPORT="${OPENVIBE_CLIENTPORT:-$((PORT + 1000))}"
++TVPORT="${OPENVIBE_TV_PORT:-$((PORT + 2000))}"
++STEAMPORT="${OPENVIBE_STEAMPORT:-$((PORT - 115))}"
MAP_DELAY="${OPENVIBE_SRCDS_MAP_DELAY:-6}"
RELOAD_DELAY="${OPENVIBE_SANDBOX_RELOAD_DELAY:-8}"
@@@ -50,9 +53,18 @@ server_cmd=(
-usercon
-ip "$BIND_IP"
-port "$PORT"
-- +clientport "$((PORT + 1000))"
++ -steamport "$STEAMPORT"
++)
++
++if [[ "${OPENVIBE_SRCDS_MASTER:-0}" != "1" ]]; then
++ server_cmd+=(-nomaster)
++fi
++
++server_cmd+=(
++ +clientport "$CLIENTPORT"
+maxplayers "$MAXPLAYERS"
-- +tv_port "$((PORT + 2000))"
++ +tv_port "$TVPORT"
++ +sv_master_share_game_socket 1
+exec openvibe_sandbox.cfg
)
@@@ -71,7 +83,9 @@ console_input() {
filter_output() {
sed -u \
-e '/WARNING: Failed to load 32-bit libtinfo\.so\.5 or libncurses\.so\.5\./d' \
-- -e '/Please install (lib32tinfo5 \/ ncurses-libs\.i686 \/ equivalent) to enable readline\./d'
++ -e '/Please install (lib32tinfo5 \/ ncurses-libs\.i686 \/ equivalent) to enable readline\./d' \
++ -e '/^Socket bound to non-default port 269[0-9][0-9] because original port was already in use\./d' \
++ -e '/^WARNING: Port 26900 was unavailable - bound to port 269[0-9][0-9] instead/d'
}
if command -v script >/dev/null 2>&1; then
ddiff --git a/tools/run-server.sh b/tools/run-server.sh
iindex e96154c..f25c498 100755
---- a/tools/run-server.sh
++++ b/tools/run-server.sh
@@@ -27,6 +27,9 @@ case "$MODE" in
esac
BIND_IP="${OPENVIBE_BIND_IP:-$DEFAULT_BIND_IP}"
++CLIENTPORT="${OPENVIBE_CLIENTPORT:-$((PORT + 1000))}"
++TVPORT="${OPENVIBE_TV_PORT:-$((PORT + 2000))}"
++STEAMPORT="${OPENVIBE_STEAMPORT:-$((PORT - 115))}"
if [[ ! -x "$SRCDS/srcds_linux64" ]]; then
echo "Missing 64-bit SRCDS at $SRCDS/srcds_linux64" >&2
@@@ -63,9 +66,18 @@ server_cmd=(
-usercon
-ip "$BIND_IP"
-port "$PORT"
-- +clientport "$((PORT + 1000))"
++ -steamport "$STEAMPORT"
++)
++
++if [[ "${OPENVIBE_SRCDS_MASTER:-0}" != "1" ]]; then
++ server_cmd+=(-nomaster)
++fi
++
++server_cmd+=(
++ +clientport "$CLIENTPORT"
+maxplayers "$MAXPLAYERS"
-- +tv_port "$((PORT + 2000))"
++ +tv_port "$TVPORT"
++ +sv_master_share_game_socket 1
+exec "$CFG"
)
@@@ -79,7 +91,9 @@ if [[ "${OPENVIBE_SRCDS_PIPE_MAP:-1}" == "1" ]]; then
filter_output() {
sed -u \
-e '/WARNING: Failed to load 32-bit libtinfo\.so\.5 or libncurses\.so\.5\./d' \
-- -e '/Please install (lib32tinfo5 \/ ncurses-libs\.i686 \/ equivalent) to enable readline\./d'
++ -e '/Please install (lib32tinfo5 \/ ncurses-libs\.i686 \/ equivalent) to enable readline\./d' \
++ -e '/^Socket bound to non-default port 269[0-9][0-9] because original port was already in use\./d' \
++ -e '/^WARNING: Port 26900 was unavailable - bound to port 269[0-9][0-9] instead/d'
}
if command -v script >/dev/null 2>&1; then
ddiff --git a/tools/run-traitortown.sh b/tools/run-traitortown.sh
iindex 8986659..9c0b85e 100755
---- a/tools/run-traitortown.sh
++++ b/tools/run-traitortown.sh
@@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
--exec "$(dirname "$0")/run-server.sh" traitortown 27019 tt_openvibe_dev 24 openvibe_traitortown.cfg
++exec "$(dirname "$0")/run-server.sh" traitortown "${OPENVIBE_TRAITORTOWN_PORT:-27019}" tt_openvibe_dev "${OPENVIBE_TRAITORTOWN_MAXPLAYERS:-24}" openvibe_traitortown.cfg
ddiff --git a/tools/smoke-srcds.sh b/tools/smoke-srcds.sh
iindex 5fda7b1..7167896 100755
---- a/tools/smoke-srcds.sh
++++ b/tools/smoke-srcds.sh
@@@ -9,12 +9,18 @@ run_check() {
local name="$1"
local script="$2"
local map="$3"
++ local port_env="$4"
++ local smoke_port="$5"
local log="/tmp/openvibe-srcds-$name.log"
rm -f "$log"
set +e
-- timeout "${OPENVIBE_SRCDS_SMOKE_TIMEOUT:-70}s" "$ROOT/tools/$script" >"$log" 2>&1
++ env "$port_env=$smoke_port" \
++ OPENVIBE_CLIENTPORT="$((smoke_port + 1000))" \
++ OPENVIBE_TV_PORT="$((smoke_port + 2000))" \
++ OPENVIBE_STEAMPORT="$((smoke_port - 115))" \
++ timeout "${OPENVIBE_SRCDS_SMOKE_TIMEOUT:-70}s" "$ROOT/tools/$script" >"$log" 2>&1
local code=$?
set -e
@@@ -51,8 +57,10 @@ run_check() {
echo "[srcds:$name] ok ($map)"
}
--run_check hub run-hub.sh ov_hub
--run_check prophunt run-prophunt.sh ph_openvibe_dev
--run_check deathrun run-deathrun.sh dr_openvibe_dev
--run_check fortwars run-fortwars.sh fw_openvibe_dev
--run_check traitortown run-traitortown.sh tt_openvibe_dev
++BASE_PORT="${OPENVIBE_SRCDS_SMOKE_BASE_PORT:-37015}"
++
++run_check hub run-hub.sh ov_hub OPENVIBE_HUB_PORT "$BASE_PORT"
++run_check prophunt run-prophunt.sh ph_openvibe_dev OPENVIBE_PROPHUNT_PORT "$((BASE_PORT + 1))"
++run_check deathrun run-deathrun.sh dr_openvibe_dev OPENVIBE_DEATHRUN_PORT "$((BASE_PORT + 2))"
++run_check fortwars run-fortwars.sh fw_openvibe_dev OPENVIBE_FORTWARS_PORT "$((BASE_PORT + 3))"
++run_check traitortown run-traitortown.sh tt_openvibe_dev OPENVIBE_TRAITORTOWN_PORT "$((BASE_PORT + 4))"