Skip to content

Deployment Overview of Counter-Strike 2 Server on Server

Prerequisites and Basic Requirements

The deployment of the Counter-Strike 2 server requires the following system specifications and privileges:

  • Operating System: Ubuntu (specifically utilizing the multiverse repository and support for i386 architecture).

  • Privileges: Root access or sudo privileges are required to install system packages, manage directories, and execute the server management script.

  • Dependencies: The steamcmd package must be installed via the apt package manager.

  • Network: Access to the internet is required for downloading the SteamCMD client and updating the game binaries.

File and Directory Structure

The application and its associated components are organized within specific directories on the server:

  • Installation Directory: /opt/cs2

  • Game Binaries and Data: /opt/cs2/game

  • Server Configuration: /opt/cs2/game/game/csgo/cfg/cs2server.cfg

  • Steam SDK Directory: /root/.steam/sdk64

  • Server Management Script: /root/cs2server.sh

  • Process ID File: /tmp/cs2server.pid

  • Log File: /var/log/cs2server.log

Application Installation Process

The installation process involves setting up the environment, installing SteamCMD, and downloading the Counter-Strike 2 server files.

  1. Repository Configuration: The multiverse repository is added to the APT sources, and the i386 architecture is enabled to support legacy dependencies.

  2. Package Installation: System packages are updated, and the steamcmd package is installed using apt.

  3. Directory Creation: The installation directory /opt/cs2 and the Steam SDK directory /root/.steam/sdk64 are created with 0755 permissions.

  4. SteamCMD Setup: The SteamCMD client is downloaded and extracted into /opt/cs2.

  5. Game Download: The Counter-Strike 2 server (Application ID 730) is downloaded and validated via SteamCMD using the force_install_dir command.

  6. Library Linking: The steamclient.so file is copied from /opt/cs2/linux64/ to /root/.steam/sdk64/ to ensure library compatibility.

  7. Configuration and Scripting: The server configuration file cs2server.cfg is deployed to /opt/cs2/game/game/csgo/cfg/, and the management script cs2server.sh is placed in /root/.

Docker Containers and Their Deployment

The deployment includes an Nginx container configured for SSL certificate management and proxying.

  • Container Image: jonasal/nginx-certbot:latest

  • Network Mode: The container runs in host network mode.

  • Volume Mounts:

  • nginx_secrets: An external volume mounted to /etc/letsencrypt.

  • /data/nginx/user_conf.d: Mounted to /etc/nginx/user_conf.d for custom user configurations.

  • Environment Variables:

  • CERTBOT_EMAIL: Set to [email protected].

  • Additional configuration is loaded from /data/nginx/nginx-certbot.env.

Proxy Servers

The Nginx container functions as the primary proxy server handling SSL termination and traffic routing.

  • Functionality: The container utilizes Certbot for automated SSL certificate management.

  • Secrets Management: SSL secrets are stored in the external Docker volume nginx_secrets.

  • Configuration: Custom Nginx configurations are expected to be placed in /data/nginx/user_conf.d on the host, which maps directly to the container.

Starting, Stopping, and Updating

Server operations are managed through the custom shell script located at /root/cs2server.sh. The script accepts the following arguments:

  • Start: Executes the server binary located at /opt/cs2/game/game/bin/linuxsteamrt64/cs2 with the -dedicated flag and loads the cs2server.cfg configuration. It runs in the background via nohup and writes the process ID to /tmp/cs2server.pid.

  • Stop: Reads the PID from /tmp/cs2server.pid, terminates the process, and removes the PID file.

  • Restart: Executes the stop command, waits for 2 seconds, and then executes the start command.

  • Status: Checks if the PID file exists and verifies if the process is currently running.

Commands to manage the service:

/root/cs2server.sh start
/root/cs2server.sh stop
/root/cs2server.sh restart
/root/cs2server.sh status

Permission Settings

File and directory permissions are set during the deployment process to ensure security and functionality:

  • Directory Permissions:

  • /opt/cs2: 0755

  • /root/.steam: 0755

  • /root/.steam/sdk64: 0755 (recursive)

  • File Permissions:

  • /opt/cs2/game/game/csgo/cfg/cs2server.cfg: 0755 (owner: root, group: root)

  • /root/cs2server.sh: 0755 (owner: root, group: root)

Location of Configuration Files and Data

The following paths contain critical configuration files and runtime data:

  • Server Configuration: /opt/cs2/game/game/csgo/cfg/cs2server.cfg

  • Management Script: /root/cs2server.sh

  • Nginx Environment: /data/nginx/nginx-certbot.env

  • Nginx User Configs: /data/nginx/user_conf.d

  • SSL Certificates: Managed within the nginx_secrets Docker volume.

  • Runtime Logs: /var/log/cs2server.log

  • Process ID: /tmp/cs2server.pid

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×