|
#!/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 |
|
|