Merge branch 'joedwards32:main' into main

This commit is contained in:
Alex 2023-11-06 20:23:09 +01:00 committed by GitHub
commit 2da61fd258
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 118 additions and 11 deletions

View file

@ -29,7 +29,7 @@ or using docker-compose, see [examples](https://github.com/joedwards32/CS2/blob/
$ docker compose --file examples/docker-compose.yml up -d cs2-server $ docker compose --file examples/docker-compose.yml up -d cs2-server
``` ```
You must have at least **40GB** of free disk space! See [System Requirements](#System Requirements). You must have at least **40GB** of free disk space! See [System Requirements](./#system-requirements).
`STEAMUSER` and `STEAMPASS` **are required as unlike CS:GO, CS2 can not be downloaded anonymously (at time of writing).** `STEAMUSER` and `STEAMPASS` **are required as unlike CS:GO, CS2 can not be downloaded anonymously (at time of writing).**
@ -62,7 +62,7 @@ STEAMGUARD="" (Optional, Steam Guard key if enabled. Use your most
```dockerfile ```dockerfile
CS2_SERVERNAME="changeme" (Set the visible name for your private server) CS2_SERVERNAME="changeme" (Set the visible name for your private server)
CS2_IP=0.0.0.0 (CS2 server listening IP address, 0.0.0.0 - all IP addresses on the local machine, empty - IP identified automatically) 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) 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. 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.) Useful for services like AWS Fargate which do not support mixed protocol ports.)
@ -92,6 +92,29 @@ CS2_BOT_QUOTA="" (Number of bots)
CS2_BOT_QUOTA_MODE="" (fill, competitive) CS2_BOT_QUOTA_MODE="" (fill, competitive)
``` ```
### CSTV/SourceTV
```dockerfile
TV_ENABLE=0 (0 - disable, 1 - enable)
TV_PORT=27020 (SourceTV/CSTV port to bind to)
TV_AUTORECORD=0 (Automatically record all games as CSTV demos: 0=off, 1=on)
TV_PW="changeme" (CSTV password for clients)
TV_RELAY_PW="changeme" (CSTV password for relay proxies)
TV_MAXRATE=0 (Max CSTV spectator bandwidth rate allowed, 0 == unlimited)
TV_DELAY=0 (CSTV broadcast delay in seconds)
```
# Customizing this Container
## Pre and Post Hooks
The container includes two scripts for executing custom actions:
* `/home/steam/cs2-dedicated/pre.sh` is executed before the CS2 server starts
* `/home/steam/cs2-dedicated/post.sh` is executed after the CS2 server stops
When using a persient volume mounted at `/home/steam/cs2-dedicated/` you may edit these scripts to perform custom actions, such as enabling metamod.
# Credits # Credits
This container leans heavily on the work of [CM2Walki](https://github.com/CM2Walki/), especially his [SteamCMD](https://github.com/CM2Walki/steamcmd) container image. GG! This container leans heavily on the work of [CM2Walki](https://github.com/CM2Walki/), especially his [SteamCMD](https://github.com/CM2Walki/steamcmd) container image. GG!

View file

@ -18,6 +18,8 @@ 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" COPY etc/server.cfg "/etc/server.cfg"
COPY etc/pre.sh "/etc/pre.sh"
COPY etc/post.sh "/etc/post.sh"
RUN set -x \ RUN set -x \
# Install, update & upgrade packages # Install, update & upgrade packages
@ -53,6 +55,13 @@ ENV CS2_SERVERNAME="cs2 private server" \
CS2_GAMETYPE=0 \ CS2_GAMETYPE=0 \
CS2_GAMEMODE=1 \ CS2_GAMEMODE=1 \
CS2_LAN=0 \ CS2_LAN=0 \
TV_AUTORECORD=0 \
TV_ENABLE=0 \
TV_PORT=27020 \
TV_PW="changeme" \
TV_RELAY_PW="changeme" \
TV_MAXRATE=0 \
TV_DELAY=0 \
CS2_ADDITIONAL_ARGS="" CS2_ADDITIONAL_ARGS=""
# Set permissions on STEAMAPPDIR # Set permissions on STEAMAPPDIR

View file

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
# Create App Dir
mkdir -p "${STEAMAPPDIR}" || true mkdir -p "${STEAMAPPDIR}" || true
# Download Updates # Download Updates
@ -14,10 +16,25 @@ ln -sfT ${STEAMCMDDIR}/linux64/steamclient.so ~/.steam/sdk64/steamclient.so
# Install server.cfg # Install server.cfg
cp /etc/server.cfg "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg cp /etc/server.cfg "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg
sed -i -e "s/{{SERVER_HOSTNAME}}/${CS2_SERVERNAME}/g" "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg \ sed -i -e "s/{{SERVER_HOSTNAME}}/${CS2_SERVERNAME}/g" \
-e "s/{{SERVER_PW}}/${CS2_PW}/g" "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg \ -e "s/{{SERVER_PW}}/${CS2_PW}/g" \
-e "s/{{SERVER_RCON_PW}}/${CS2_RCONPW}/g" "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg \ -e "s/{{SERVER_RCON_PW}}/${CS2_RCONPW}/g" \
-e "s/{{SERVER_LAN}}/${CS2_LAN}/g" "${STEAMAPPDIR}"/game/csgo/cfg/server.cfg -e "s/{{TV_ENABLE}}/${TV_ENABLE}/g" \
-e "s/{{TV_PORT}}/${TV_PORT}/g" \
-e "s/{{TV_AUTORECORD}}/${TV_AUTORECORD}/g" \
-e "s/{{TV_PW}}/${TV_PW}/g" \
-e "s/{{TV_RELAY_PW}}/${TV_RELAY_PW}/g" \
-e "s/{{TV_MAXRATE}}/${TV_MAXRATE}/g" \
-e "s/{{TV_DELAY}}/${TV_DELAY}/g" \
"${STEAMAPPDIR}"/game/csgo/cfg/server.cfg
# Install hooks
if [[ ! -f "${STEAMAPPDIR}/pre.sh" ]] ; then
cp /etc/pre.sh "${STEAMAPPDIR}/pre.sh"
fi
if [[ ! -f "${STEAMAPPDIR}/post.sh" ]] ; then
cp /etc/post.sh "${STEAMAPPDIR}/post.sh"
fi
# Rewrite Config Files # Rewrite Config Files
@ -34,6 +51,9 @@ fi
# Switch to server directory # Switch to server directory
cd "${STEAMAPPDIR}/game/bin/linuxsteamrt64" cd "${STEAMAPPDIR}/game/bin/linuxsteamrt64"
# Pre Hook
bash "${STEAMAPPDIR}/pre.sh"
# Construct server arguments # Construct server arguments
if [[ -z $CS2_GAMEALIAS ]]; then if [[ -z $CS2_GAMEALIAS ]]; then
@ -44,6 +64,12 @@ else
CS2_GAME_MODE_ARGS="+game_alias ${CS2_GAMEALIAS}" CS2_GAME_MODE_ARGS="+game_alias ${CS2_GAMEALIAS}"
fi fi
if [[ -z $CS2_IP ]]; then
CS2_IP_ARGS=""
else
CS2_IP_ARGS="-ip ${CS2_IP}"
fi
# Start Server # Start Server
if [[ ! -z $CS2_RCON_PORT ]]; then if [[ ! -z $CS2_RCON_PORT ]]; then
@ -52,7 +78,7 @@ if [[ ! -z $CS2_RCON_PORT ]]; then
fi fi
eval "./cs2" -dedicated \ eval "./cs2" -dedicated \
-ip "${CS2_IP}" -port "${CS2_PORT}" \ "${CS2_IP_ARGS}" -port "${CS2_PORT}" \
-console \ -console \
-usercon \ -usercon \
-maxplayers "${CS2_MAXPLAYERS}" \ -maxplayers "${CS2_MAXPLAYERS}" \
@ -61,4 +87,8 @@ eval "./cs2" -dedicated \
+map "${CS2_STARTMAP}" \ +map "${CS2_STARTMAP}" \
+rcon_password "${CS2_RCONPW}" \ +rcon_password "${CS2_RCONPW}" \
+sv_password "${CS2_PW}" \ +sv_password "${CS2_PW}" \
+sv_lan "${CS2_LAN}" \
"${CS2_ADDITIONAL_ARGS}" "${CS2_ADDITIONAL_ARGS}"
# Post Hook
bash "${STEAMAPPDIR}/post.sh"

5
bullseye/etc/post.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
# POST HOOK
# Make your customisation here
echo "post-hook: noop"

5
bullseye/etc/pre.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
# PRE HOOK
# Make your customisation here
echo "pre-hook: noop"

View file

@ -1,9 +1,35 @@
// Server Defaults // Server Defaults
hostname "{{SERVER_HOSTNAME}}" hostname "{{SERVER_HOSTNAME}}" // Set server hostname
sv_lan {{SERVER_LAN}}
// Passwords // Passwords
rcon_password "{{SERVER_RCON_PW}}" rcon_password "{{SERVER_RCON_PW}}" // Set rcon password
sv_password "{{SERVER_PW}}" sv_password "{{SERVER_PW}}" // Set server password
// CSTV
sv_hibernate_postgame_delay 180 // Delay server hibernation after all clients disconnect
tv_allow_camera_man 1 // Auto director allows spectators to become camera man
tv_allow_static_shots 1 // Auto director uses fixed level cameras for shots
tv_autorecord {{TV_AUTORECORD}} // Automatically records all games as CSTV demos: 0=off, 1=on.
tv_chatgroupsize 0 // Set the default chat group size
tv_chattimelimit 8 // Limits spectators to chat only every n seconds
tv_debug 0 // CSTV debug info.
tv_delay {{TV_DELAY}} // CSTV broadcast delay in seconds
tv_delaymapchange 1 // Delays map change until broadcast is complete
tv_deltacache 2 // Enable delta entity bit stream cache
tv_dispatchmode 1 // Dispatch clients to relay proxies: 0=never, 1=if appropriate, 2=always
tv_enable {{TV_ENABLE}} // Activates CSTV on server: 0=off, 1=on.
tv_maxclients 10 // Maximum client number on CSTV server.
tv_maxrate {{TV_MAXRATE}} // Max CSTV spectator bandwidth rate allowed, 0 == unlimited
tv_name "{{SERVER_HOSTNAME}} CSTV" // CSTV host name
tv_overridemaster 0 // Overrides the CSTV master root address.
tv_port {{TV_PORT}} // Host SourceTV port
tv_password "{{TV_PW}}" // CSTV password for clients
tv_relaypassword "{{TV_RELAY_PW}}" // CSTV password for relay proxies
tv_relayvoice 1 // Relay voice data: 0=off, 1=on
tv_timeout 60 // CSTV connection timeout in seconds.
tv_title "{{SERVER_HOSTNAME}} CSTV" // Set title for CSTV spectator UI
tv_transmitall 1 // Transmit all entities (not only director view)

View file

@ -28,10 +28,19 @@ services:
- CS2_BOT_DIFFICULTY # (0 - easy, 1 - normal, 2 - hard, 3 - expert) - CS2_BOT_DIFFICULTY # (0 - easy, 1 - normal, 2 - hard, 3 - expert)
- CS2_BOT_QUOTA # (Number of bots) - CS2_BOT_QUOTA # (Number of bots)
- CS2_BOT_QUOTA_MODE # (fill, competitive) - CS2_BOT_QUOTA_MODE # (fill, competitive)
# TV
- TV_AUTORECORD=0 # Automatically records all games as CSTV demos: 0=off, 1=on.
- TV_ENABLE=0 # Activates CSTV on server: 0=off, 1=on.
- TV_PORT=27020 # Host SourceTV port
- TV_PW=changeme # CSTV password for clients
- TV_RELAY_PW=changeme # CSTV password for relay proxies
- TV_MAXRATE=0 # World snapshots to broadcast per second. Affects camera tickrate.
- TV_DELAY=0 # Max CSTV spectator bandwidth rate allowed, 0 == unlimited
volumes: volumes:
- cs2:/home/steam/cs2-dedicated/ # (Change /mnt/cs2 according to your volume location) - cs2:/home/steam/cs2-dedicated/ # (Change /mnt/cs2 according to your volume location)
ports: ports:
- "27015:27015/tcp" # TCP - "27015:27015/tcp" # TCP
- "27015:27015/udp" # UDP - "27015:27015/udp" # UDP
- "27020:27020/udp" # UDP
volumes: volumes:
cs2: cs2: