Issue-3 Env var parsing bug fixes

* Password now set on commandline and in server.cfg
* Rcon password now set on commandline and in server.cfg
* Server name now set in server.cfg
This commit is contained in:
John Edwards 2023-10-02 14:44:32 +01:00
parent 2d93e45b28
commit 056fbb9a3a
4 changed files with 24 additions and 5 deletions

View file

@ -36,6 +36,7 @@ Feel free to overwrite these environment variables, using -e (--env):
STEAMUSER="changeme" (Steam User for SteamCMD.) STEAMUSER="changeme" (Steam User for SteamCMD.)
STEAMPASS="changeme" (Password for Steam User.) STEAMPASS="changeme" (Password for Steam User.)
STEAMGUARD="" (Optional, Steam Guard key if enabled. Use your most recent Steam Guard key.) STEAMGUARD="" (Optional, Steam Guard key if enabled. Use your most recent Steam Guard key.)
CS2_SERVERNAME="changeme" (Set the visible name for your private server)
CS2_PORT=27015 (CS2 server listen port tcp_udp) CS2_PORT=27015 (CS2 server listen port tcp_udp)
CS2_RCONPW="changeme" (RCON password) CS2_RCONPW="changeme" (RCON password)
CS2_PW="changeme" (CS2 server password) CS2_PW="changeme" (CS2 server password)

View file

@ -14,6 +14,7 @@ ENV STEAMAPPDIR "${HOMEDIR}/${STEAMAPP}-dedicated"
ENV CFG_URL https://raw.githubusercontent.com/joedwards32/CS2/settings.tgz ENV CFG_URL https://raw.githubusercontent.com/joedwards32/CS2/settings.tgz
COPY etc/entry.sh "${HOMEDIR}/entry.sh" COPY etc/entry.sh "${HOMEDIR}/entry.sh"
COPY etc/server.cfg "/etc/server.cfg"
RUN set -x \ RUN set -x \
# Install, update & upgrade packages # Install, update & upgrade packages
@ -31,7 +32,8 @@ RUN set -x \
FROM build_stage AS bullseye-base FROM build_stage AS bullseye-base
ENV CS2_PORT=27015 \ ENV CS2_SERVERNAME="cs2 private server" \
CS2_PORT=27015 \
CS2_MAXPLAYERS=10 \ CS2_MAXPLAYERS=10 \
CS2_RCONPW="changeme" \ CS2_RCONPW="changeme" \
CS2_PW="changeme" \ CS2_PW="changeme" \

View file

@ -8,28 +8,35 @@ bash "${STEAMCMDDIR}/steamcmd.sh" +force_install_dir "${STEAMAPPDIR}" \
+app_update "${STEAMAPPID}" \ +app_update "${STEAMAPPID}" \
+quit +quit
# Install server.cfg
cp /etc/server.cfg "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg
sed -i "s/{{SERVER_HOSTNAME}}/${CS2_SERVERNAME}/g" "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg
sed -i "s/{{SERVER_PW}}/${CS2_PW}/g" "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg
sed -i "s/{{SERVER_RCON_PW}}/${CS2_RCONPW}/g" "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg
# Rewrite Config Files # Rewrite Config Files
if [[ ! -z $CS2_BOT_DIFFICULTY ]] ; then if [[ ! -z $CS2_BOT_DIFFICULTY ]] ; then
sed -i "s/bot_difficulty.*/bot_difficulty ${CS2_BOT_DIFFICULTY}/" /home/steam/cs2-dedicated/game/csgo/cfg/* sed -i "s/bot_difficulty.*/bot_difficulty ${CS2_BOT_DIFFICULTY}/" "${STEAMAPPDIR}"/game/csgo/cfg/*
fi fi
if [[ ! -z $CS2_BOT_QUOTA ]] ; then if [[ ! -z $CS2_BOT_QUOTA ]] ; then
sed -i "s/bot_quota.*/bot_quota ${CS2_BOT_QUOTA}/" /home/steam/cs2-dedicated/game/csgo/cfg/* sed -i "s/bot_quota.*/bot_quota ${CS2_BOT_QUOTA}/" "${STEAMAPPDIR}"/game/csgo/cfg/*
fi fi
if [[ ! -z $CS2_BOT_QUOTA_MODE ]] ; then if [[ ! -z $CS2_BOT_QUOTA_MODE ]] ; then
sed -i "s/bot_quota_mode.*/bot_quota_mode ${CS2_BOT_QUOTA_MODE}/" /home/steam/cs2-dedicated/game/csgo/cfg/* sed -i "s/bot_quota_mode.*/bot_quota_mode ${CS2_BOT_QUOTA_MODE}/" "${STEAMAPPDIR}"/game/csgo/cfg/*
fi fi
# Start Server # Start Server
"${STEAMAPPDIR}/game/bin/linuxsteamrt64/cs2" -dedicated \ "${STEAMAPPDIR}/game/bin/linuxsteamrt64/cs2" -dedicated \
-console \
-usercon \ -usercon \
-maxplayers_override "${CS2_MAXPLAYERS}" \
+game_type "${CS2_GAMETYPE}" \ +game_type "${CS2_GAMETYPE}" \
+game_mode "${CS2_GAMEMODE}" \ +game_mode "${CS2_GAMEMODE}" \
+mapgroup "${CS2_MAPGROUP}" \ +mapgroup "${CS2_MAPGROUP}" \
+map "${CS2_STARTMAP}" \ +map "${CS2_STARTMAP}" \
+sv_setsteamaccount \ +sv_setsteamaccount \
-maxplayers_override "${CS2_MAXPLAYERS}" \
+rcon_password "${CS2_RCONPW}" \ +rcon_password "${CS2_RCONPW}" \
+sv_password "${CS2_PW}" \ +sv_password "${CS2_PW}" \
"${CS2_ADDITIONAL_ARGS}" "${CS2_ADDITIONAL_ARGS}"

9
bullseye/etc/server.cfg Normal file
View file

@ -0,0 +1,9 @@
// Server Defaults
hostname "{{SERVER_HOSTNAME}}"
sv_lan "0"
// Passwords
rcon_password "{{SERVER_RCON_PW}}"
sv_password "{{SERVER_PW}}"