Skip to content

Commit

Permalink
Merge pull request #5 from joedwards32/3-container-environment
Browse files Browse the repository at this point in the history
Issue-3 Env var parsing bug fixes
  • Loading branch information
joedwards32 authored Oct 2, 2023
2 parents 2d93e45 + 056fbb9 commit 8b87611
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Feel free to overwrite these environment variables, using -e (--env):
STEAMUSER="changeme" (Steam User for SteamCMD.)
STEAMPASS="changeme" (Password for Steam User.)
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_RCONPW="changeme" (RCON password)
CS2_PW="changeme" (CS2 server password)
Expand Down
4 changes: 3 additions & 1 deletion bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ENV STEAMAPPDIR "${HOMEDIR}/${STEAMAPP}-dedicated"
ENV CFG_URL https://raw.githubusercontent.com/joedwards32/CS2/settings.tgz

COPY etc/entry.sh "${HOMEDIR}/entry.sh"
COPY etc/server.cfg "/etc/server.cfg"

RUN set -x \
# Install, update & upgrade packages
Expand All @@ -31,7 +32,8 @@ RUN set -x \

FROM build_stage AS bullseye-base

ENV CS2_PORT=27015 \
ENV CS2_SERVERNAME="cs2 private server" \
CS2_PORT=27015 \
CS2_MAXPLAYERS=10 \
CS2_RCONPW="changeme" \
CS2_PW="changeme" \
Expand Down
15 changes: 11 additions & 4 deletions bullseye/etc/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,35 @@ bash "${STEAMCMDDIR}/steamcmd.sh" +force_install_dir "${STEAMAPPDIR}" \
+app_update "${STEAMAPPID}" \
+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

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
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
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

# Start Server

"${STEAMAPPDIR}/game/bin/linuxsteamrt64/cs2" -dedicated \
-console \
-usercon \
-maxplayers_override "${CS2_MAXPLAYERS}" \
+game_type "${CS2_GAMETYPE}" \
+game_mode "${CS2_GAMEMODE}" \
+mapgroup "${CS2_MAPGROUP}" \
+map "${CS2_STARTMAP}" \
+sv_setsteamaccount \
-maxplayers_override "${CS2_MAXPLAYERS}" \
+rcon_password "${CS2_RCONPW}" \
+sv_password "${CS2_PW}" \
"${CS2_ADDITIONAL_ARGS}"
9 changes: 9 additions & 0 deletions bullseye/etc/server.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Server Defaults

hostname "{{SERVER_HOSTNAME}}"
sv_lan "0"

// Passwords

rcon_password "{{SERVER_RCON_PW}}"
sv_password "{{SERVER_PW}}"

0 comments on commit 8b87611

Please sign in to comment.