Difference between revisions of "Running Multiple Servers In a Single Ubuntu Computer"

From Armagetron
(30 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
== Important ==
 +
 +
Parts of this guide may be outdated.
 +
 +
If you'd like a more automated setup, see here: http://wiki.armagetronad.org/index.php?title=Setting_Up_Multiple_Armagetron_Servers_the_Easy_Way
 +
 
== Introduction ==
 
== Introduction ==
  
Line 5: Line 11:
 
I do hope people will find this tutorial useful as I found the other one very useful but a bit confusing at times.
 
I do hope people will find this tutorial useful as I found the other one very useful but a bit confusing at times.
  
In the tutorial, My username is <code> vertrex</code> so don't get confused. Change my username to YOUR username so everything will work the way it should. '''DO NOT HAVE SPACES IN YOUR USERNAME!!!'''
+
In the tutorial, My username is <code> <your_username></code> so don't get confused. Change my username to YOUR username so everything will work the way it should. '''DO NOT HAVE SPACES IN YOUR USERNAME!!!'''
  
 
== Requirements ==
 
== Requirements ==
Line 15: Line 21:
 
  4) Have "screen" installed
 
  4) Have "screen" installed
 
  5) Have libxml2 installed
 
  5) Have libxml2 installed
 +
6) Have build-essentials
 +
 +
You can get the essentials from this link: [http://wiki.armagetronad.net/index.php?title=Ubuntu_Installation Ubuntu_Installation]
  
 
== Server Installation ==
 
== Server Installation ==
Line 27: Line 36:
  
 
The location where you should download your source code would be:  
 
The location where you should download your source code would be:  
  cd /home/vertrex
+
  cd /home/<your_username>
  
 
Now download the source files using the command: bzr branch
 
Now download the source files using the command: bzr branch
Line 35: Line 44:
  
 
Once the download completes, go into the source folder
 
Once the download completes, go into the source folder
  cd /home/vertrex/0.2.8-armagetronad-sty+ct
+
  cd /home/<your_username>/0.2.8-armagetronad-sty+ct
  
 
Then run the bootstrap
 
Then run the bootstrap
Line 44: Line 53:
 
  rm: remove write-protected regular file `aclocal.m4'? yes
 
  rm: remove write-protected regular file `aclocal.m4'? yes
 
then try:
 
then try:
  sudo ./bootstrap.sh
+
  sudo apt-get install bzr  build-essential automake libboost-dev libxml2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev ftgl-dev libglew-dev bison pkg-config autoconf autotools-dev libprotobuf-dev
  
 
Before taking the final steps, you need to create the folder to which your server will be installed in.
 
Before taking the final steps, you need to create the folder to which your server will be installed in.
  mkdir /home/vertrex/armagetronad
+
  mkdir /home/<your_username>/armagetronad
  
 
Now configure the server.
 
Now configure the server.
  ./configure --disable-glout --enable-authentication --prefix=/home/vertrex/armagetronad --exec_prefix=/home/vertrex/armagetronad --with-zthread
+
  ./configure --disable-glout --enable-authentication --prefix=/home/<your_username>/armagetronad --exec_prefix=/home/<your_username>/armagetronad --with-zthread
  
 
=== Installing Source Files ===
 
=== Installing Source Files ===
Line 61: Line 70:
 
  sudo make install
 
  sudo make install
  
Now, our servers have been installed in the directory: <code>/home/vertrex/armagetronad/</code>
+
Now, our servers have been installed in the directory: <code>/home/<your_username>/armagetronad/</code>
  
 
== Server Preparations ==
 
== Server Preparations ==
Line 72: Line 81:
  
 
Go into your armagetronad installaiton folder
 
Go into your armagetronad installaiton folder
  cd /home/vertrex/armagetronad
+
  cd /home/<server_username>/armagetronad
  
 
Create the sub directories as indicated below:
 
Create the sub directories as indicated below:
 
  mkdir servers      'This folder will be used to store your server configurations
 
  mkdir servers      'This folder will be used to store your server configurations
mkdir logs        'This one will be used to save the server logs
 
 
  mkdir scripts      'And this one will be used to call scripts to start the servers or include with the servers
 
  mkdir scripts      'And this one will be used to call scripts to start the servers or include with the servers
  
 
The next few steps are the fun parts. We will be making our servers. To do so, go into servers directory that you have just created.  
 
The next few steps are the fun parts. We will be making our servers. To do so, go into servers directory that you have just created.  
  cd /home/vertrex/armagetronad/servers
+
  cd /home/<your_username>/armagetronad/servers
  
 
There, start creating sub folders for each of your servers. Example:
 
There, start creating sub folders for each of your servers. Example:
  
 
One server that I would like to create would be CTF which is capture the flag.
 
One server that I would like to create would be CTF which is capture the flag.
  mkdir ctf 'this is the server that will be hosted
+
  mkdir <server_name> 'this is the server that will be hosted
  mkdir ctf/var 'this folder where the server's ladderlog, score, players will be stored
+
  mkdir <server_name>/var 'this folder where the server's ladderlog, score, players will be stored
  mkdir ctf/settings 'this is the folder where you place your config files such as settings_custom.cfg, settings.cfg, etc...
+
  mkdir <server_name>/settings 'this is the folder where you place your config files such as settings_custom.cfg, settings.cfg, etc...
 +
mkdir <server_name>/resource    'this is where your map files will be stored depending on your specified server
 +
mkdir <server_name>/logs        'This one will be used to save the server logs
  
 
then copy your config files into the settings folder and the files that belong in the var folder.
 
then copy your config files into the settings folder and the files that belong in the var folder.
  
You can create many more servers...
+
You can create more servers like...
 
  mkdir racing
 
  mkdir racing
 
  mkdir racing/var
 
  mkdir racing/var
 
  mkdir racing/settings
 
  mkdir racing/settings
 
+
  mkdir racing/resource
Simply put it that the server directories will be like this:
+
  mkdir racing/logs
  mkdir [Server Name]
+
and many more.
  mkdir [Server Name]/var
 
mkdir [Server Name]/settings
 
  
 
== Normal Scripts ==
 
== Normal Scripts ==
Line 105: Line 113:
 
The scripts are used mainly to launch a specific server that is called using the script. The servers include Capture The Flag (S), High Rubber (S), Dogfight, Sumo
 
The scripts are used mainly to launch a specific server that is called using the script. The servers include Capture The Flag (S), High Rubber (S), Dogfight, Sumo
  
All the server scripts are to be stored in the <code>/home/vertrex/armagetronad/scripts</code> directory.  
+
All the server scripts are to be stored in the <code>/home/<your_username>/armagetronad/scripts</code> directory.  
  
 
To save a script: Hold <code> CTRL</code> then press <code> X</code>. Then <code> Y</code> to save the script.
 
To save a script: Hold <code> CTRL</code> then press <code> X</code>. Then <code> Y</code> to save the script.
Line 114: Line 122:
  
 
Firstly go into the scripts folder to follow the steps below:
 
Firstly go into the scripts folder to follow the steps below:
  cd /home/vertrex/scripts
+
  cd /home/<your_username>/scripts
  
 
=== The Server Script ===
 
=== The Server Script ===
Line 124: Line 132:
 
  #!/bin/bash
 
  #!/bin/bash
 
   
 
   
  loc="/home/vertrex/armagetronad"
+
  loc="/home/<your_username>/armagetronad"
 
  tron=$loc"/bin/armagetronad-dedicated"
 
  tron=$loc"/bin/armagetronad-dedicated"
  userconfigdir=$loc"/server/"$1"/settings/"
+
vardir=$loc"/servers/"$1"/var"
  var=$loc"/server/$1"/var/"
+
  userconfigdir=$loc"/servers/"$1"/settings"
  mkdir $loc/logs/$1
+
  resourcedir=$loc"/servers/"$1"/resource/"
 +
 +
  mkdir $loc"/servers/"$1"/logs"
 
  screen -S $1 -X logtstamp on # print timestamps in log file
 
  screen -S $1 -X logtstamp on # print timestamps in log file
  screen -S $1 -X logfile $loc/logs/$1/$1_%m-%d-%Y-%c.log # create a logfile in the logs subf
+
  screen -S $1 -X logfile $loc"/servers/"$1"/logs/"$1_%m-%d-%Y-%c.log # create a logfile in the logs subf
 
  screen -S $1 -X log on # Turn on logging for the server window
 
  screen -S $1 -X log on # Turn on logging for the server window
 
  while true; do # start a loop to allow server restart if it crashes
 
  while true; do # start a loop to allow server restart if it crashes
 
   
 
   
  #Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
+
#Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
 
  # in /home/vertrex/armagetronad/bin directory.
 
  # in /home/vertrex/armagetronad/bin directory.
 
   
 
   
        $tron --userconfigdir $userconfigdir --vardir $var
+
$tron --vardir $vardir
 
+
$tron --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir
 +
 
  # Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
 
  # Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
 
       echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
 
       echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
 
       sleep 5
 
       sleep 5
            done # end the loop
+
    done # end the loop
+
 
To save the file, press CTRL-X and Y to confirm. You have now a file called srv in /home/vertrex/armagetronad/scripts
+
To save the file, press CTRL-X and Y to confirm. You have now a file called srv in /home/<your_username>/armagetronad/scripts
  
 
=== The Global Script ===
 
=== The Global Script ===
Line 154: Line 165:
 
  #!/bin/bash
 
  #!/bin/bash
 
   
 
   
  loc="/home/vertrex/armagetronad"  
+
  loc="/home/<your_username>/armagetronad"  
 
   
 
   
 
  # If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in
 
  # If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in
  # the /home/vertrex/armagetrnad/servers directory will be started
+
  # the /home/<your_username>/armagetrnad/servers directory will be started
 
   
 
   
 
  if [ "$1" != "" ]; then
 
  if [ "$1" != "" ]; then
Line 164: Line 175:
 
  else
 
  else
 
       for f in $(ls $loc/scripts/servers/.) # start a loop running the following command for any existing folders in the
 
       for f in $(ls $loc/scripts/servers/.) # start a loop running the following command for any existing folders in the
  #/home/vertrex/armagetronad/servers folder
+
  #/home/<your_username>/armagetronad/servers folder
 
                 do
 
                 do
 
                       screen -S $f -X quit # Kill the window if it exists already, avoiding to run the same server twice
 
                       screen -S $f -X quit # Kill the window if it exists already, avoiding to run the same server twice
Line 181: Line 192:
 
For the sake of this part, I will be demonstrating to you how I used the rotation script to manage my racing server.
 
For the sake of this part, I will be demonstrating to you how I used the rotation script to manage my racing server.
  
As always, all script are to be stored in the <code>/home/vertrex/armagetronad/scripts</code> directory.
+
As always, all script are to be stored in the <code>/home/<your_username>/armagetronad/scripts</code> directory.
  
 
'''When creating/editing the scripts, I have used''' <code> nano</code>''' because it was easier for me but you don't have to use the same method. You have the freedom to choose which ever editor you wish to use to create or edit any of these files/scripts.'''
 
'''When creating/editing the scripts, I have used''' <code> nano</code>''' because it was easier for me but you don't have to use the same method. You have the freedom to choose which ever editor you wish to use to create or edit any of these files/scripts.'''
  
 
So go into the scripts folder to follow the steps shown below:
 
So go into the scripts folder to follow the steps shown below:
  cd /home/vertrex/scripts
+
  cd /home/<your_username>/scripts
  
 
=== The Rotation Script ===
 
=== The Rotation Script ===
Line 229: Line 240:
 
  #!/bin/bash
 
  #!/bin/bash
 
   
 
   
  loc="/home/vertrex/armagetronad"
+
  loc="/home/<your_username>/armagetronad"
 
  tron=$loc"/bin/armagetronad-dedicated"
 
  tron=$loc"/bin/armagetronad-dedicated"
  var=$loc"/servers/"$1"/var/"
+
  vardir=$loc"/servers/"$1"/var/"
 
  log=$var"console_log.txt"
 
  log=$var"console_log.txt"
 
  userconfigdir=$loc"/servers/"$1"/settings/"
 
  userconfigdir=$loc"/servers/"$1"/settings/"
  parser=$loc"/scripts/race_rotation.php"
+
resourcedir=$loc"/servers/"$1"/resource"
 +
  parser=$loc"/scripts/rotation.php"
 
  ladderlog=$var"ladderlog.txt"
 
  ladderlog=$var"ladderlog.txt"
 +
cmd=$loc"/scripts/cmd.txt"
 
   
 
   
  mkdir $loc/logs/$1
+
  mkdir $loc"/servers/"$1"/logs"
 
  screen -S $1 -X logtstamp on                                    # print timestamps in log file
 
  screen -S $1 -X logtstamp on                                    # print timestamps in log file
  screen -S $1 -X logfile $loc/logs/$1/$1_%m-%d-%Y-%c.log         # create a logfile in the logs subf
+
  screen -S $1 -X logfile $loc"/servers/"$1"/logs/"$1_%m-%d-%Y-%c.log     # create a logfile in the logs subf
 
  screen -S $1 -X log on                                  # Turn on logging for the server window
 
  screen -S $1 -X log on                                  # Turn on logging for the server window
 
  while true; do                                          # start a loop to allow server restart if it crashes
 
  while true; do                                          # start a loop to allow server restart if it crashes
+
 
 
  #Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
 
  #Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
 
  # in /home/vertrex/armagetronad/bin directory.
 
  # in /home/vertrex/armagetronad/bin directory.
 
   
 
   
  tail -f $ladderlog | $parser | $tron --userconfigdir $userconfigdir --vardir $var| tee -a $log
+
  tail -f $ladderlog | $parser | $tron --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir | tee -a $log
 
+
 +
#$tron --help
 +
 
  # Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
 
  # Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
 
       echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
 
       echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
Line 269: Line 284:
 
  #!/bin/bash
 
  #!/bin/bash
 
   
 
   
  loc="/home/vertrex/armagetronad"
+
  loc="/home/<your_username>/armagetronad"
  # If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in the /home/vertrex/armagetrnad-0.2.8/servers director$
+
  # If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in the /home/<your_username>/armagetrnad-0.2.8/servers director$
 
  # will be started
 
  # will be started
 
  if [ "$1" != "" ]; then
 
  if [ "$1" != "" ]; then
Line 277: Line 292:
 
  else
 
  else
 
       for f in $(ls $loc/scripts/servers/.)    # start a loop running the following command for any existing folders in the
 
       for f in $(ls $loc/scripts/servers/.)    # start a loop running the following command for any existing folders in the
  # /home/vertrex/armagetronad/servers folder
+
  # /home/<your_username>/armagetronad/servers folder
 
                 do
 
                 do
 
                       screen -S $f -X quit                            # Kill the window if it exists already, avoiding to run the same server twice
 
                       screen -S $f -X quit                            # Kill the window if it exists already, avoiding to run the same server twice
Line 295: Line 310:
 
=== Start All Servers ===
 
=== Start All Servers ===
  
To start all the servers check this link to fin out just how to do it as I didn't find it very useful for my purposes: [http://wiki.armagetronad.net/index.php?title=Running_Multiple_Servers_on_a_single_Linux_computer#Starting_all_servers Running_Multiple_Servers_on_a_single_Linux_computer#Starting_all_servers].
+
To start all the servers check this link to fin out just how to do it as I didn't find it very useful for my purposes: [http://wiki.armagetronad.org/index.php?title=Running_Multiple_Servers_on_a_single_Linux_computer#Starting_all_servers Running_Multiple_Servers_on_a_single_Linux_computer#Starting_all_servers].
  
 
=== Start Normal Servers ===
 
=== Start Normal Servers ===
  
 
Firstly go into your scripts folder
 
Firstly go into your scripts folder
  cd /home/vertrex/armagetronad/scripts
+
  cd /home/<your_username>/armagetronad/scripts
  
 
Then simply run start.sh script using the following method
 
Then simply run start.sh script using the following method
Line 331: Line 346:
  
 
Create the <code> cmd_race.txt</code> file in the scripts folder which is easy to access from.
 
Create the <code> cmd_race.txt</code> file in the scripts folder which is easy to access from.
  cd /home/vertrex/armagetronad/scripts
+
  cd /home/<your_username>/armagetronad/scripts
 
Then create the following files accordingly in the same folder as cmd_race.txt
 
Then create the following files accordingly in the same folder as cmd_race.txt
  
Line 337: Line 352:
 
  #!/bin/bash
 
  #!/bin/bash
 
   
 
   
  loc="/home/vertrex/armagetronad"
+
  loc="/home/<your_username>/armagetronad"
 
  tron=$loc"/bin/armagetronad-dedicated"
 
  tron=$loc"/bin/armagetronad-dedicated"
 
  var=$loc"/servers/racing/var/"
 
  var=$loc"/servers/racing/var/"
Line 351: Line 366:
 
  #!/bin/bash
 
  #!/bin/bash
 
   
 
   
  loc="/home/vertrex/armagetronad"
+
  loc="/home/<your_username>/armagetronad"
 
  tron=$loc"/bin/armagetronad-dedicated"
 
  tron=$loc"/bin/armagetronad-dedicated"
  var=$loc"/servers/racing/var/"
+
  vardir=$loc"/servers/racing/var/"
 
  log=$var"console_log.txt"
 
  log=$var"console_log.txt"
 
  userconfigdir=$loc"/servers/racing/settings/"
 
  userconfigdir=$loc"/servers/racing/settings/"
  parser=$loc"/scripts/race_rotation.php"
+
resourcedir=$loc"/servers/racing/resource/"
 +
  parser=$loc"/scripts/rotation.php"
 
  ladderlog=$var"ladderlog.txt"
 
  ladderlog=$var"ladderlog.txt"
  cmd=$loc"/scripts/cmd_race.txt"
+
  cmd=$loc"/scripts/cmd.txt"
 
   
 
   
  $tron --userconfigdir $userconfigdir --vardir $var --input $cmd
+
  $tron --input $cmd --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir
  
 
Remember to make them executable:
 
Remember to make them executable:
Line 366: Line 382:
 
  chmod +x start_race_server.sh
 
  chmod +x start_race_server.sh
  
Also remember to change my username, Vertrex, to your username.
+
Also remember to change my username, <your_username>, to your username.
  
 
Once that's done, you open <code> start_race_parser.sh</code> and <code> start_race_server.sh</code> in different terminal windows or this won't work.
 
Once that's done, you open <code> start_race_parser.sh</code> and <code> start_race_server.sh</code> in different terminal windows or this won't work.
Line 372: Line 388:
 
  ./start_race_server.sh
 
  ./start_race_server.sh
 
After running them in two different terminals, open another terminal and cd into your scripts folder:
 
After running them in two different terminals, open another terminal and cd into your scripts folder:
  cd /home/vertrex/armagetronad/scripts
+
  cd /home/<your_username>/armagetronad/scripts
  
 
Once in the folder, start your game and start playing and when you look at the terminals, you will see that the terminal window which you used to open <code> start_race_parser.sh</code> starts to output texts and from those texts, your server changes maps accordingly (depends on how you arranged your maps that is). How does that work?
 
Once in the folder, start your game and start playing and when you look at the terminals, you will see that the terminal window which you used to open <code> start_race_parser.sh</code> starts to output texts and from those texts, your server changes maps accordingly (depends on how you arranged your maps that is). How does that work?
Line 379: Line 395:
  
 
For example: in the extra window you have opened previously, type:
 
For example: in the extra window you have opened previously, type:
  echo center_message Hello World >> cmd.txt
+
  echo center_message Hello World >> cmd_race.txt
  
 
This should automatically pop-up a message in your game with big writings in the center saying "Hello World".
 
This should automatically pop-up a message in your game with big writings in the center saying "Hello World".
Line 449: Line 465:
  
 
Firstly go into your user folder:
 
Firstly go into your user folder:
  cd /home/vertrex
+
  cd /home/<your_username>
  
 
Downloading ZThread Compressed File
 
Downloading ZThread Compressed File
  wget http://voxel.dl.sourceforge.net/sourceforge/zthread/ZThread-2.3.2.tar.gz
+
  wget http://vertrex.tk/sources/ZThread/ZThread-2.3.2.tar
  
 
Extracting File
 
Extracting File
  tar -xzf ZThread-2.3.2.tar.gz
+
  tar -xvf ZThread-2.3.2.tar
  
 
Entering into the extracted folder
 
Entering into the extracted folder
Line 464: Line 480:
  
 
Perform the installation of the source files
 
Perform the installation of the source files
  sudo make install
+
  make && make install
 +
'''IF ERROR COMES BACK AS'''
 +
cannot create regular file '/usr/lib/libZThread-2.3.so.2.0.0': Permission Denied
 +
That only means that you do not have '''ROOT''' privileges. This is the most common case for any regular user who has ubuntu and windows installed. To get around this, you simply do
 +
sudo su
 +
which should put you in root. Mind that it might not work but for me, it did! Once it works, do the same process as above and it will complete!
  
 
=== Install Libtools ===
 
=== Install Libtools ===
Line 474: Line 495:
  
 
Firstly go into your user folder:
 
Firstly go into your user folder:
  cd /home/vertrex
+
  cd /home/<your_username>
  
 
Downloading the compressed File
 
Downloading the compressed File
Line 512: Line 533:
 
This should be done first as most virtual servers won't be usable before being updated.
 
This should be done first as most virtual servers won't be usable before being updated.
 
  sudo apt-get update
 
  sudo apt-get update
 
and
 
 
sudo apt-get upgrade
 
 
Do those codes every month to keep your system and packages updated '''but be careful about the usage of''' <code> sudo apt-get upgrade</code> . '''It can crash your platform or make some programs non-operational.'''
 
  
 
== Credits ==
 
== Credits ==
  
This tutorial was written by Vertrex a.k.a LOVER$BOY. Some of the scripts were written by Superkikim in his tutorial which I modified a little for the uses of my servers. I originally thought of editing and adding the the data that I've shown you here into his tutorial ... but his tutorial was the one that had helped me to get this far. So I instead chose to make something similar to his but with the additional data.  
+
This tutorial was written by vertrex a.k.a LOVER$BOY. Some of the scripts were written by Superkikim in his tutorial which I modified a little for the uses of my servers. I originally thought of editing and adding the the data that I've shown you here into his tutorial ... but his tutorial was the one that had helped me to get this far. So I instead chose to make something similar to his but with the additional data.  
  
 
I really do hope that people who read this will find it useful. In the title I may have called it only for Ubuntu Computers but it can be applied to any linux computer that exists today.
 
I really do hope that people who read this will find it useful. In the title I may have called it only for Ubuntu Computers but it can be applied to any linux computer that exists today.

Revision as of 00:21, 30 March 2021

Important

Parts of this guide may be outdated.

If you'd like a more automated setup, see here: http://wiki.armagetronad.org/index.php?title=Setting_Up_Multiple_Armagetron_Servers_the_Easy_Way

Introduction

Hello everyone. This is a tutorial that I thought I should put together for those who are using Ubuntu and are struggling to grasp how to host more than one server. Before I go any further, I would like to say that this section does look similar to Running Multiple Servers on a single Linux computer ... but there is a difference. There are a couple of things that are different from the other and there are few others that have been added so people will find them useful.

I do hope people will find this tutorial useful as I found the other one very useful but a bit confusing at times.

In the tutorial, My username is <your_username> so don't get confused. Change my username to YOUR username so everything will work the way it should. DO NOT HAVE SPACES IN YOUR USERNAME!!!

Requirements

To continue with the next steps you will have installed the following:

1) Have bzr installed
2) Have Z-Thread installed
3) Have "nano" (or your favorite text editor) Installed
4) Have "screen" installed
5) Have libxml2 installed
6) Have build-essentials

