Page MenuHomePhabricator

Installation
Updated 1,466 Days AgoPublic

This tutorial is simply a re-make of the currently existing [tutorial] written by LOVER$BOY. This too is written by Vertrex but with a few differences here and there.

This tutorial only applies to Debian and Ubuntu based Linux :)

${USER} gets your current user stored in an environment variable. Feel free to replace this if necessary or use $HOME instead.

Open up your Terminal and let's get started!

Table of Contents

Requirements

These following are the software that need to be installed beforehand.

  • Have bzr installed
  • Have Z-Thread installed
  • Have nano (or your favorite text editor) Installed
  • Have screen installed
  • Have libxml2 installed
  • Have build-essentials

It is typically a good idea to update your repositories before installing anything.

sudo apt-get update

You can install them all at once with the following line:

sudo apt-get install bzr build-essential automake libboost-dev libxml2-dev ftgl-dev libglew-dev bison pkg-config autoconf autotools-dev protobuf-compiler screen nano libxml2

Installation

What to install? Well, for this tutorial I will be using Alpha Project's but you have the choices and they are all here: Armagetron Advanced: a Tron Clone in 3d.

Downloading Source

Let's use a location that won't restrict us for security reasons or any other the computer could think of. Example, let's try out /home/${USER}/ directory. Replace the ${USER} with your username.

cd /home/${USER}/

Now download the source into the folder

bzr branch lp:~armagetronad-ap/armagetronad/0.2.9-armagetronad-sty+ct+ap

Configuring Files

After downloading, do

cd 0.2.9-armagetronad-sty+ct+ap

Then do

./bootstrap.sh

Next minimize the terminal and in your /home/${USER}/ folder, make a directory to install the server in. For this tutorial's case, I'll do

mkdir /home/${USER}/armagetronad

and next configuring the server itself.

./configure --enable-dedicated --enable-authentication --prefix=/home/${USER}/armagetronad/ --exec_prefix=/home/${USER}/armagetronad/

If you wish to change the default MAX_CLIENTS limit of 32, then I suggest you add

--with-maxclients=X

to your configure line. Be sure to replace X with the number you want

Quick Method

CXXFLAGS="-pipe" ./configure --enable-dedicated --enable-armathentication --disable-automakedefaults --disable-sysinstall --disable-useradd --disable-etc --disable-desktop --disable-initscripts --disable-uninstall --disable-games --prefix=/home/${USER}/armagetronad

Installing Files

Two commands and 30 minutes of time is required for this part. Well, make can be faster or slower depending on the speed of your computer.

make
make install

OR

make && make install

The first command will compile the source code into binary form, preparing for installation. You can speed it up by "multithreading" make with something like the following, replacing 4 with the number of cores (and/or threads, if you have something such as Hyperthreading enabled) on your CPU.

make -j4
make install

Then run the second command and your server should be installed. Go into your /home/${USER}/armagetronad/ folder and you should be able to see three folders

bin
etc
share

Go into bin folder and check to make sure you have

armagetronad-dedicated

If you have it, that means your server has been installed successfully!

create_server.sh

Putting Together

This is where we will be describing on how to have multiple servers, the folders required and stuff like that.

Ok, first enter into your the folder you installed your server in. For this tutorial, that is /home/${USER}/armagetronad
Next create the following folder

mkdir servers

It doesn't have to be servers. Have the folder name set to whatever you prefer but I always set it with that name so I know that's where servers go.

Setting up Servers

Now go into that folder. servers is the folder for this tutorial.

mkdir {server_name}

Replace {server_name} with the name of the server or whichever. The choice is again down to you. Next enter into that newly created directory and start creating the folders we need.

Doing it and their explanations are also given below:

mkdir scripts     # the folder for scripts to run that particular server, also for script.php
mkdir settings    # the folder for holding our custom settings and config files & folders
mkdir var         # the folder for the files the server writes to, like ladderlog.txt, players.txt, etc...
mkdir logs        # the folder for logs of your server, especially its console or any errors it detected. No need to create if not needed.

As an example, this tutorial will have following directories

mkdir Test
cd Test
mkidr scripts
mkdir settings
mkdir var
mkdir logs

After creating the directories, go and place the files required in each of them. If you don't get it, read the descriptions above for clarifications. Even after reading them and your confused... read the bit below...

Read this if you're folder lost!
Folder: scripts
Description: This is the folder for all of your scripts, such as the start-up script and any other configuration scripts you want to use go. Getting Files: Continue to read tutorial and you'll know soon.

Folder: settings
Description: Settings folder which holds your configs and the regular settings to make the server run properly. Getting Files:

cd /home/${USER}/armagetronad/etc/
cp armagetronad-dedicated /home/${USER}/armagetronad/servers/Test/settings/

Command Files

This is where you will be creating files you would definitely need if hackers tend to jump in servers and take over. In your /home/${USER}/armagetronad/servers/Test/ directory, create the files command.txt and console.txt

touch command.txt && touch console.txt

The command.txt is the file used to send commands to the server using your terminal.
The console.txt is the file that stores the console as the server does it's job. Useful to going back and checking to ensure nothing terrible happened. Also useful to check for errors.

Setting up Scripts

