Team Fortress 2

Team Fortress 2

Not enough ratings
Pre-Fortress 2: Linux Dedicated Server Setup
By sour dani
This is a guide on how to start a Source Dedicated Server in Linux for Pre-Fortress 2!

Based off the Open Fortress Linux Server guide[web.archive.org]
Newer additions reference TF2Classic Wiki[wiki.tf2classic.com]
   
Award
Favorite
Favorited
Unfavorite
Introduction

This guide is for the game mod Pre-Fortress 2 a mod inspired by the beta of TF2 that uses Source SDK Base 2013 Multiplayer.

Feel free to give feedback in the comments!
1. Software requirements: Package Dependencies
Dependencies:
  • On 64-bit Ubuntu / Debian based distros run:
    sudo dpkg --add-architecture i386; sudo apt update; sudo apt install lib32gcc-s1 libstdc++6 libstdc++6:i386 libncurses6:i386 libtinfo6:i386 libcurl4-gnutls-dev:i386 unzip curl
  • On 32-bit Debian based distros run:
    sudo apt install libstdc++6 libncurses6 libtinfo6 libcurl4-gnutls-dev unzip curl
  • On Arch Linux run:
    sudo pacman -Syy lib32-gcc-libs gcc-libs lib32-ncurses lib32-libcurl-gnutls unzip curl
  • On Fedora run:
    sudo dnf install libgcc.x86_64 libgcc.i686 glibc.i686 libstdc++.x86_64 libstdc++.i686 ncurses-libs.i686 libcurl.i686 unzip curl
2. Creating a user for hosting SDK13 Dedicated Servers
It's important to separate your services based on type, for this guide we will be creating a new user that's directly responsible for Source SDK Base 2013 Dedicated Servers.

Create a user with that home directory and give it a strong password:
useradd -m steam passwd steam

Now switch over to the steam user before continuing this guide.
su - steam
3. Install Steam CMD for Linux
Next, download the linux SteamCMD Tar archive and unpack it

You can now run steamcmd with
./steamcmd.sh
And exit it with
quit
4. Install Source SDK 2013
For automation and ease of use's sake, we'll be using auto-update scripts to ease the updating process.

While still in the /home/steam directory, create a file named fullupdate.txt with the following contents:
@ShutdownOnFailedCommand 1 @NoPromptForPassword 1 login anonymous force_install_dir ./sdk app_update 244310 -beta previous2021 quit

And now to install the necessary Source SDK 2013 MP files using that newly created script, run that script in steamcmd once with the following command:
./steamcmd.sh +runscript fullupdate.txt
This will install the necessary files in directories named /sdk/.
5. Download PF2
Go into the folder named /sdk/ from the previous step, and run this one-liner:
This will download a copy of the latest files on the official Pre-Fortress 2 repository.
6. Final links
Go into the /sdk/ directory and from there go into the /bin/ directory.
And in /sdk/bin paste & run these commands:
ln -s datacache_srv.so datacache.so && \ ln -s dedicated_srv.so dedicated.so && \ ln -s engine_srv.so engine.so && \ ln -s materialsystem_srv.so materialsystem.so && \ ln -s replay_srv.so replay.so && \ ln -s scenefilecache_srv.so scenefilecache.so && \ ln -s shaderapiempty_srv.so shaderapiempty.so && \ ln -s soundemittersystem_srv.so soundemittersystem.so && \ ln -s studiorender_srv.so studiorender.so && \ ln -s vphysics_srv.so vphysics.so && \ mv libstdc++.so.6 libstdc++.so.6.old

And go to the /sdk/pf2/bin directory and run this command:
ln -s server.so server_srv.so
This will create necessary file links for files that don't exist but should be there.
7. How to start the server
And that's all. Wasn't so hard, was it?
Now, how to run a server.

Create a script to run your server in the /sdk/ directory, name it something like run-pf2.sh. Here's a sample server run script.
#!/bin/sh ./srcds_run -console -game pf2 +maxplayers 24 +map ctf_2fort
Make it executable with
chmod +x run-pf2.sh
Change the launch parameters of the script (whatever is after "./srcds_run") to your heart's content. Remember to keep -console -game pf2 though.
8. Auto updating
It's important to keep your gameserver updated, otherwise players who update their local copies will eventually encounter problems or won't be able to play on your server at all.

To update TF2 and and SDK 2013 automatically, place the following in the front of your launch parameters in /sdk/run-pf2.sh:
-autoupdate -steam_dir ../ -steamcmd_script fullupdate.txt

We will create a bash script that will check the current version of the install PF2 and compare it to the current verison.

