Generic Gaming Server Setup

From Scottworld
Jump to navigation Jump to search

Add a gaming server and set its home directory to be where the servers are

adduser --disabled-login gameadmin
usermod -d /srv/data/gameservers/ gameadmin

Make your gaming directories and set permissions etc.

 gameadmin@solaris:/srv/data/gameservers$ ls -la
 total 16
 drwxrwx--- 4 gameadmin gameadmin 4096 Aug  6 17:29 .
 drwxr-xr-x 8 root      root      4096 Aug  6 17:28 ..
 drwxrwx--- 2 gameadmin gameadmin 4096 Aug  6 17:29 7d2dserver
 drwxrwx--- 2 gameadmin gameadmin 4096 Aug  6 17:28 Steam      <--- Make this a capital "S"

 chown gameadmin:gameadmin gameservers/ -R
 chmod 770 gameservers/ -R

Install Steam Client

Steam requires this install

sudo dpkg --add-architecture i386
apt install lib32gcc1 libsdl2-2.0-0:i386

Become the gaming account

su gameadmin

Move to the newly created steam directory Download the SteamCMD executable.


Run steam, login and check for errors

login <username <password>

Install a server from steam

Run the steam cmdline client


Login and set directory

login <username> <password>
force_install_dir ../gameserverdirectory
app_update <stream app id>

Create a launcher config file (in the scripts directory)


Set the environment variables as per this template (make all references fully qualified)

CMDLINE="/srv/data/gameservers/7d2dserver/ -configfile=/srv/data/gameservers/7d2dserver/serverconfig.xml"

Install the master launcher script.


# =====================================================================
# Script to lauch multiple command-line game servers
# V1.00 2020-08-06 Initial Release (ISM)
# =====================================================================

echo "Games server startup script starting to read $_gfiles"

for g in $_gfiles
        echo "Processing file: $g"
        source $g

        if [ $ENABLED != "true" ]; then
                echo "$SCREEN_NAME: disabled - skipping"

        screen -ls | grep "$SCREEN_NAME" &> /dev/null
        if [ $? == 0 ]; then
                echo "$SCREEN_NAME: already running - skipping"

        echo "$SCREEN_NAME: Changing directory to $GAMEDIR"
        cd $GAMEDIR

        echo "$SCREEN_NAME: Launching game..."
        screen -d -m -S $SCREEN_NAME $CMDLINE

Set permissions on the launcher (make it executable)

chown gamesadmin:gameadmin
chmod 770

Make the Game Launcher start on boot. Use your favourite editor to make a new file called game_launcher.service in /etc/systemd/system/.

nano /etc/systemd/system/game_launcher.service

Description=Game Server Launcher service



Once you are done, save the file and close the editor. Now we will activate the script so that it will start on boot. This makes to systemd recognize the file we just created.

systemctl --system daemon-reload

Enable the service. (optional if you want all the servers to launch on boot)

systemctl enable game_launcher.service

Or you can control it via a terminal using

systemctl start game_launcher.service

Once you've started the server, you can check that it's running with this command.

systemctl status game_launcher.service

Note running multiple times is not a problem (as the launcher checks for currently running screens)