Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Dedicated Linux server: Difference between revisions

From TF2 Classified Wiki
Webb (talk | contribs)
No longer necessary to symlink server.so
Webb (talk | contribs)
No edit summary
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
:''This article is based on a guide written by Raizo, the original of which can be found [https://blog.raizo.dev/posts/tf2-classic-linux-server-tutorial/ here].''
{{Ambox|contents=This article is based on a guide written by Raizo, the original of which can be found [https://blog.raizo.dev/posts/tf2-classic-linux-server-tutorial/ here].}}


== Reading this article ==
== Reading this article ==
Line 16: Line 16:
* At least 25GB of free storage
* At least 25GB of free storage
* A minimum of a ten megabit upload speed if you intend on hosting a server over the Internet, more will be needed if you host custom content
* A minimum of a ten megabit upload speed if you intend on hosting a server over the Internet, more will be needed if you host custom content
* ''Optional'': An opened port on your firewall for the server if you want a persistent IP address (see [[#Disabling the Steam Datagram Relay|this section on disabling the Steam Datagram Relay]])
* An opened port on your firewall for the server if you want a persistent IP address (unless using SDR, see [[#Enabling the Steam Datagram Relay|this section on enabling the Steam Datagram Relay]])
* ''Optional'': An SSH/SFTP client if doing remote access/file management
* ''Optional'': An SSH/SFTP client if doing remote access/file management


<sup>*</sup> This guide was written for and tested on Ubuntu Server 24.04 LTS Minimal. Other distros may use different package names and conventions.
<sup>*</sup> This guide was written for and tested on Ubuntu Server 24.04 LTS Minimal. Other Linux distributions may use different package names and conventions.


<sup>**</sup>Architectures other than amd64 (including 32-bit x86) are not supported. Using an x86 compatibility layer like Box86 for another architecture may not work.
<sup>**</sup>Architectures other than amd64 (including 32-bit x86) are unsupported. Compatibility layers like FEX or Box64 may not work or cause unexpected problems.


== Preparing for install ==
== Preparing for install ==
Line 89: Line 89:
</pre>
</pre>


=== Fixing libraries with symlinks ===
Before continuing, we'll need to symlink the install's <code>steamclient.so</code> to a special directory.
 
Next we'll need to make some symlinks, since there's some issues with the installed libraries. Your server
will not run unless these steps are followed.
 
First, let's remove the existing libvstdlib.so and replace it with a symlink
 
<pre>
$ cd ~/classified/bin/linux64
$ rm libvstdlib.so
$ ln -s libvstdlib_srv.so libvstdlib.so
</pre>
 
We'll also need to symlink one of SteamCMD's libraries to a special Steam directory. Note that
it's not from within the bin folder.


<pre>
<pre>
Line 110: Line 96:
</pre>
</pre>


== Testing the server ==
=== Testing the server ===


Before proceeding, we can manually run the server to make sure the install was successful.
Before proceeding, we can manually run the server to make sure the install was successful.
Line 116: Line 102:
<pre>
<pre>
$ cd ~/classified
$ cd ~/classified
$ ./srcds.sh -tf_path ~/tf +map ctf_2fort +sv_password changethis
$ ./srcds.sh -port 27015 -tf_path ~/tf +map ctf_2fort +sv_password changethis
</pre>
</pre>


Line 208: Line 194:
ExecStartPre=-/usr/games/steamcmd +runscript /home/srcds/bin/update-classified.steamcmd
ExecStartPre=-/usr/games/steamcmd +runscript /home/srcds/bin/update-classified.steamcmd
Environment="LD_LIBRARY_PATH=".:bin/linux64:$LD_LIBRARY_PATH""
Environment="LD_LIBRARY_PATH=".:bin/linux64:$LD_LIBRARY_PATH""
ExecStart=/usr/bin/script -e -c "/home/srcds/classified/srcds_linux64 -tf_path /home/srcds/tf +map ctf_2fort +maxplayers 24" /dev/null
ExecStart=/usr/bin/script -e -c "/home/srcds/classified/srcds_linux64 -port 27015 -tf_path /home/srcds/tf +map ctf_2fort +maxplayers 24" /dev/null
TimeoutStartSec=infinity
TimeoutStartSec=infinity
Restart=always
Restart=always
Line 248: Line 234:
== Extras ==
== Extras ==


=== Disabling the Steam Datagram Relay ===
=== Enabling the Steam Datagram Relay ===
 
Servers can use the Steam Datagram Relay. It masks your server's IP address, helps prevent DDoS attacks, and allows you to run a server without port forwarding or configuring firewalls. However, this comes at the cost of added latency and using ephemeral IP addresses for your server, the latter breaking server favoriting and IP bans.
 
You can enable this by adding <code>sv_use_steam_networking 1</code> to <code>classified/tf2classified/cfg/default.cfg</code>.
 
If you want your server to appear on the server browser with SDR enabled you will need to supply a GLST token. You can acquire a key by going to [https://steamcommunity.com/dev/managegameservers this page]. Once you've got it, put <code>sv_setsteamaccount $KEY</code> in your configuration, replacing $KEY with the token from the page.
 
=== Installing SourceMod ===
 
SourceMod is a server modding platform that provides admin tools, permissions, and plugin support. Installing it is strongly recommended if you plan to run a publicly-facing server.
 
You'll need to install the '''a development version''' of SourceMod, as well as MetaMod which SourceMod depends on to work. '''It will not work with stable releases currently'''. As of writing this article, the latest known working development build is 7301 and 1389 respectively.
 
<pre>
$ cd ~
$ wget https://mms.alliedmods.net/mmsdrop/2.0/mmsource-2.0.0-git1389-linux.tar.gz -O /tmp/mm.tar.gz
$ wget https://sm.alliedmods.net/smdrop/1.13/sourcemod-1.13.0-git7301-linux.tar.gz -O /tmp/sm.tar.gz
$ tar -xf /tmp/mm.tar.gz
$ tar -xf /tmp/sm.tar.gz
$ mv addons ~/classified/tf2classified
$ mv cfg/sourcemod ~/classified/tf2classified/cfg
$ rm -r cfg
$ rm /tmp/mm.tar.gz
$ rm /tmp/sm.tar.gz
</pre>
 
Once the server starts it should work. A good way to test if everything is running properly is to use the <code>!motd</code> command in chat. If the MOTD pops up after the command that means SourceMod is working. For further information on setting up SourceMod, read [https://wiki.alliedmods.net/Category:SourceMod_Documentation the documentation].
 
Existing SourceMod plugins are not guaranteed to work and may require special steps or patching to get working.
 
==== Installing the patched TF2 Tools extension ====
 
Many plugins depend on the built-in TF2 Tools extension that comes with Sourcemod. This isn't compatible with TF2C. Instead, we can use a patched version of the extension which enables the use of many plugins.
 
There's currently no public download link for this extension. After joining the Team Fortress 2 Classified Discord server you can find the files you need in [https://discordapp.com/channels/196337717267791874/1011914229307166780/1467172013637636327 this message]. Specifically, you need <code>game.tf2.ext.2.tf2.so</code> and <code>sm-tf2.games.txt</code>.
 
First, we'll need to disable automatic game data updating to prevent our gamedata file from being removed.
 
<pre>
$ nano ~/classified/tf2classified/addons/sourcemod/configs/core.cfg
</pre>
 
Replace <code>"no"</code> in this part of the file with <code>"yes"</code>
 
<pre>
        /**
        * Enables or Disables SourceMod's automatic gamedata updating.
        *
        * The default value is "no". A value of "yes" will block the Auto Updater.
        */
        "DisableAutoUpdate"                    "no" // Change to "yes"
</pre>
 
Next we'll add both the gamedata file and the plugin to our installation.
 
<pre>
$ mv $WHEREVER_YOU_PUT_IT/sm-tf2.games.txt ~/classified/tf2classified/addons/gamedata/sm-tf2.games.txt
$ mv $WHEREVER_YOU_PUT_IT/game.tf2.ext.2.tf2.so ~/classified/tf2classified/addons/extensions/x64
</pre>


By default, the dedicated server will use the Steam Datagram Relay. It masks your server's IP address, helps prevent DDoS attacks, and allows you to run a server without port forwarding or configuring firewalls. However, this comes at the cost of added latency and using ephemeral IP addresses for your server, the latter breaking server favoriting.
Finally, create an empty file so that the extension is automatically loaded.


You can disable this by adding <code>sv_use_steam_networking 0</code> to <code>classified/tf2classified/cfg/default.cfg</code>. You should also manually assign a port to the server by adding the <code>-port</code> argument to the server launch command. You will need the assigned port forwarded in your router and allowed in your firewall.
<pre>
$ touch ~/classified/tf2classified/addons/sourcemod/extensions/game.tf2.autoload
</pre>


== Troubleshooting ==
== Troubleshooting ==
Line 258: Line 305:
=== Sounds are missing/only stock weapons are usable ===
=== Sounds are missing/only stock weapons are usable ===


This is due to a missing <code>libvstdlib.so</code> symlink. Ensure that it's symlinked properly.
This is likely due to a problem with <code>libvstdlib.so</code>. It's possible it wasn't updated or is corrupted. Validate your install.


<pre>
<pre>
$ cd ~/classified/bin/linux64
$ cd ~
$ rm libvstdlib.so
$ . /etc/environment
$ ln -s libvstdlib_srv.so libvstdlib.so
$ steamcmd
Steam>force_install_dir /home/srcds/classified
Steam>login anonymous
Steam>app_update 3557020 validate
Steam>quit
</pre>
</pre>
=== Server not showing up on the server browser while using SDR ===
This is likely happening because you enabled use of the SDR but didn't supply a game key. Read [[#Enabling the Steam Datagram Relay|the last paragraph of this section]] for more information.
=== Server using high levels of CPU when ran via the service file ===
The service file included in this guide has a workaround for Source servers refusing to log without a TTY present. There has been at least one report of this causing unusually high CPU usage. It's believed this happens on servers with slower SSDs and spinning hard drives. You can disable it, but it will mean there will be no journald logs for your server and you can't use features like Systemd sockets.
To disable it, unwrap the <code>srcds_linux64</code> command from <code>script</code>.
<pre>ExecStart=/usr/bin/script -e -c "/home/srcds/classified/srcds_linux64 -port 27015 -tf_path /home/srcds/tf +map ctf_2fort +maxplayers 24" /dev/null</pre>
<pre>ExecStart=/home/srcds/classified/srcds_linux64 -port 27015 -tf_path /home/srcds/tf +map ctf_2fort +maxplayers 24</pre>


[[Category:Guides]]
[[Category:Guides]]