Dedicated legacy Linux server: Difference between revisions
From TF2 Classified Wiki
More actions
Added sectioning though this might be ugly |
Technochips (talk | contribs) m fixed headers |
||
| Line 1: | Line 1: | ||
''Note: This 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/'' | ''Note: This 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/'' | ||
= Prerequisites = | == Prerequisites == | ||
* A Linux server running Ubuntu Server<sup>*</sup> on an x86_64 CPU. You cannot easily run SRCDS on any other architecture besides an x86_64 CPU. Box64/Box86 may work for ARM processors (e.g. Raspberry Pis) but that's complex, and not covered here. | * A Linux server running Ubuntu Server<sup>*</sup> on an x86_64 CPU. You cannot easily run SRCDS on any other architecture besides an x86_64 CPU. Box64/Box86 may work for ARM processors (e.g. Raspberry Pis) but that's complex, and not covered here. | ||
* A SFTP/SSH client (PuTTY, Termius, FileZilla, MobaXterm) | * A SFTP/SSH client (PuTTY, Termius, FileZilla, MobaXterm) | ||
| Line 9: | Line 9: | ||
<sup>*</sup>'''Note''': This guide was written for and tested on Ubuntu Server 22.04 LTS, however any Debian-based distro should work similarly and fine using this guide. | <sup>*</sup>'''Note''': This guide was written for and tested on Ubuntu Server 22.04 LTS, however any Debian-based distro should work similarly and fine using this guide. | ||
== Reading this article == | === Reading this article === | ||
<!-- Originally from https://wiki.teamfortress.com/wiki/Linux_dedicated_server#Reading_this_article --> | <!-- Originally from https://wiki.teamfortress.com/wiki/Linux_dedicated_server#Reading_this_article --> | ||
This article has been written according to standard Linux terminal documentation syntax, meaning the following: | This article has been written according to standard Linux terminal documentation syntax, meaning the following: | ||
| Line 19: | Line 19: | ||
Some commands are listed in-line with the rest of a paragraph and lack this symbol, in which case you should run the command as whichever account you're currently logged in with. | Some commands are listed in-line with the rest of a paragraph and lack this symbol, in which case you should run the command as whichever account you're currently logged in with. | ||
== Creating a steam user for SteamCMD and Source SDK Base 2013 Dedicated Server == | === Creating a steam user for SteamCMD and Source SDK Base 2013 Dedicated Server === | ||
Pick a directory to install your server into. Industry standard is usually in <code>/opt</code>, but <code>/home</code> may be easier for you. If you want to use a directory in <code>/home</code>, omit the <code>-d</code> option as useradd will create a directory in <code>/home</code> with the user’s username, ours being <code>steam</code>. We’ll pick <code>/opt/tf2classic</code>. | Pick a directory to install your server into. Industry standard is usually in <code>/opt</code>, but <code>/home</code> may be easier for you. If you want to use a directory in <code>/home</code>, omit the <code>-d</code> option as useradd will create a directory in <code>/home</code> with the user’s username, ours being <code>steam</code>. We’ll pick <code>/opt/tf2classic</code>. | ||
| Line 31: | Line 31: | ||
<code>-m</code> creates a home directory for it, <code>-d /opt/tf2classic</code> specifies where our home directory will be, and <code>-s /usr/bin/bash</code> sets the shell to bash. | <code>-m</code> creates a home directory for it, <code>-d /opt/tf2classic</code> specifies where our home directory will be, and <code>-s /usr/bin/bash</code> sets the shell to bash. | ||
== Installing Source SDK Base 2013 DS, SteamCMD, and dependencies == | === Installing Source SDK Base 2013 DS, SteamCMD, and dependencies === | ||
The SteamCMD package is in the multiverse repos. TF2Classic and SteamCMD require i386 (32-bit) libraries to function. You also need 7-Zip to extract TF2Classic. | The SteamCMD package is in the multiverse repos. TF2Classic and SteamCMD require i386 (32-bit) libraries to function. You also need 7-Zip to extract TF2Classic. | ||
| Line 60: | Line 60: | ||
Give it a few, and when it’s finished we can run <code>exit</code>. | Give it a few, and when it’s finished we can run <code>exit</code>. | ||
= Downloading TF2 Classic = | == Downloading TF2 Classic == | ||
The fastest way to download TF2Classic is to use TF2CDownloader. | The fastest way to download TF2Classic is to use TF2CDownloader. | ||
| Line 77: | Line 77: | ||
<pre>mv tf2classic /opt/tf2classic/server/</pre> | <pre>mv tf2classic /opt/tf2classic/server/</pre> | ||
=== Server Configuration === | |||
Generate your server config(s) on [https://cfg.tf/ cfg.tf]. | Generate your server config(s) on [https://cfg.tf/ cfg.tf]. | ||
| Line 88: | Line 88: | ||
And merge the <code>cfg</code> folder with <code>/opt/tf2classic/server/tf2classic/cfg/</code>. | And merge the <code>cfg</code> folder with <code>/opt/tf2classic/server/tf2classic/cfg/</code>. | ||
== Create symlinks to missing shared objects. == | === Create symlinks to missing shared objects. === | ||
Valve changed some shared object file names in the SDK and the objects we’re given have not adapted to the new names. Since these are simply renames, we can symlink them. | Valve changed some shared object file names in the SDK and the objects we’re given have not adapted to the new names. Since these are simply renames, we can symlink them. | ||
'''Your server will not start without doing this.''' | '''Your server will not start without doing this.''' | ||
| Line 121: | Line 121: | ||
</pre> | </pre> | ||
= Running the server = | == Running the server == | ||
== Creating the server script == | === Creating the server script === | ||
Change into the server directory with: | Change into the server directory with: | ||
| Line 150: | Line 150: | ||
If you want it to run even after closing the terminal window, run <code>nohup ./runserver.sh &</code> followed by <code>disown</code> | If you want it to run even after closing the terminal window, run <code>nohup ./runserver.sh &</code> followed by <code>disown</code> | ||
== Systemd & Crontab for | === Systemd & Crontab for automated start, restart and updating === | ||
For easier automation of server restarts, updating, and booting alongside the system, you may use systemd, which is the default init system for most modern Linux distros and cronjobs. | For easier automation of server restarts, updating, and booting alongside the system, you may use systemd, which is the default init system for most modern Linux distros and cronjobs. | ||
| Line 205: | Line 205: | ||
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>. | 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>. | ||
=== Systemd | === Systemd manual start, stop, restart/update === | ||
If you don't wish to use the service files above to automatically boot servers, or you need to perform these actions for maintenance: you may issue commands to manually ''start'', ''stop'', ''restart'', or ''update'' the server(s) through systemd. | If you don't wish to use the service files above to automatically boot servers, or you need to perform these actions for maintenance: you may issue commands to manually ''start'', ''stop'', ''restart'', or ''update'' the server(s) through systemd. | ||