Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
Add cs2 base image
Browse files Browse the repository at this point in the history
  • Loading branch information
sazarkin committed Nov 12, 2023
1 parent 04213bf commit 5e62fba
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
33 changes: 33 additions & 0 deletions base-cs2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM debian:bookworm-slim

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
rsync \
unzip \
wget \
lib32z1 \
locales \
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m csgo

USER csgo

RUN mkdir /home/csgo/Steam && \
mkdir /home/csgo/server

WORKDIR /home/csgo/Steam

RUN wget -qO- https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz | tar zxf - \
&& /home/csgo/Steam/steamcmd.sh +quit \
&& mkdir -p /home/csgo/.steam/sdk64 \
&& ln -s /home/csgo/Steam/linux64/steamclient.so /home/csgo/.steam/sdk64/steamclient.so

WORKDIR /home/csgo

COPY server.sh .

ENTRYPOINT ["/home/csgo/server.sh"]

84 changes: 84 additions & 0 deletions base-cs2/server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

set -e

shopt -s extglob

steam_dir="${HOME}/Steam"
server_dir="${HOME}/server"
server_installed_lock_file="${server_dir}/installed.lock"
cs2_dir="${server_dir}/game/csgo"
cs2_custom_files_dir="${CS2_CUSTOM_FILES_DIR-"/usr/csgo"}"


install() {
echo '> Installing or updating game files ...'

validate=""
if [ "${VALIDATE_SERVER_FILES-"false"}" = "true" ]; then
echo '> Validating game files ...'
validate="validate"
fi

$steam_dir/steamcmd.sh \
+force_install_dir $server_dir \
+login "${STEAM_USERNAME}" "${STEAM_PASSWORD}" \
+app_update 730 ${validate} \
+quit

echo '> Done'

touch $server_installed_lock_file
}

sync_custom_files() {
echo "> Checking for custom files at \"$cs2_custom_files_dir\" ..."

if [ -d "$cs2_custom_files_dir" ]; then
echo "> Found custom files. Syncing with \"${cs2_dir}\" ..."

set -x

cp -asf $cs2_custom_files_dir/* $cs2_dir # Copy custom files as soft links
find $cs2_dir -xtype l -delete # Find and delete broken soft links

set +x

echo '> Done'
else
echo '> No custom files found'
fi
}

start() {
echo '> Starting server ...'

additionalParams=""

if [ -n "$CS2_PW" ]; then
additionalParams+=" +sv_password $CS2_PW"
fi

set -x

exec $server_dir/game/bin/linuxsteamrt64/cs2 \
-dedicated \
-console \
-usercon \
-maxplayers_override "${CS2_MAX_PLAYERS-16}" \
+game_alias "${CS2_GAME_ALIAS-competetive}" \
+mapgroup "${CS2_MAP_GROUP-mg_active}" \
+map "${CS2_MAP-de_dust2}" \
+rcon_password "${CS2_RCON_PW-changeme}" \
$additionalParams \
$CS2_PARAMS
}

if [ ! -z $1 ]; then
$1
else
install
sync_custom_files
start
fi

0 comments on commit 5e62fba

Please sign in to comment.