Quantcast
Channel: Dirty Motherfucking Blog » steam
Viewing all articles
Browse latest Browse all 2

Running a Source dedicated server (for Left 4 Dead)

$
0
0

For a while now I have been running some dedicated servers for Source games. Primarily Team Fortress 2. I lately switched those off in favor of Left 4 Dead servers. I was always looking for a way to improve my setup. At some point during my initial googleing I came across this article.
I based my startup script on the one in that article. But we’ll come back to that later. Let’s start with installation.
The initial steps are laid out perfectly on srcds.com. But I’ll list everything important in here as well.

As all of my administration articles (so far) this one is for Ubuntu Server 8.04.1.

Let’s start by adding a new user that will run our servers.

sudo adduser --disabled-login steam

Now to log in with the newly created user to install the servers. We need to switch the user as root as a normal user can not log into this account.

sudo su - steam

No we can install the HLDSUpdateTool.

wget http://www.steampowered.com/download/hldsupdatetool.bin
chmod +x hldsupdatetool.bin
./hldsupdatetool.bin
./steam

In case it will hang at “Checking bootstrapper version…” you can try to set a set of preferred content servers. You do that by creating a file called “steam.cfg” and adding the following line to it:

PreferredContentServerIDs = "id id id"

You can find the ids on http://store.steampowered.com/stats/content/ under “Individual Server Statisistics”. Look for Valve #NN servers and place the number of the servers you want to use inside the quotes. Then retry running steam.

Now we’ll install a game. Let’s start out with Left 4 Dead. If you want to see what games are available, run:

./steam -command list

This will also show you the correct game identifier for Left 4 Dead, which is l4d_full (left4dead was for the demo).

./steam -command update -game l4d_full -dir /home/steam

In case the installation process hangs you can also try setting the preferred content servers as mentioned above. Now, theoretically you’re good to go and you can start your server. But we’re gonna go a step further. I use a start script based on the article mentioned at the start of this article. Now let’s grab it.
But wait, in case you realize that you really don’t want to use any of my shitty scripts and that you just want to get a clean server running, in that case it can stilll be helpful to get the script. You see when you use my script and you start a profile it will print out the command line it used. That way you can build up your desired configuration according to this guide, then run the script and get the correct command line to run your server. Thus I still highly recommend getting the script.

wget http://www.dirty-motherfucker.org/blog/wp-content/uploads/2008/12/steamLauncher.sh
chmod +x steamLauncher.sh

The script allows to easily start and stop Source servers in the background. It also allows for several profiles for several games. So you can start all games through the same interface. I like it, if you don’t then maybe have a look at the original script.

So let’s create a profile for Left 4 Dead.

mkdir profiles
editor profiles/l4d.conf

Now, this is how a profile should look like:

longName                = Left 4 Dead - 1 instance      ; The name of this profile/game
gameName                = left4dead                     ; The name given by steam to the game (equals the foldername ex. cstrike|tf2|left4dead)
daemon                  = /home/steam/l4d/srcds_run     ; Usually srcds_run
updater                 = /home/steam/steam             ; Where is the updater located? (steam binary)
basePath                = /home/steam/l4d               ; The base path of the steam installation (this folder contains tf2/cstrike/left4dead folders)
userName                = steam                         ; What user the server should run as

serverName              = My L4D Server                 ; The name that will appear in the server browser
serverIp                = 11.222.33.111                 ; The IP address to bind the server socket to
serverPort              = 27010                         ; The first port to use for listening (will be treated as base port with forked l4d servers)
serverMap               = l4d_hospital01_apartment      ; The first map to load
serverMaxPlayers        = 4                             ; Maximum number of players allowed on the server
serverPriority          = 0                             ; Renice to set for the server process (-20 is high, 0 is normal, +19 is low)
forkCount               = 0                             ; How many instances to fork
additionalParams        = -nohltv -steamport 27960+## +clientport 25030+## +exec server##.cfg +sv_lan 0 ; Additional params to run the server with

Obviously in that profile you need to adjust at least the serverIp parameter. Now you can run that profile by typing.

./steamLauncher start l4d

Keep in mind though, this is not a state that we want to be comfortable with just yet. Nevertheless start it up and check if there is any trouble. If it comes up, attach to the screen session as the script tells you to.
In case you get an error saying “Cannot open terminal ‘/dev/pts/0′”, you can run “script /dev/null” and then attach to the session. There are other ways to resolve it. If you wanna find out about those they’re easy to find in Google ;)

Now, in the profile of Left 4 Dead in the additionParameters we also tell the server to execute a certain config file. Let’s create that one now.

editor l4d/left4dead/cfg/server01.cfg

In here we can now override the default map, difficulty and whatnot. For example:

hostname        My L4D Server - No Mercy - Normal Difficulty
map             l4d_hospital01_apartment
m_difficulty    normal

Setting the difficulty and map is almost pointless though as they can be changed by vote anyway. But I’m sure you can think of some other server variables that you might want to set. And this is the place to do it.