It's time to set up some scripts to actually run the server!

These scripts are straightforward I hope. Replace ${USER} and any other file or folder names that your and mine differ from.

Server Scripts

This script puts a loop on the server so it can easily be restarted. It also has variables which configure the paths which the server will use.

After preparing the server up, cd into scripts and do

nano server.sh

I prefer to use server as the standard file name but you can choose what you want it named but I generally prefer to name it like this so I know it's to actually run the server, not the start-up script. However, have the extension as .sh

Now a new screen will appear in your terminal. Paste the following in:

#!/bin/bash

loc="/path/to/"
tron=$loc"bin/armagetronad-dedicated"
server=$loc"servers/"$1"/"
var=$server"var"
settings=$server"settings"
command=$server"command.txt"
console=$server"console.txt"

### Comment ###
# $1 is the folder name of server given from start.sh it is executed

#mkdir $server"logs"
#screen -S $1 -X log on
#screen -S $1 -X logfile $server"logs/$1.log"
#screen -S $1 -X logstamp on

while true; do
	$tron --vardir $var --userconfigdir $settings --input $command >> $console
	echo "!============================== SERVER RESTARTING IMMEDIATELY ==============================!" >> $console
	sleep 1
done

The while true; do is a loop system that ensures your server will restart when the server quits or crashes. As it automatically restarts after crash or whatever it was that caused it to shut down, the script will write ============== SERVER RESTARTING ============== to console.txt

Change the $loc variable to your prefix path. (probably /home/${USER}/)

Now mark the file executable so it can be run:

chmod +x server.sh

Start Script

This script runs the above script in a screen session so the server can be run in the background. Using screen also allows you to attach and detach from the server console if necessary (although it can be easy to accidentally terminate your server if you use Ctrl+C instead of Ctrl+A+D to detach!)

We'll call it start.sh here.

#!/bin/sh

server="your_server_folder_name"

loc="/path/to/servers/"$server"/"
command=$loc"command.txt"
console=$loc"console.txt"

case $1 in
	start)
		if ! screen -list | grep -q $server; then
    			rm -rf $command
			touch $command

	    		#rm -rf $console

			echo "Starting "$server" immediately!"
			screen -dmS $server ./server.sh $server
		else
			echo $server" is already running..."
		fi
	;;
	stop)
		if ! screen -list | grep -q $server; then
			echo $server" server is already stopped..."
		else
			echo "Stopping "$server" immediately!"
			echo "EXIT" >> $command
			sleep 1
			screen -S $server -X quit 
		fi
	;;
esac

Don't forget to replace your_server_folder_name with the name you want to give the server to be stored in the screen under as.
So, replace the things that yours and mine differ from and finish of by doing:

chmod +x start.sh

Server Execution

Starting Server

Now that you've created the [Server Script](#Server_Scripts) and [Start Script](#Start_Script), let's start the servers.

cd to your scripts folder

cd /home/${USER}/armagetronad/servers/Test/scripts

Once in, execute the following:

./start.sh start

After execution, a message show appear in the terminal saying "Server Starting". You can check to make sure its up by typing the following

screen -r {server_name}

Instead of {server_name}, type in the name you gave the server and it should be listed in the list of screen running. To dtach yourself from the screen without causing it to quit, simply press together the keys: CTRL + A + D

screen -ls    # lists all screens running currently

Stopping Server

Not really a special content here, simply have to go back into your scripts folder and do:

./start.sh stop

and a message saying "Server Stopping" should appear. To ensure the server has stopped, do

screen -ls

Advanced

Here you will learn to do more high ordered scripting to make your server fascinating and cool!

Scripting tutorial

This section will inform you on how to run script.php. First you create the file, either manually through editor or nano. After making your code, save it in your server's scripts folder. Then run

chmod +x script.php

to make it executable. Now, in the directory with the settings (settings_custom.cfg, whatever) create a file named script.cfg and add the following lines

KILL_SCRIPT script.php
SPAWN_SCRIPT script.php

In game, you can now include script.cfg at any time to restart the script.

Now, add INCLUDE script.cfg in your config (probably settings_custom.cfg) and it will be launched on server startup.

Extras

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

Nelg: I don't really know why most of these are here when they're also included with the apt-get line above, so I'll probably clean this up later

Install Z-Thread

ZThread is neccessary to be able to login during the round. The easiest way to install it is by installing it from your distro's packages.

sudo apt-get install libzthread-dev

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

The easiest way to install protobuf is to install from your distro's packages like so:

sudo apt-get install protobuf-compiler

Install Screen

The screen command is used in the start scripts to run your server in the background.

sudo apt-get install screen

Install PHP

PHP is typically the language of choice for scripting in Armagetron.

sudo apt-get install php

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

Vertrex: Main author of this tutorial.

Nelg: Various improvements throughout.

Good luck! ;)

Last Author
Armanelgtron
Last Edited
Nov 15 2020, 7:42 PM

Event Timeline

Armanelgtron edited the content of this document. (Show Details)Jun 30 2020, 4:32 PM
Armanelgtron edited the content of this document. (Show Details)Nov 15 2020, 7:33 PM
Armanelgtron edited the content of this document. (Show Details)Nov 15 2020, 7:42 PM