From 3f4d62daac7610253afdd30d80a9e35c67c5b44f Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 1 Nov 2021 15:53:00 +0100 Subject: [PATCH] more like the csgo docker image --- Dockerfile | 5 ++--- README.md | 6 +++++- docker-compose.yml | 15 ++++++++++++--- start.sh | 28 ++++++---------------------- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 360dd61..cd04ad1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM cm2network/steamcmd:latest - +RUN mkdir -p /home/steam/server COPY start.sh /home/steam/start.sh - +VOLUME "/home/steam/server" WORKDIR /home/steam/ - ENTRYPOINT /home/steam/start.sh diff --git a/README.md b/README.md index bf0504a..5b90455 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,13 @@ Left 4 dead 2 server. - 27015 - 27015/udp +# Volumes + +You can create a volume at `/home/steam/server` to not redownload the game every time you make a change at the docker-compose file. + # Configuration -The `server.cfg` gets created on the fly and gets filled with the enviroment variable starting with `CVAR_`. +You can set ANY conVar you want simply by prefixing the enviroment with `CVAR_`. So for example to set the RCON password set the enviroment variable `CVAR_RCON_PASSWORD=password123`. Try to avoid variables with the word `CVAR_` and avoid `=` in it. diff --git a/docker-compose.yml b/docker-compose.yml index 902dd4e..6e26afb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,18 @@ services: - CVAR_SV_CONSISTENCY=1 - CAVR_SV_VOICEENABLE=1 - CVAR_MP_DISABLE_AUTOKICK=1 - volumes: - - ./motd.txt:/motd.txt:ro - - ./host:txt:/host.txt:ro + - "MOTD_FILE_CONTENT=Put your MODT here. \n +Multiline is also supported." + - "HOST_FILE_CONTENT=Same with the host file \n +lalalalal" ports: - 27015:27015 - 27015:27015/udp + volumes: + - l4d2_game:/home/steam/server + stdin_open: true + tty: true +volumes: + l4d2_game: + name: l4d2_game + diff --git a/start.sh b/start.sh index 6a1ef15..d5f0a63 100755 --- a/start.sh +++ b/start.sh @@ -2,30 +2,14 @@ set -e -echo "### Installing / Updateing l4d2 ###" +/home/steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir "$HOME/server" +app_update 222860 validate +quit -/home/steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir $HOME/server +app_update 222860 validate +quit +echo -n "$MOTD_FILE_CONTENT" > "$HOME/server/left4dead2/motd.txt" -echo "### Creating config ###" +echo -n "$HOST_FILE_CONTENT" > "$HOME/server/left4dead2/host.txt" -env | awk -F "=" '/^CVAR_/ {sub("CVAR_","",$1); print tolower($1),($2 ~ /^[0-9]+$/)?$2:"\""$2"\""}' > $HOME/server/left4dead2/cfg/server.cfg +env | awk -F "=" '/^CVAR_/ {sub("CVAR_","",$1); print tolower($1),($2 ~ /^[0-9]+$/)?$2:"\""$2"\""}' > /home/steam/server/left4dead2/cfg/server.cfg -echo "### Using follwing config: " -cat $HOME/server/left4dead2/cfg/server.cfg -echo "###" +cat /home/steam/server/left4dead2/cfg/server.cfg -echo "### Linking host and motd file ### " - -if [[ -f "/motd.txt" ]]; then - rm $HOME/server/left4dead2/motd.txt - ln -sf /motd.txt $HOME/server/left4dead2/motd.txt -fi - -if [[ -f "/host.txt" ]]; then - rm $HOME/server/left4dead2/host.txt - ln -sf /host.txt $HOME/server/left4dead2/host.txt -fi - -echo "### Starting l4d2 ###" - -$HOME/server/srcds_run -console -game left4dead2 +maxplayers 16 -maxclients 16 -ip 0.0.0.0 +map c1m1_hotel +"$HOME/server/srcds_run" -console -game left4dead2 +maxplayers 16 -maxclients 16 -ip 0.0.0.0