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

User:Webb/New linux server: Difference between revisions

From TF2 Classified Wiki
Webb (talk | contribs)
No edit summary
Webb (talk | contribs)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
:''This is a WIP updated version of the Linux dedicated server article. I want to ask for feedback before moving out of my user namespace. The original article was adapted and revised from a guide written by Raizo, the original of which can be found here: https://blog.raizo.dev/posts/tf2-classic-linux-server-tutorial/''
:''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 20GB of free storage
* At least 20GB of free storage
* A minimum of a 10Mbps 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 10Mbps upload speed if you intend on hosting a server over the Internet, more will be needed if you host custom content
* An opened port on your firewall for the server
* ''Optional'': An SSH/SFTP client if doing remote access/file management
* ''Optional'': An SSH/SFTP client if doing remote access/file management
* ''Optional'': A port that's been forwarded for the server if you wish to have it accessible over the internet


<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 distros may use different package names and conventions.
Line 51: Line 53:
Pick a directory to install your server into. Many put it under a directory in <code>/opt</code>, but for this guide we'll be using <code>/home/srcds</code>.
Pick a directory to install your server into. Many put it under a directory in <code>/opt</code>, but for this guide we'll be using <code>/home/srcds</code>.


Create a disabled user with the home directory:
Create a disabled user with a home directory.


<pre>
<pre>
Line 80: Line 82:


If everything went well, <code>srcds</code> should be installed and you should be back at your user shell.
If everything went well, <code>srcds</code> should be installed and you should be back at your user shell.
Before we continue we'll need to fix some files.


== Installing TF2C ==
Valve changed some shared object file names in the SDK, but the objects included with our install of SDK 2013 have not adopted the new names.
 
Since these are simply renames, we can symlink them.  
We'll be downloading the archived verison of TF2C, since it's unlikely to get updates. You have the option of using TF2CDownloader, but we won't cover it here.
 
<pre>
$ wget https://wiki.tf2classic.com/archive/tf2classic-2.2.3.zip -O /tmp/tf2classic.zip
$ mkdir ~/sdk/tf2classic
$ cd ~/sdk/tf2classic
$ 7z x /tmp/tf2classic.zip && rm /tmp/tf2classic.zip
</pre>


This will downloaded the latest archive of TF2C, create its directory, and extract it. If extraction succeeds it will delete tf2classic.zip.
=== Symlinking improperly named shared objects ===
Valve changed some shared object file names in the SDK, but the objects included with our install of SDK 2013 have not adopted the new names.
Since these are simply renames, we can symlink them. We'll also do the same for TF2C's <code>server_srv.so</code> and SDK's <code>steamclient.so</code>.
'''Your server will not start without doing this.'''
'''Your server will not start without doing this.'''
Run the following commands to create the symlinks in the bin folder:


<pre>
<pre>
Line 114: Line 101:
$ ln -s vphysics_srv.so vphysics.so
$ ln -s vphysics_srv.so vphysics.so
$ ln -s soundemittersystem_srv.so soundemittersystem.so
$ ln -s soundemittersystem_srv.so soundemittersystem.so
$ cd ~/sdk/tf2classic/bin
$ ln -s server.so server_srv.so
</pre>
</pre>


Next, we'll symlink <code>steamclient.so</code> to a special directory to prevent bugs.
Finally, we'll also symlink <code>steamclient.so</code> to a special directory to prevent bugs.


<pre>
<pre>
$ mkdir -p ~/.steam/sdk32
$ mkdir -p ~/.steam/sdk32
$ ln -s ~/sdk/bin/steamclient.so ~/.steam/sdk32/
$ ln -s ~/sdk/bin/steamclient.so ~/.steam/sdk32/
</pre>
== Installing TF2C ==
We'll be downloading the archived verison of TF2C, since it's unlikely to get updates. You have the option of using TF2CDownloader, but we won't cover it here.
<pre>
$ wget https://wiki.tf2classic.com/kachemak/tf2classic.zip -O /tmp/tf2classic.zip
$ mkdir ~/sdk/tf2classic
$ cd ~/sdk/tf2classic
$ 7z x /tmp/tf2classic.zip && rm /tmp/tf2classic.zip
</pre>
This will download the latest archive, create its directory, and extract it. If extraction succeeds it will also delete the downloaded archive.
We'll also need to do a quick symlink in TF2C's bin folder.
<pre>
$ cd ~/sdk/tf2classic/bin
$ ln -s server.so server_srv.so
</pre>
</pre>


Line 145: Line 150:
Make sure the server type is set to “Internet and LAN” if you want players outside your LAN to be able to join (you may need to port forward if you’re on consumer broadband or open ports on your firewall).
Make sure the server type is set to “Internet and LAN” if you want players outside your LAN to be able to join (you may need to port forward if you’re on consumer broadband or open ports on your firewall).


Upload the generated ZIP file to your server using SFTP, unzip the folder using:
Upload the generated ZIP file to your server, perhaps using SFTP, and unzip the folder.


<pre>
<pre>
Line 223: Line 228:
# systemctl enable tf2c.service
# systemctl enable tf2c.service
</pre>
</pre>
You may create as many services as you have TF2C servers but remember to name the service files uniquely. When modifying service files, remember to run <code>systemctl daemon-reload</code> before restarting the service.


=== Automatic restarts using crontab ===
=== Automatic restarts using crontab ===


As root, execute <code>crontab -e</code>. This will open a special file in your editor where you can set cronjobs. For example, adding the following line will restart your game server every day at 04:00:
Cron is a program built into most Linux distros that runs scheduled commands.
 
As root, execute <code>crontab -e</code>. This will open a special file in your editor where you can declare what jobs you want to run and when. Let's add a job to run at 04:00 that will restart our server.


<pre>
<pre>
0 4 * * * systemctl restart tf2c.service
0 4 * * * systemctl restart tf2c.service
</pre>
</pre>
You may create as many services as you have TF2C servers but remember to name the service files uniquely, enable them in <code>systemctl</code>, and add them to the <code>crontab</code>. When updating service files, remember to run <code>systemctl daemon-reload</code> before restarting the service.


=== Manually managing services ===
=== Manually managing services ===