Make a new file called update-pf2.sh.
#!/usr/bin/env bash # Updates Pre-Fortress 2. download_game() { echo "Downloading game." cd sdk curl https://dl.prefortress.com/latest/version.txt > ./version.txt echo "Removing any leftover game files." rm -f latest.tar.gz # Downloads latest tarball from the latest archive. wget https://dl.prefortress.com/latest/latest.tar.gz -O latest.tar.gz tar -xzf latest.tar.gz cd .. } if test -d "./sdk/pf2/"; then if test -f "./sdk/version.txt"; then content=$(curl https://dl.prefortress.com/latest/version.txt) if grep -Fxq "$content" ./sdk/version.txt; then echo "Matching version, no need to update." else echo "Update Detected." download_game fi else echo "No verbose version text detected." download_game fi else echo "No PF2 Installation exists." download_game fi echo "Install complete, exiting."
9. Run the server in the background
Next, create a service file in /etc/systemd/system/

Example pf2.service:

[Unit] Description=PF2 Server After=network-online.target Wants=network-online.target [Service] Type=forking User=steam WorkingDirectory=/home/steam RemainAfterExit=yes ExecStartPre=/home/steam/update-pf2.sh ExecStart=/home/steam/run-pf2.sh TimeoutStartSec=infinity Restart=always [Install] WantedBy=multi-user.target

Then, enable the service to start with the init system:
sudo systemctl enable pf2.service sudo systemctl start pf2.service

Next, switch to the root user using sudo su and execute crontab -e. This is where you can set cronjobs, include something like the following:
# Restart and update check for PF2 every day at 4 AM. 0 4 * * * systemctl restart pf2.service

You may create as many services as you have PF2 servers but remember to name the service files uniquely, enable them in systemctl, and add them to the crontab.

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, diable or update the server(s) through systemd
10. Server settings and configuration
Whatever comes out of the box doesn't have to be your server forever! Pre-Fortress 2 and the Source engine have a LOT of server settings that can change how your server works, what gamemodes it runs etc.


To change them, create a file named server.cfg if it doesn't exist in the ~/sdk/pf2/cfg/ directory and edit it with your custom Convars (Console Variables), which control the server's functionality.
A few notable Convars:
// Changes your server's name visible in the server browser. hostname "Super Shotgun Universe" // Sets your RCON password to allow for remote console command execution on the server. // DO NOT SHARE THIS! This grants anyone who has the password control over your server! rcon_password "thisPasswordShouldBeVeryLongAnd_c0mpl1c4t3d!@#$" // Set to 1 to make your server LAN-only. Keep at 0 otherwise. sv_lan 0 // Time per map in the rotation, in minutes. 0 to never rotate the map on a timer. mp_timelimit 10 // Maximum number of rounds to play per map before forcing a mapchange mp_maxrounds 1 // Allow clients to upload customization files (e.g. sprays) sv_allowupload 1 // Allow clients to download files (e.g. sprays, custom maps, custom content, etc.) sv_allowdownload 1 // Maximum allowed file size for uploading in MB (Optional) net_maxfilesize 15
Type pf_ inside the in-game console to find configs you prefer on your server.
Documentation on PF2 specific convars is currently only available for internal use at this time.

There are also launch parameters, settings that only can be applied on server start. They are the settings with dashes (-) or pluses (+) visible after
./srcds_run
In your run-pf2.sh file. Change any launch parameters over there.
Launch parameters with pluses (+) instead of dashes (-) are console commands that will be executed on server start but can also be run while the server is running. Parameters with minuses cannot. These launch options have to go inside your run-pf2.sh file.
Most popular launch parameters:
// Sets your server's max player connected limit. +maxplayers 24 // Bind the server to a different port (27015 is the default) -port 27015 // Disables VAC. -insecure // Timeout before the server restarts if it crashes. Only works if you have // the -autoupdate parameters from the previous step. -timeout 0 // Disables SourceTV functionality on your server - may reduce RAM used by the server. -nohltv // The map that the server starts with. Use the changelevel command if the // server is already running instead of map. +map ctf_badlands
11. SourceMod Plugins
Requirements
To install source mod and start adding plugins, you need 4 things
  • MetaMod 1.11.1155
  • Source Mod 1.11.6502 (No other version)
  • PF2-Tools (Very important)
  • DHooks SM110 (Required)
In this tutorial we will be installing the release of PF2-Tools that already includes these files.

On your server in the sdk directory execute this code to download:

On your server in the sdk directory execute this code to install:
unzip -o PF2-Tools-Linux.zip -d pf2

