Skip to content

Instantly share code, notes, and snippets.

@meyt
Last active April 26, 2024 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meyt/7ad415cfe491638b4feac4211d6ec089 to your computer and use it in GitHub Desktop.
Save meyt/7ad415cfe491638b4feac4211d6ec089 to your computer and use it in GitHub Desktop.
cs2 setup
#!/bin/bash
SRCDS_TOKEN="..."
CS2_RCON_PORT=1002
CS2_PORT=27015
CS2_RCONPW="changeme"
CS2_PW="changeme"
CS2_MAXPLAYERS=10
CS2_ADDITIONAL_ARGS=""
CS2_GAMEALIAS="competitive" # competitive, wingman, casual, deathmatch, custom
CS2_MAPGROUP="mg_active"
CS2_STARTMAP="de_inferno"
TV_PORT=27020
CONTAINER_NAME="cs2"
DATA_DIR="/home/steam/cs2-dedicated"
# install docker
if [ "$1" == "docker" ]; then
echo "nameserver 185.55.226.26" > /etc/resolv.conf
apt-get update
apt-get install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
#########
# Configure docker
# alternative mirrors:
# - https://docker.iranserver.com
# - https://registry.docker.ir
# - https://docker.arvancloud.ir
# - https://docker.haiocloud.com/
# - https://docker.host:5000
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://docker.haiocloud.com/"]
}
EOF
systemctl daemon-reload
systemctl restart docker
#########
# Start
mkdir -p $DATA_DIR
chown 1000:1000 $DATA_DIR
docker kill $CONTAINER_NAME || true
docker rm $CONTAINER_NAME || true
# https://github.com/joedwards32/CS2/raw/main/examples/docker-compose.yml
docker run -d --name=$CONTAINER_NAME \
-e HTTP_PROXY="" \
-e HTTPS_PROXY="" \
-e SRCDS_TOKEN="$SRCDS_TOKEN" \
-e CS2_RCON_PORT="$CS2_RCON_PORT" \
-e CS2_PORT="$CS2_PORT" \
-e CS2_RCONPW="$CS2_RCONPW" \
-e CS2_PW="$CS2_PW" \
-e CS2_MAXPLAYERS="$CS2_MAXPLAYERS" \
-e CS2_ADDITIONAL_ARGS="$CS2_ADDITIONAL_ARGS" \
-e CS2_GAMEALIAS="$CS2_GAMEALIAS" \
-e CS2_MAPGROUP="$CS2_MAPGROUP" \
-e CS2_STARTMAP="$CS2_STARTMAP" \
-e TV_PORT="$TV_PORT" \
-v $DATA_DIR:/home/steam/cs2-dedicated/ \
-p $CS2_RCON_PORT:$CS2_RCON_PORT/tcp \
-p $CS2_PORT:$CS2_PORT/tcp \
-p $CS2_PORT:$CS2_PORT/udp \
-p $TV_PORT:$TV_PORT/udp \
joedwards32/cs2
docker logs $CONTAINER_NAME -f

Install metamod and plugins

  1. Download metamod and install
mkdir -p /tmp/metamod
cd /tmp/metamod
wget https://mms.alliedmods.net/mmsdrop/2.0/mmsource-2.0.0-git1289-linux.tar.gz
tar xvf mmsource-2.0.0-git1289-linux.tar.gz
mkdir /home/steam/cs2-dedicated/game/csgo/addons || true
cp -R addons/* /home/steam/cs2-dedicated/game/csgo/addons
chown -R 1000:1000 /home/steam/cs2-dedicated/game/csgo/addons
  1. Edit /game/csgo/gameinfo.gi, locate for Game_LowViolence csgo_lv // Perfect World content override
  2. Create a new line underneath and add Game csgo/addons/metamod
  3. docker restart cs2
  4. run rcon meta list, if says unknown command then installion failed.

Install CounterStrikeSharp (CSS)

mkdir -p /tmp/cssharp
cd /tmp/cssharp
wget https://github.com/roflmuffin/CounterStrikeSharp/releases/download/v213/counterstrikesharp-with-runtime-build-213-linux-dfc9859.zip
unzip counterstrikesharp-with-runtime-build-213-linux-dfc9859.zip
cp -R addons/* /home/steam/cs2-dedicated/game/csgo/addons
chown -R 1000:1000 /home/steam/cs2-dedicated/game/csgo/addons
docker restart cs2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment