From 60fc1d58ee6d790914112c6a687e3789035e0fd7 Mon Sep 17 00:00:00 2001 From: Daniel Ceregatti Date: Wed, 29 May 2024 20:08:08 -0700 Subject: [PATCH] Add support for setting the steam query port via the environment. It's optional, but now we're going to always use it, so we normalized that setting in the serverDZ.cfg that we ship (which we should probably update, as 1.25 adds new entries). --- files/serverDZ.cfg | 2 +- server/bin/dz | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/files/serverDZ.cfg b/files/serverDZ.cfg index 2bc3921..2d8685c 100644 --- a/files/serverDZ.cfg +++ b/files/serverDZ.cfg @@ -49,7 +49,7 @@ adminLogPlayerList = 0; // 1 - log periodic player list with position every 5 enableDebugMonitor = 0; // shows info about the character using a debug window in a corner of the screen (value 0-1) -//steamQueryPort = 2305; // defines Steam query port, should fix the issue with server not being visible in client server browser +steamQueryPort = 27016; // defines Steam query port, should fix the issue with server not being visible in client server browser allowFilePatching = 1; // if set to 1 it will enable connection of clients with "-filePatching" launch parameter enabled diff --git a/server/bin/dz b/server/bin/dz index e949e40..99c0edf 100755 --- a/server/bin/dz +++ b/server/bin/dz @@ -11,6 +11,7 @@ mkdir -p ${SERVER_PROFILE}/battleye SERVER_CFG_FILE="serverDZ.cfg" SERVER_CFG_DST="${SERVER_PROFILE}/${SERVER_CFG_FILE}" SERVER_CFG_SRC="${FILES}/${SERVER_CFG_FILE}" +SERVER_CFG_SAVE="${SERVER_PROFILE}/${SERVER_CFG_FILE}.save" # Command line parameters except mod, as that is handled separately. parameters="-config=${SERVER_CFG_DST} -port=${port} -freezecheck -BEpath=${SERVER_PROFILE}/battleye -profiles=${SERVER_PROFILE} -nologs" @@ -62,10 +63,10 @@ loadconfig(){ exit 1 fi # Handle the initial server configuration file - if [ ! -f ${SERVER_CFG_DST} ] + if [ ! -f ${SERVER_CFG_SAVE} ] then echo "Creating initial server configuration file" - cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}" + cp "${SERVER_CFG_SRC}" "${SERVER_CFG_SAVE}" fi # battleye config and rconpassword setup # The server creates a new file from this file, which it then uses. @@ -411,6 +412,9 @@ start(){ # actual status with those echo ${mod_command_line} > /tmp/mod_command_line echo ${parameters} > /tmp/parameters + # Add the steam port from the environment + cp -a "${SERVER_CFG_SAVE}" "${SERVER_CFG_DST}" + sed -e "s,^steamQueryPort.*,steamQueryPort = ${STEAM_PORT};," -i "${SERVER_CFG_DST}" ./DayZServer "${mod_command_line}" ${parameters} EXIT_CODE=$? printf "\n[ ${yellow}DayZ${default} ] Server exited. Exit code: ${EXIT_CODE}\n" @@ -446,20 +450,20 @@ force(){ # Handle any changes in the server config file by allowing them to be merged after viewing a diff. config(){ - if ! diff -q "${SERVER_CFG_DST}" "${SERVER_CFG_SRC}" + if ! diff -q "${SERVER_CFG_SAVE}" "${SERVER_CFG_SRC}" then echo "=========================================================================" - diff -Nau --color "${SERVER_CFG_DST}" "${SERVER_CFG_SRC}" | more + diff -Nau --color "${SERVER_CFG_SAVE}" "${SERVER_CFG_SRC}" | more echo "=========================================================================" if prompt_yn "The new server configuration file differs from what's installed. Use it?" then echo "Updating the server configuration file" - cp "${SERVER_CFG_SRC}" "${SERVER_CFG_DST}" + cp "${SERVER_CFG_SRC}" "${SERVER_CFG_SAVE}" else echo "NOT updating the server configuration file" fi else - echo "No differences found between ${SERVER_CFG_SRC} and ${SERVER_CFG_DST}" + echo "No differences found between ${SERVER_CFG_SRC} and ${SERVER_CFG_SAVE}" fi } @@ -540,9 +544,9 @@ activelist(){ get_map_name(){ MAP="none" # Map name - if [[ -f ${SERVER_CFG_DST} ]] + if [[ -f ${SERVER_CFG_SAVE} ]] then - MAP=$(grep -E "template=" ${SERVER_CFG_DST} | grep -vE "^//" | cut -d= -f2 | cut -d\; -f1 | tr -d '"') + MAP=$(grep -E "template=" ${SERVER_CFG_SAVE} | grep -vE "^//" | cut -d= -f2 | cut -d\; -f1 | tr -d '"') fi echo ${MAP} }