Post

Setting up a TF2 server – Part 1

So I also host a small set of game servers for me to test plugins and maps out. Not to mention its also a simple way for me to say to a group of friends lets go play this and have a place to go without the hassle of looking for a server. Normally I would tell people to install LGSM when they want to setup a gameserver. I though have run into a few issues where LGSM is a tad constricting for my needs now. So off to setting the server up from scratch and trying to replicate a couple of features from LGSM.

So for this part, setup the server in a raw form.

Prepare the system as TF2 servers run as 32-bit

1
2
3
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install mailutils util-linux byobu tmux lib32gcc1 libstdc++6 libstdc++6:i386 libcurl4-gnutls-dev:i386

Always a good idea to run things as a user and not root, so lets add a user and login as it.

1
2
sudo adduser tf2-server
sudo login -f tf2-server

Now that we are in the user account lets download the server. First we need to download steamcmd.

1
2
3
4
mkdir steamcmd
cd steamcmd
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
tar zxf steamcmd_linux.tar.gz

Create a steamcmd file and run it.

1
2
3
4
5
6
7
8
cd /home/tf2-server
echo tf2_ds.txt <<EOF
login anonymous
force_install_dir /home/tf2-server/srcds
app_update 232250
quit
EOF
./steamcmd.sh +runscript tf2_ds.txt

Now to create a launcher script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cd /home/tf2-server/srcds
echo launcher.sh <<EOF
#!/bin/bash
OPTS="-console -debug"
OPTS="$OPTS -game tf +sv_pure 1 -secured -timeout 3"
OPTS="$OPTS +ip 0.0.0.0 -port 27015"
#OPTS="$OPTS +map ctf_2fort"
OPTS="$OPTS +randommap"
OPTS="$OPTS +maxplayers 32"
OPTS="$OPTS -autoupdate -steam_dir /home/tf2-server/srcds/ -steamcmd_script /home/tf2-server/steamcmd/tf2_ds.txt"
OPTS="$OPTS +sv_shutdown_timeout_minutes 40"
./srcds_run $OPTS
EOF
chmod +x launcher.sh

At this point it is possible to launch the server.

1
./launcher.sh
This post is licensed under CC BY 4.0 by the author.