Skip to content

Commit

Permalink
Add support for Game Login Tokens from https://steamcommunity.com/dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
joedwards32 committed Nov 29, 2023
1 parent 9802ea3 commit da6155a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ This Docker image contains the dedicated server of the game.

Running using Docker:
```console
$ docker run -d --name=cs2 -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2
$ docker run -d --name=cs2 -e SRCDS_TOKEN={YOURTOKEN} -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2
```

Running using a bind mount for data persistence on container recreation:
```console
$ mkdir -p $(pwd)/cs2-data
$ chmod 777 $(pwd)/cs2-data # Makes sure the directory is writeable by the unprivileged container user
$ docker run -d --name=cs2 -v $(pwd)/cs2-data:/home/steam/cs2-dedicated/ -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2
$ docker run -d --name=cs2 -e SRCDS_TOKEN={YOURTOKEN} -v $(pwd)/cs2-data:/home/steam/cs2-dedicated/ -p 27015:27015/tcp -p 27015:27015/udp -p 27020:27020/tcp joedwards32/cs2
```

or using docker-compose, see [examples](https://github.com/joedwards32/CS2/blob/main/examples/docker-compose.yml):
```console
# Remember to update passwords in your compose file
# Remember to update passwords and SRCDS_TOKEN in your compose file
$ docker compose --file examples/docker-compose.yml up -d cs2-server
```

Expand All @@ -49,6 +49,7 @@ Feel free to overwrite these environment variables, using -e (--env):
### Server Configuration

```dockerfile
SRCDS_TOKEN="" Game Server Token from https://steamcommunity.com/dev/managegameservers
CS2_SERVERNAME="changeme" (Set the visible name for your private server)
CS2_IP="" (CS2 server listening IP address, 0.0.0.0 - all IP addresses on the local machine, empty - IP identified automatically)
CS2_PORT=27015 (CS2 server listen port tcp_udp)
Expand Down
1 change: 1 addition & 0 deletions bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ENV CS2_SERVERNAME="cs2 private server" \
TV_RELAY_PW="changeme" \
TV_MAXRATE=0 \
TV_DELAY=0 \
SRCDS_TOKEN="" \
CS2_ADDITIONAL_ARGS=""

# Set permissions on STEAMAPPDIR
Expand Down
5 changes: 5 additions & 0 deletions bullseye/etc/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ else
CS2_IP_ARGS="-ip ${CS2_IP}"
fi

if [[ ! -z $SRCDS_TOKEN ]]; then
SV_SETSTEAMACCOUNT_ARGS="+sv_setsteamaccount ${SRCDS_TOKEN}"
fi

# Start Server

if [[ ! -z $CS2_RCON_PORT ]]; then
Expand All @@ -86,6 +90,7 @@ eval "./cs2" -dedicated \
+mapgroup "${CS2_MAPGROUP}" \
+map "${CS2_STARTMAP}" \
+rcon_password "${CS2_RCONPW}" \
"${SV_SETSTEAMACCOUNT_ARGS}" \
+sv_password "${CS2_PW}" \
+sv_lan "${CS2_LAN}" \
"${CS2_ADDITIONAL_ARGS}"
Expand Down
1 change: 1 addition & 0 deletions examples/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
container_name: cs2-dedicated
environment:
# Server configuration
- SRCDS_TOKEN # Game Server Token from https://steamcommunity.com/dev/managegameservers
- CS2_SERVERNAME=changeme # (Set the visible name for your private server)
- CS2_PORT=27015 # (CS2 server listen port tcp_udp)
- CS2_RCON_PORT # (Optional, use a simple TCP proxy to have RCON listen on an alternative port. Useful for services like AWS Fargate which do not support mixed protocol ports.)
Expand Down

0 comments on commit da6155a

Please sign in to comment.