You can get the essentials from this link: Ubuntu_Installation

Server Installation

Before you can think about setting up so that you can have multiple servers, firstly you need to have installed the Armagetron Advanced Dedicated Server in your computer. Now this is not specific as there are countless number of servers that the admins have either created or experiments or stable release.

The source codes for the servers can be found here: Armagetron Advanced: a Tron Clone in 3d

For the sake of this tutorial, our selection would be armagetron-sty+ct as that's a very popular selection to create servers with.

Downloading Source Files

The location where you should download your source code would be:

cd /home/<your_username>

Now download the source files using the command: bzr branch

bzr branch lp:~armagetronad-ct/armagetronad/0.2.8-armagetronad-sty+ct

Configuring Source Files

Once the download completes, go into the source folder

cd /home/<your_username>/0.2.8-armagetronad-sty+ct

Then run the bootstrap

./bootstrap.sh

if you get an error saying:

autom4te: cannot open autom4te.cache/requests: Permission denied
aclocal: autom4te failed with exit status: 1
rm: remove write-protected regular file `aclocal.m4'? yes

then try:

sudo apt-get install bzr  build-essential automake libboost-dev libxml2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev ftgl-dev libglew-dev bison pkg-config autoconf autotools-dev libprotobuf-dev

Before taking the final steps, you need to create the folder to which your server will be installed in.

mkdir /home/<your_username>/armagetronad

Now configure the server.

./configure --disable-glout --enable-authentication --prefix=/home/<your_username>/armagetronad --exec_prefix=/home/<your_username>/armagetronad --with-zthread

Installing Source Files

Once configuration is done, follow the next steps at installing the server

make
make install

If you do not have write rights to the installation directory, use:

sudo make install

Now, our servers have been installed in the directory: /home/<your_username>/armagetronad/

Server Preparations

Now, this is where you will have to do some thinking. You can make 7 servers as the ports list from 4534 to 4540. So, basically you have seven servers to make from. You could choose to make, Capture The Flag (S), High Rubber (S), Racing, etc...

To setup the multiple servers, please follow from next steps.

Server Directories

Go into your armagetronad installaiton folder

cd /home/<server_username>/armagetronad

Create the sub directories as indicated below:

mkdir servers      'This folder will be used to store your server configurations
mkdir scripts      'And this one will be used to call scripts to start the servers or include with the servers

The next few steps are the fun parts. We will be making our servers. To do so, go into servers directory that you have just created.

cd /home/<your_username>/armagetronad/servers

There, start creating sub folders for each of your servers. Example:

One server that I would like to create would be CTF which is capture the flag.

mkdir <server_name>		'this is the server that will be hosted
mkdir <server_name>/var		'this folder where the server's ladderlog, score, players will be stored
mkdir <server_name>/settings	'this is the folder where you place your config files such as settings_custom.cfg, settings.cfg, etc...
mkdir <server_name>/resource     'this is where your map files will be stored depending on your specified server
mkdir <server_name>/logs         'This one will be used to save the server logs

then copy your config files into the settings folder and the files that belong in the var folder.

You can create more servers like...

mkdir racing
mkdir racing/var
mkdir racing/settings
mkdir racing/resource
mkdir racing/logs

and many more.

Normal Scripts

The scripts are used mainly to launch a specific server that is called using the script. The servers include Capture The Flag (S), High Rubber (S), Dogfight, Sumo

All the server scripts are to be stored in the /home/<your_username>/armagetronad/scripts directory.

To save a script: Hold CTRL then press X. Then Y to save the script.

Check this website to understand more about the scripts ... Running_Multiple_Servers_on_a_single_Linux_computer#The_scripts

When creating/editing the scripts, I have used nano because it was easier for me but you don't have to use the same method. You have the freedom to choose which ever editor you wish to use to create or edit any of these files/scripts.

Firstly go into the scripts folder to follow the steps below:

cd /home/<your_username>/scripts

The Server Script

The first script will be called in this example: srv.sh

nano srv.sh 

That creates a .sh file called srv in the scripts directory. Write the following lines in the file

#!/bin/bash

loc="/home/<your_username>/armagetronad"
tron=$loc"/bin/armagetronad-dedicated"
vardir=$loc"/servers/"$1"/var"
userconfigdir=$loc"/servers/"$1"/settings"
resourcedir=$loc"/servers/"$1"/resource/"

mkdir $loc"/servers/"$1"/logs"
screen -S $1 -X logtstamp on 					# print timestamps in log file
screen -S $1 -X logfile $loc"/servers/"$1"/logs/"$1_%m-%d-%Y-%c.log 	# create a logfile in the logs subf
screen -S $1 -X log on 					# Turn on logging for the server window
while true; do 						# start a loop to allow server restart if it crashes

#Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
# in /home/vertrex/armagetronad/bin directory.

	$tron --vardir $vardir
	$tron --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir

# Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
      echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
      sleep 5
	    done # end the loop

To save the file, press CTRL-X and Y to confirm. You have now a file called srv in /home/<your_username>/armagetronad/scripts

The Global Script

Create the second script. I called it start:

nano start.sh

That creates a .sh file called start in the scripts directory. Write the following lines in the file

#!/bin/bash

loc="/home/<your_username>/armagetronad" 

# If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in
# the /home/<your_username>/armagetrnad/servers directory will be started

if [ "$1" != "" ]; then
     screen -S $1 -X quit				# Kill the window if it exists already, avoiding to run the same server twice
     screen -dmS $1 $loc/scripts/srv.sh $1			 # start a GNU screen window with the specified server inside
else
      for f in $(ls $loc/scripts/servers/.)	 # start a loop running the following command for any existing folders in the
#/home/<your_username>/armagetronad/servers folder
               do
                      screen -S $f -X quit				# Kill the window if it exists already, avoiding to run the same server twice
                      screen -dmS $f $loc/scripts/srv.sh $f	# start a GNU screen window with the server inside for each server folder
               done							# ends the loop
fi

Before you can run the script, you must make them executable:

chmod +x srv.sh
chmod +x start.sh

Advanced Scripts

In this part there are a few things that might interest you, such as the rotation script, one that is used to choose maps randomly per round.

For the sake of this part, I will be demonstrating to you how I used the rotation script to manage my racing server.

As always, all script are to be stored in the /home/<your_username>/armagetronad/scripts directory.

When creating/editing the scripts, I have used nano because it was easier for me but you don't have to use the same method. You have the freedom to choose which ever editor you wish to use to create or edit any of these files/scripts.

So go into the scripts folder to follow the steps shown below:

cd /home/<your_username>/scripts

The Rotation Script

I found the script in a post that was made in the Armagetron Forums. I wanted to experiment with my racing maps in the 0.2.8-sty+ct version.

All credit goes to Kyle for writing the script.

Create the rotation script. I called it race_rotation:

nano race_rotation.php

This creates a .php file with the name race_rotation in the scripts folder.

#!/usr/bin/php
<?php
$maps=array("/path/to/map1.xml","/path/to/map2.xml");
while (1)  {
   $line = rtrim(fgets(STDIN, 1024));
   if ( preg_match( "/^ROUND_COMMENCING/", $line ) ){
       $keywords = preg_split("/ /", $line);
  $map=rand (0 , count($maps )-1);
       echo "MAP_FILE ".$maps[$map]."\n";
       echo "WAIT_FOR_EXTERNAL_SCRIPT 0\n";
       sleep(6);
       echo "WAIT_FOR_EXTERNAL_SCRIPT 1\n";
   }
}
?>

To understand the components of the script, go to the post where it was originally made: Armagetron Forums: Map Rotation without 0.3

Remember to enable Ladderlog command in your server so that the script will rotate the maps:

LADDERLOG_WRITE_ROUND_COMMENCING 1

The Server Script

OK, The following script is only for the racing server. However, you can change it for your own uses.

Create the server script. I called it race_srv:

nano race_srv.sh

This creates a .sh file with the name race_srv in the scripts folder.

#!/bin/bash

loc="/home/<your_username>/armagetronad"
tron=$loc"/bin/armagetronad-dedicated"
vardir=$loc"/servers/"$1"/var/"
log=$var"console_log.txt"
userconfigdir=$loc"/servers/"$1"/settings/"
resourcedir=$loc"/servers/"$1"/resource"
parser=$loc"/scripts/rotation.php"
ladderlog=$var"ladderlog.txt"
cmd=$loc"/scripts/cmd.txt"

mkdir $loc"/servers/"$1"/logs"
screen -S $1 -X logtstamp on                                    # print timestamps in log file
screen -S $1 -X logfile $loc"/servers/"$1"/logs/"$1_%m-%d-%Y-%c.log     # create a logfile in the logs subf
screen -S $1 -X log on                                  # Turn on logging for the server window
while true; do                                          # start a loop to allow server restart if it crashes
 
#Runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
# in /home/vertrex/armagetronad/bin directory.

tail -f $ladderlog | $parser | $tron --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir | tee -a $log

#$tron --help

# Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
      echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
      sleep 5
           done # end the loop

To use your rotation script for other servers, change the rotation script name in the script to your rotation script's name:

 parser=$loc"/scripts/[Script Name].php"

To know more commands other than userconfigdir and vardir , try this in the script which will give you a window with the other things you can have:

$tron --help

The Global Script

OK, The following script is only to start the racing server, race_srv.sh, but you can change it accordingly for your own purposes.

Create the server script. I called it race_start:

nano race_start.sh

This creates a .sh file with the name race_start in the scripts folder.

#!/bin/bash

loc="/home/<your_username>/armagetronad"
# If you run the script with a parameter (server name), only that server will be start. Otherwise, all servers in the /home/<your_username>/armagetrnad-0.2.8/servers director$
# will be started
if [ "$1" != "" ]; then
      screen -S $1 -X quit                             # Kill the window if it exists already, avoiding to run the same server twice
      screen -dmS $1 $loc/scripts/race_srv.sh $1                     # start a GNU screen window with the specified server inside
else
      for f in $(ls $loc/scripts/servers/.)     # start a loop running the following command for any existing folders in the
# /home/<your_username>/armagetronad/servers folder
               do
                      screen -S $f -X quit                             # Kill the window if it exists already, avoiding to run the same server twice
                      screen -dmS $f $loc/scripts/race_srv.sh $f    # start a GNU screen window with the server inside for each server folder
               done                                                    # ends the loop
fi

Before you can run the script, you must make them executable:

chmod +x race_rotation.php
chmod +x race_srv.sh
chmod +x race_start.sh

Running Servers

Starting the servers shouldn't be that hard if you follow the steps given below:

Start All Servers

To start all the servers check this link to fin out just how to do it as I didn't find it very useful for my purposes: Running_Multiple_Servers_on_a_single_Linux_computer#Starting_all_servers.

Start Normal Servers

Firstly go into your scripts folder

cd /home/<your_username>/armagetronad/scripts

Then simply run start.sh script using the following method

./start.sh [Server Name]

If you get a message saying:

No screen session found.

Don't panic that there is an error in the script. Try the next step:

screen -r [Server Name]

Start Racing Servers

In the scripts folder, run race_start.sh . As that script is for the racing server, we type in racing or something like that depending on the name you have given your racing folder.

./race_start.sh racing

Ok, the racing scripts are a little different to the normal scripts. It's not much difference. You follow the same steps as above and enter into the new screen that the server will start in but what's different is that you can't enter any commands in the server like you can with the normal ones.

Basically meaning, you have to manually enter settings rather than easily change settings without entering the server. That is to say, you enter into the server, login as Owner or Admin and change settings.

Start Racing Server in Separate Sessions

As you can read from the title, this will section will explain how you can run your racing server with parser and not have to go into the server in the game to change the settings. That way is manually but this way is much quicker and easier.

To do this, you will need three files:

start_race_parser.sh
start_race_server.sh
cmd_race.txt

These can be named with any names but in my case as I'm talking about racing, I will relate them to the racing.

Create the cmd_race.txt file in the scripts folder which is easy to access from.

cd /home/<your_username>/armagetronad/scripts

Then create the following files accordingly in the same folder as cmd_race.txt

start_race_parser.sh:

#!/bin/bash

loc="/home/<your_username>/armagetronad"
tron=$loc"/bin/armagetronad-dedicated"
var=$loc"/servers/racing/var/"
log=$var"console_log.txt"
userconfigdir=$loc"/servers/racing/settings/"
parser=$loc"/scripts/race_rotation.php"
ladderlog=$var"ladderlog.txt"
cmd=$loc"/scripts/cmd_race.txt"

tail -f $ladderlog | $parser | tee -a $cmd

start_race_server.sh:

#!/bin/bash

loc="/home/<your_username>/armagetronad"
tron=$loc"/bin/armagetronad-dedicated"
vardir=$loc"/servers/racing/var/"
log=$var"console_log.txt"
userconfigdir=$loc"/servers/racing/settings/"
resourcedir=$loc"/servers/racing/resource/"
parser=$loc"/scripts/rotation.php"
ladderlog=$var"ladderlog.txt"
cmd=$loc"/scripts/cmd.txt"

$tron --input $cmd --resourcedir $resourcedir --userconfigdir $userconfigdir --vardir $vardir

Remember to make them executable:

chmod +x start_race_parser.sh
chmod +x start_race_server.sh

Also remember to change my username, <your_username>, to your username.

Once that's done, you open start_race_parser.sh and start_race_server.sh in different terminal windows or this won't work.

./start_race_parser.sh
./start_race_server.sh

After running them in two different terminals, open another terminal and cd into your scripts folder:

cd /home/<your_username>/armagetronad/scripts

Once in the folder, start your game and start playing and when you look at the terminals, you will see that the terminal window which you used to open start_race_parser.sh starts to output texts and from those texts, your server changes maps accordingly (depends on how you arranged your maps that is). How does that work?

I'm not an expert when it comes to scripts but I'll explain the best I can which I gathered form the people that have explained it to me. The start_race_parser.sh outputs texts which will be written into the cmd.txt and from there the server will read the cmd_race.txt file for new text entires and feeds them into the server and this is done through the use of --input .

For example: in the extra window you have opened previously, type:

echo center_message Hello World >> cmd_race.txt

This should automatically pop-up a message in your game with big writings in the center saying "Hello World".

From that little example you should now know how it's done, how you can change settings in the server without actually being in the server.

Manage Servers

Multiple Servers

Managing the servers should be pretty easy once you get to understand what you need to do.

Let's have an example that you started 4 servers: ctf, high_rubber, hr+S and racing

How are you going to keep a watch on them from within a single terminal ... that's practically impossible. You can only watch over one server at a time but there is another way that you could use to watch over them. Firstly let's call the current terminal, T1 ... make things easier to understand.

Stepped Process:

Step 1: Go to File.
Step 2: Select"Open Terminal"

A new terminal window should show up, let's call it T2. With T2, you can monitor another server. Repeat the "Stepped Process" and you can monitor many more servers.

In each terminal window, type one of each of the servers that are running:

screen -r ctf
screen -r high_rubber
screen -r hr+s
screen -r racing

Your computer screen would look full with all the terminal windows but don't worry. You can minimize them and continue doing whatever you wish to do while the servers are online.

The GNU Screen

You don't really need to know a great deal lot of information on how to manage servers in a GNU but if you wish to, then try:

man screen

It'll give you many commands that you can use in your terminal.

Show Current Running Servers

To see the servers that are running, try this:

screen -ls

It will display the servers that are currently running in your system.

Access/Leave Specific Server

To access a certain server, enter:

screen -r [Server Name]

To detach from the server, do: Hold CTRL then hold A and finally Press D

When you detach from the server window, it doesn't mean the server will shutdown. You simply are leaving the server window to get back to the normal window which you have started from. To re-enter the server window, follow the steps given above on how to access the server.

Close A Server

To close a server, go into the server you want to close:

screen -r [Server Name]

Then Do: Hold CTRL and press C

That should automatically bring you back to your terminal window and a message should appear saying:

[screen is terminating]

Extras

These are snippets of stuff that I found useful when I had problems with things when running my server.

Install Z-Thread

Firstly go into your user folder:

cd /home/<your_username>

Downloading ZThread Compressed File

wget http://vertrex.tk/sources/ZThread/ZThread-2.3.2.tar

Extracting File

tar -xvf ZThread-2.3.2.tar

Entering into the extracted folder

cd ZThread-2.3.2

Configuring the source files

./configure CXXFLAGS="-fpermissive" --prefix=/usr/

Perform the installation of the source files

make && make install

IF ERROR COMES BACK AS

cannot create regular file '/usr/lib/libZThread-2.3.so.2.0.0': Permission Denied

That only means that you do not have ROOT privileges. This is the most common case for any regular user who has ubuntu and windows installed. To get around this, you simply do

sudo su

which should put you in root. Mind that it might not work but for me, it did! Once it works, do the same process as above and it will complete!

Install Libtools

You simply enter the following into the terminal and it will automatically should install it for you:

sudo apt-get install libtool

Install Protobuf

Firstly go into your user folder:

cd /home/<your_username>

Downloading the compressed File

wget http://protobuf.googlecode.com/files/protobuf-2.0.3.tar.bz2

Extracting File

tar -jxvf ./protobuf-2.0.3.tar.bz2

Entering into the extracted folder

cd protobuf-2.0.3

Configuring the source files

./configure --prefix=/usr

Perform the installation of the source files

sudo make install

Install Screen

This will automatically install the screen command which you need for these scripts

sudo apt-get install screen

Install PHP

This will automatically install the screen command which you need for these scripts

sudo apt-get install php5

Install BZR

This will automatically start the installation of the bzr which you will need in order to download the armagetronad source files.

sudo apt-get install bzr

Install libxml2

This will automatically start to install libxml2. This is needed if the ./configure is to work properly.

sudo apt-get install libxml2-dev

Update Packages

This should be done first as most virtual servers won't be usable before being updated.

sudo apt-get update

Credits

This tutorial was written by vertrex a.k.a LOVER$BOY. Some of the scripts were written by Superkikim in his tutorial which I modified a little for the uses of my servers. I originally thought of editing and adding the the data that I've shown you here into his tutorial ... but his tutorial was the one that had helped me to get this far. So I instead chose to make something similar to his but with the additional data.

I really do hope that people who read this will find it useful. In the title I may have called it only for Ubuntu Computers but it can be applied to any linux computer that exists today.