If done correctly you've now installed Source Mod for Pre-Fortress 2!
12. (Optional) Using GitHub/GitLab as FastDL Server
If your server uses custom maps and you want your players to be able to download the maps quickly.

Made by Cyanide originally for use with TF2Classic
Compatible with any Source Mod.

If you're using GitLab please follow this guide

Code from the Video
server.cfg
sv_allowdownload 1 sv_allowupload 1 sv_downloadurl "https://USERNAME.github.io/fast-dl/pf2"

index.html
<!doctype html> <html> <body> <p>This is a blank webpage.</p> </body> </html>
13. (Optional) Running multiple servers off the same installation
If you intend to run multiple server of the same installation of Pre-Fortress 2, you can do this very easily by creating a new service, update, and run script. We will also utilize a unique exec, servercfgfile, mapcyclefile, and motdfile.

First, in your /pf2/cfg directory, create a file called unique_id_server.cfg. You don't have to use the word "unique_id" but you should call it something that uniquely identifies the server. Now add in all of your usual server.cfg settings.

Next, in your /pf2/cfg directory, create a file called unique_id_mapcycle.txt. In this file you can store the map rotation of the given server. For instance if you want to create a custom maps server using maps you've placed in your /pf2/custom/coolservermaps folder. Simply list the name of the map file such as: ad_dustbowl, tc_hydro, etc.

After that, create a unique MOTD file in your /pf2/cfg directory. The file name should be unique_id_motd.txt. In here you can leave a special message to people who play your server or link to a webpage. This can help distinguish your maps from one another.

Now lastly and optionally you can choose to store which map is chosen at the beginning of the game in a config file that will be executed before everything else. Rather than writing
+map koth_crossover
In the server start command line, you can instead create a config file that simply runs whatever map you want to put in it. That way you don't have to change the run script, just the starting map config.
Simply create unique_id_map.cfg file in you /pf2/cfg folder and add:
map koth_crossover

Now copy your existing run-pf2.sh and give the new one a unique name, unique_id-run-pf2.sh and at the end of the run command add the following commands
+exec unique_id_map.cfg +servercfgfile unique_id_server.cfg +mapcyclefile unique_id_mapcycle.txt +motdfile unique_id_motd.txt
If you did not create a unique_id_map.cfg you can skip adding that line.
Outro
Your server should be ready to have hours of Pre-Fortress 2 fun!
Please share your servers with us on the Discord![discord.gg]
Check the latest version of the URL link on the Pre-Fortress 2 website[http//hhttps]

For any troubleshooting please visit our Discord!
Troubleshooting!
Please check our Discord server[discord.gg] first before posting your errors here. We are more likely to get to your questions there!

Please also look at the OF Linux Server guide[web.archive.org] we referenced, as your problem might have already been solved in their troubleshooting section.

  • My server didn't start!
    Make sure you followed the instructions exactly as specified. Look over your files to see if you put any binaries in the wrong folder when doing the "Final Links" step.

  • error=bin/libstdc++.so.6: version `CXXABI_1.3.8' not found
    If you are experiencing an error that looks like this:
    failed to dlopen /home/steam/sdk/pf2/bin/server_srv.so error=bin/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/steam/sdk/pf2/bin/server_srv.so) Segmentation fault (core dumped)
    PF2 0.7 has an updated C++ toolset not used in 0.6 and therefore you need to run
    mv libstdc++.so.6 libstdc++.so.6.old

13 Comments
sour dani  [author] 3 Jul @ 12:34pm 
thank you bestie
λNTICITIZEN_1 2 Jul @ 8:39pm 
FYI, libncurses5 is now deprecated and replaced with libncurses6
Asterisk 24 Feb @ 3:55am 
It literally says to do that in the PF2-tools README.
sour dani  [author] 24 Feb @ 12:15am 
I'll take a look at that soon, thanks for the suggestion!
Asterisk 23 Feb @ 5:56pm 
*and metamod
Asterisk 23 Feb @ 5:56pm 
Also from my testing, you can use sourcemod 1.12 with the pre-fortress 2 plugin and gamedata instead of the PF2-tools zip.
sour dani  [author] 23 Feb @ 2:36pm 
Corrected, thanks!
Asterisk 23 Feb @ 12:24pm 
update-pf2.sh is misaing a semicolon on line 29 at [code]if test -f "./sdk/version.txt" else[/code]
psychpayload 22 Feb @ 8:46pm 
oh okay thanks
sour dani  [author] 22 Feb @ 7:53pm 
The download link subdomain was outdated. It has been updated to:
https://dl.prefortress.com/latest/latest.tar.gz