commit cf2f45b76538ec05c86736bba13f1c1ba8522dee Author: Djeeberjr Date: Mon Oct 18 00:27:51 2021 +0200 initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7778b42 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM cm2network/steamcmd:latest + +COPY entrypoint.sh /home/steam/entrypoint.sh + +USER steam +VOLUME /home/steam/server +WORKDIR /home/steam/ + +ENTRYPOINT /home/steam/entrypoint.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a36b50 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Standard enviroment variable + +`GSLT`: Game Server Login Token. Required if you want your server to public. Get your token [here](https://steamcommunity.com/dev/managegameservers). + +`WORKSHOP_AUTHKEY`: Required if you want to play workshop maps. Get your token [here](https://steamcommunity.com/dev/apikey) + +`MAP`: Default map to start. + +`INSECURE`: Set this var to disable VAC. + +`MAX_PLAYERS`: Overide max players. + +`TICKRATE`: Tickrate of the server. Default is 64. + +`NOHLTV`: Disable HLTV. + +`MAPGROUP`: Mapgroup to cycle through. Values: `mg_bomb`, `mg_hostage`, `mg_dust`, `mg_demolition` or `mg_armsrace`. + +`RCONPW`: Sets the RCON password. + +`WORKSHOP_MAP`: Specify with what workshop map to start. + +`WORKSHOP_COLLECTION`: Specify what workshop collection to cycle through. + +`GAMEMODE`: What gamemode to load. Not the same as the `game_mode` cvar. Value gets translated to a gamemode/gametype combination. Available values are: `casual`,`competitive`, `wingman`, `armsrace`, `deathmatch`, `custom`, `coop`, `dangerzone`, `weaponexpert`,`demolition`,`stab_zap`,`ffa`,`flying_scoutsman`,`trigger_discipline`,`headshots`,`hunter_gatherers`,`retakes`,`competitive_short`. For more information see [here](https://developer.valvesoftware.com/wiki/CS:GO_Game_Mode_Commands). + +# Custom conVars + +You can set ANY other variable by just prefixing the conVar with `CVAR_`. So for example if you want to set `mp_disable_autokick 1` just set the enviroment variable `CVAR_MP_DISABLE_AUTOKICK` to `1`. Upper or lower case is ignored. + +# Minimum configuration + +The minimum variables you should set for a somewhat working game is is `GSLT`, `MAP` and maybe `GAMEMODE`. You can also check out the example [docker-compose.yml](docker-compose.yml). + +# Misc + +Because docker-compose recreated the container every time you update a varaible you can mount `/home/steam/server` to a volume so that you dont have to redownload the server every time you change something. + +The game gets updated every time the image restarts. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5539e36 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,29 @@ +version: "3" + +services: + csgo: + build: . + environment: + - INSECURE=true + - MAX_PLAYERS=16 + - TICKRATE=128 + - GSLT=XXXX + - WORKSHOP_AUTHKEY=XXXXX + - MAP=de_nuke + - MAPGROUP=mg_bomb + - GAMEMODE=retakes + - RCONPW=password123 + - CVAR_MP_DISABLE_AUTOKICK=1 + volumes: + - csgo_game:/home/steam/server + ports: + - 0.0.0.0:27015:27015/tcp + - 0.0.0.0:27015:27015/udp + - 0.0.0.0:27020:27020/tcp + - 0.0.0.0:27020:27020/udp + stdin_open: true + tty: true + +volumes: + csgo_game: + name: csgo_game \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..db89ad0 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +set -eo pipefail + +/home/steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/steam/server +app_update 740 validate +quit + +SRCDS_ARGS="-usercon" + +if [ -n "$GSLT" ]; then + SRCDS_ARGS="${SRCDS_ARGS} +sv_setsteamaccount ${GSLT}" +else + echo "GSLT not set. Connections will be restricted to LAN only." +fi + +if [ -n "$WORKSHOP_AUTHKEY" ]; then + SRCDS_ARGS="${SRCDS_ARGS} -authkey ${WORKSHOP_AUTHKEY}" +else + echo "WORKSHOP_AUTHKEY not set. Workshop maps will be unsupported." +fi + +if [ -n "$INSECURE" ]; then + SRCDS_ARGS="${SRCDS_ARGS} -insecure" + echo "Running with VAC disabled." +fi + +if [ -n "$MAX_PLAYERS" ]; then + SRCDS_ARGS="${SRCDS_ARGS} -maxplayers $MAX_PLAYERS" + echo "Maxplayers set to ${MAX_PLAYERS}." +fi + +if [ -n "$TICKRATE" ]; then + SRCDS_ARGS="${SRCDS_ARGS} -tickrate $TICKRATE" + echo "Tickrate set to $TICKRATE." +fi + +if [ -n "$NOHLTV" ]; then + SRCDS_ARGS="${SRCDS_ARGS} -nohltv" + echo "Disableing HLTV." +fi + +if [ -n "$RCONPW" ]; then + SRCDS_ARGS="${SRCDS_ARGS} +rcon_password $RCONPW" + echo "Setting RCON password to: $RCONPW" +fi + +if [ -n "$GAMEMODE" ]; then + case "$GAMEMODE" in + "casual" | "competitive" | "wingman" | "weaponexpert") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0" + ;; + "armsrace" | "demolition" | "deathmatch") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 1" + ;; + "custom" ) + SRCDS_ARGS="${SRCDS_ARGS} +game_type 3" + ;; + "guardian" | "coop" ) + SRCDS_ARGS="${SRCDS_ARGS} +game_type 4" + ;; + "dangerzone" ) + SRCDS_ARGS="${SRCDS_ARGS} +game_type 6" + ;; + esac + + case "$GAMEMODE" in + "casual" | "armsrace" | "custom" | "guardian" | "dangerzone") + SRCDS_ARGS="${SRCDS_ARGS} +game_mode 0" + ;; + "competitive" | "demolition" | "coop") + SRCDS_ARGS="${SRCDS_ARGS} +game_mode 1" + ;; + "wingman" | "deathmatch") + SRCDS_ARGS="${SRCDS_ARGS} +game_mode 2" + ;; + "weaponexpert") + SRCDS_ARGS="${SRCDS_ARGS} +game_mode 3" + ;; + esac + + case "$GAMEMODE" in + "stab_zap") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 0 +sv_skirmish_id 1" + ;; + "ffa") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 2 +sv_game_mode_flags 32" + ;; + "flying_scoutsman") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 0 +sv_skirmish_id 3" + ;; + "trigger_discipline") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 0 +sv_skirmish_id 4" + ;; + "headshots") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 2 +sv_skirmish_id 6" + ;; + "hunter_gatherers") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 2 +sv_skirmish_id 7" + ;; + "retakes") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 0 +sv_skirmish_id 12" + ;; + "competitive_short") + SRCDS_ARGS="${SRCDS_ARGS} +game_type 0 +game_mode 1 +sv_game_mode_flags 32" + ;; + esac + +fi + +if [ -n "$MAP" ]; then + SRCDS_ARGS="${SRCDS_ARGS} +map ${MAP}" +fi + +if [ -n "$MAPGROUP" ]; then + SRCDS_ARGS="${SRCDS_ARGS} +mapgroup ${MAPGROUP}" +fi + +if [ -n "$WORKSHOP_MAP" ]; then + SRCDS_ARGS="${SRCDS_ARGS} +host_workshop_map ${WORKSHOP_MAP}" + + if [ -z "$WORKSHOP_AUTHKEY" ]; then + echo "WORKSHOP_MAP set but no WORKSHOP_AUTHKEY. This may not work." + fi +fi + +if [ -n "$WORKSHOP_COLLECTION" ]; then + SRCDS_ARGS="${SRCDS_ARGS} +host_workshop_collection ${WORKSHOP_COLLECTION}" + + if [ -z "$WORKSHOP_AUTHKEY" ]; then + echo "WORKSHOP_COLLECTION set but no WORKSHOP_AUTHKEY. This may not work." + fi +fi + +CVARS=$(env | awk -F "=" '/^CVAR_/ { sub("CVAR_","",$1); print "+"tolower($1),($2 ~ /^[0-9]+$/)?$2:"\""$2"\""," "}' | tr -d "\n") + +echo "Running command: srcds_run -game csgo $SRCDS_ARGS $CVARS" + +/home/steam/server/srcds_run -game csgo $SRCDS_ARGS $CVARS