[Guide] How to set up a dedicated server


Legions Developer
This guide has been requested quite a bit so here's a quick guide on one way of running a legions dedicated server. In this example I'll be using Debian 7 x32 and I'll assume you've ssh'd (if it's a remote server) or opened a terminal (if it's a box you own) as root.

Anything in this font is a command you have to run.

1. Install required programs

First we're going to update the package list using:

apt-get update

then we'll make sure the systems up to date:

apt-get upgrade

and install some of the programs we're going to be using (some systems might already have these installed but it's good to make sure)

apt-get install wget unzip screen sudo rsync

2. Set up an account to run legions

It's a bad idea to run your services under root so we're going to make our server an account named legions.

useradd -m -d /var/legions -s /bin/bash legions

and we don't want an account without a password on our machine so we'll give it a pass:

passwd legions

It should prompt you to type and confirm a password

3. Getting legions onto the server

We'll pull legions using rysnc into the folder /var/legions:

rsync -a --stats --progress --compress rsync.legionsoverdrive.com::live /var/legions

and we need to give ownership of the files to our legions account so we'll use the change ownership command:

chown -R legions:legions /var/legions

4. Changing the preferences:

Let's change directory to where our server preferences are:

cd /var/legions/server/preferences

We need some preferences that are common across any server you want to run so we will copy the default preferences into a new file:

cp defaultPrefs.cs prefs.cs

Now we need to edit this file, for that you could use the text editor nano:

nano prefs.cs

You should be greeted with a very simple text editor.

Here we can add any admin information for the servers into the top of the file. You must have the first 6 admins (from Admin[0] to Admin[5]) increasing in level along with index so it would look something like this:

$Host::Admins::Name[0] = "Player";
$Host::Admins::Level[0] = 0;
$Host::Admins::Password[0] = "";

$Host::Admins::Name[1] = "A Pug Admin";
$Host::Admins::Level[1] = 1;
$Host::Admins::Password[1] = "password";

$Host::Admins::Name[2] = "A Moderator";
$Host::Admins::Level[2] = 2;
$Host::Admins::Password[2] = "password";

$Host::Admins::Name[3] = "An Admin";
$Host::Admins::Level[3] = 3;
$Host::Admins::Password[3] = "password";

$Host::Admins::Name[4] = "A Super Admin";
$Host::Admins::Level[4] = 4;
$Host::Admins::Password[4] = "password";

$Host::Admins::Name[5] = "An Owner";
$Host::Admins::Level[5] = 5;
$Host::Admins::Password[5] = "password";
But after that the next admins can have any level, keeping in mind that 1 - pug admin, 2 - moderator, 3 - admin, 4 - super admin and 5 - owner.

Once you are done you can press {Ctrl} + X to save. Then if it asks if you want to overwrite type Y and accept the file name by pressing {Enter}.

Now we set up the configuration for each specific server: copy the template config into a new file (deleting the first 49 lines) using this command: (You can change ctf1.cs and do it multiple times if you want more than one server to run.)

sed "1,49d" config.cs > ctf1.cs

then we can edit this config file, again with nano.

nano ctf1.cs

Here you'll want to change $Host::Name to whatever you want your server to be called and $Host::BroadcastMaster to true.

Save it the same as last time: {Ctrl} + X -> Y -> {Enter}

4. Set the server up to automatically start

Now we need to go to a different directory, the directory for initialization scripts:

cd /etc/init.d/

I've prepared a standard init script and put it on the web so we can get that and name the output file legions:

wget -O legions http://code.xzanth.com/snippets/1/raw

We might want to make some modifications to this so we'll open it up with nano again:

nano legions

If we go down to where it says:
SERVER[0]='ctf1' # INSERT NAMES OF SERVERCONFIG.CS FILES HERE so you would put this if you had a file server/preferences/ctf1.cs
Just like it says, add servers by putting them in an array with the name of their config files (that you made earlier).
So if you had made config's: server1.cs and server2.cs you would change the script to say:
Save the script if you make any modifications.

Then we want to make this script executable:

chmod +x legions

And finally we can add the script so that it is started on boot:

update-rc.d legions defaults

Congratulations - we're finished!

To start the servers you can just reboot the server:




Setting up the IRC bot

The irc bot is a handy feature for server admins and also nice for players to see when the server is active and it's very easy to set up:

First open prefs.cs with nano and add the following line somewhere:

$Host::IrcBot = true;

Then for each server you want a channel open their respective config (e.g. ctf1.cs)

and add this code:
$Host::IrcNick = "ircnick";
$Host::IrcChannel = "#channel";

If you have made your bot an account with Q you can also add:

$Host::IrcAuth = true;
$Host::IrcAuthName = "Accountname";
$Host::IrcPassword = "Password;

Now, the next time the server starts, it should automatically join IRC and relay the chat messages back and forth.

Administrating the server from ssh

If you need to start or stop servers from ssh there are some commands in the script that you can use. They are in the format:

/etc/init.d/legions start|stop|restart|reload {servername}

If you do not specify a server it will apply the action to all the servers. So for example if we wanted to restart our server named ctf1 we would run:

/etc/init.d/legions restart ctf1
Last edited:


I don't want to junk this thread up but for hosting a legions server what would be the requirements for the server box? Transfer/Space/Ram/Proc/Distro


Legions Developer
The admin info is supposed to be in config.cs, not defaultPrefs. Also, deleting the first 49 lines of config.cs removes the first 6 default admin levels (0 - Player to 5 - Owner), which is what the admin panel uses to determine who has a high enough level to view the options on the left, as well as a very handy option for you server owners.
$Host::AutoResetPassword = false;
$Host::AutoResetPasswordTime = 600000; // Default of 600,000 milliseconds = 10 minutes after all players have left
$Host::DefaultPassword = "";
These three options allow you to make the server automatically reset its password to a default a specified amount of time after all the players have left. This lets you avoid constant private server resets as a result of not knowing the join password.