Now might be a good time to talk about forking with Left 4 Dead servers. Given that there are only 4 or 8 players on a Left 4 Dead server it’s almost a waste only running a single instance. That’s why you can fork multiple instances of servers. Let’s have a look at a Left 4 Dead profile modified to run 4 servers.

longName                = Left 4 Dead - 4 instances     ; The name of this profile/game
gameName                = left4dead                     ; The name given by steam to the game (equals the foldername ex. cstrike|tf2|left4dead)
daemon                  = /home/steam/l4d/srcds_run     ; Usually srcds_run
updater                 = /home/steam/steam             ; Where is the updater located? (steam binary)
basePath                = /home/steam/l4d               ; The base path of the steam installation (this folder contains tf2/cstrike/left4dead folders)
userName                = steam                         ; What user the server should run as

serverName              = My L4D Server                 ; The name that will appear in the server browser
serverIp                = 11.222.33.111                 ; The IP address to bind the server socket to
serverPort              = 27010                         ; The first port to use for listening (will be treated as base port with forked l4d servers)
serverMap               = l4d_hospital01_apartment      ; The first map to load
serverMaxPlayers        = 4                             ; Maximum number of players allowed on the server
serverPriority          = 0                             ; Renice to set for the server process (-20 is high, 0 is normal, +19 is low)
forkCount               = 4                             ; How many instances to fork
additionalParams        = -nohltv -steamport 27960+## +clientport 25030+## +exec server##.cfg +sv_lan 0 ; Additional params to run the server with

You can now also create server02.cfg, server03.cfg and server04.cfg in the l4d folder. This way you can start up each instance with a different map, difficulty, key, …
It remains a mystery to me how to properly send commands to the console with forked instances though. Although from what I read there are ways, but I just never had any luck with those. I also never had any luck with rcon. So basically when I play on my own servers I can’t do shit when someone is getting on my nerves. And we sure don’t want that!
So what do we do? We install SourceMod. It gives us a nice and easy way to kick players when they get on our balls. And we can be happy little server admins. During the installation of SourceMod it may be helpful to run only a single instance profile of Left 4 Dead so you can easily attach to the screen session and send of some commands to test your installation.
So let’s get to it!

First of all we require MetaMod. A very straight-forward guide can be found on the MetaMod Wiki. For completeness sake I’ll replicate the required information here though.

  1. Download MetaMod at http://www.metamodsource.net/
  2. Put it into the left4dead folder. (cd l4d/left4dead)
  3. tar xvzf mmsource-1.7.0.tar.gz (Filename might differ)
  4. In l4d/left4dead/addons create a file metamod.vdf and put the following into it:
    "Plugin"
    {
            "file"  "../left4dead/addons/metamod/bin/server_i486.so"
    }
    
  5. Go back into your home directory and restart your server (./steamLauncher restart l4d)
  6. Attach to the screen session and type “meta version”. Everything other than “Unknown command” is a good sign.

If the installation of MetaMod fails, refer to the MetaMod Wiki or bug me about it.

Now we’re gonna install SourceMod. Again a proper guide can be found at http://wiki.alliedmods.net/Installing_SourceMod.

  1. Grab one of the latest snapshots of SourceMod from http://www.sourcemod.net/snapshots-1.2.php
  2. Just like we did with MetaMod, put it into the l4d/left4dead folder.
  3. Extract it via tar xvzf sourcemod-1.2.0-hg2469.tar.gz (Filename may differ again)
  4. Go back into your home directory and restart your server (./steamLauncher restart l4d)
  5. Attach to the screen session and type “meta list”. You should see that SourceMod is loaded.

Now last but not least we need to set ourself up as an admin in SourceMod. We do that by editing

l4d/left4dead/addons/sourcemod/configs/admins_simple.ini

Right at the bottom we will now put the following line:

"STEAM_YOURID" "99:z"

If you’re like me then you’ll have no clue what your Steam ID is. So open up steam and connect to any server in any game. Then open up the console and type “status”. In the list that appears there should be your nick somewhere. And close to it, you’ll find your Steam ID.

Now you should be an admin on your Left 4 Dead servers. You can join your own servers easily by invoking “openserverbrowser” in the Left 4 Dead console. To enjoy being an admin it helps to bind “sm_admin” to some key. Then you can open the admin menu and kick those pesky players who just can’t stop running ahead to get themselves killed.

In case this isn’t clear. You’ll have to forward some ports for your servers to work. Which can easily be accomplished by adding two lines to your /etc/ufw/after.rules file. Similar to these two:

# Steam TF2 Server
-A ufw-after-input -d 11.222.33.111 -m udp -p udp --dport 26900:27040 -m conntrack --ctstate NEW,RELATED,ESTABLISHED -j ACCEPT
-A ufw-after-input -d 11.222.33.111 -m tcp -p tcp --dport 27000:27020 -m conntrack --ctstate NEW,RELATED,ESTABLISHED -j ACCEPT

I hope I haven’t left any open questions. In case I did, please let me know ;)


Viewing all articles
Browse latest Browse all 2

Trending Articles