Difference between revisions of "Server"

From King Arthur's Gold Wiki
Jump to: navigation, search
(Added a screen tutorial)
m (Using Screen)
Line 79: Line 79:
 
# First, download screen if you haven't got it: <br /> <syntaxhighlight lang="bash" enclose="div"> sudo apt-get install screen</syntaxhighlight>
 
# First, download screen if you haven't got it: <br /> <syntaxhighlight lang="bash" enclose="div"> sudo apt-get install screen</syntaxhighlight>
 
# Now, in you KAG server folder create a new screen: <br /> <syntaxhighlight lang="bash" enclose="div">screen -S MyScreenName</syntaxhighlight> <br />
 
# Now, in you KAG server folder create a new screen: <br /> <syntaxhighlight lang="bash" enclose="div">screen -S MyScreenName</syntaxhighlight> <br />
Note that the -S is a capital S and not a small one! <br />
+
Note that the -S is a capital s and not a small one (s)! <br />
 
# Now, start your server: <br /> <syntaxhighlight lang="bash" enclose="div">./KAGdedi</syntaxhighlight><br />
 
# Now, start your server: <br /> <syntaxhighlight lang="bash" enclose="div">./KAGdedi</syntaxhighlight><br />
 
Some basic screen instructions: <br />
 
Some basic screen instructions: <br />

Revision as of 18:21, 23 August 2013

This page might not be up-to-date (build 847).

This page is for the set up of the default Beta KAG Server and then configuring it. For minimum requirements, installation, managing stability and configuration this is the right page.

Server Requirements

The King Arthur's Gold Alpha Server is a relatively lightweight, 32-bit command line application. Freely distributed, this program allows anybody with an internet connection and a computer to host their own King Arthur's Gold server.

Note: There is very little official documentation for the KAG server. As a result, the majority of this document was created from observation, trial and error. Use at your own risk.

Residential Connections

For those hosting on residential internet connections:

  • Make sure that your computer has at least the above specifications.
  • Keep in mind that many ISPs forbid running any kind of server, including a KAG server, they may block certain ports and dynamically assign IP addresses.

Dedicated Servers

Software

  • The KAG server can run on almost all OS.
  • The recommended operating system is Linux, specifically Ubuntu or Debian.

Lowest Hardware

  • RAM: At least 128MB
  • CPU: At least 1 core clocked @ 1Ghz

Recommended Hardware

  • RAM: 512MB
  • CPU: 1 cores clocked @ 2Ghz

Network

  • Internet Connection speed per player scales with the number of players:
  • Upload to each player: (number of players - 1) * 0.3 kb/s
  • Download from each player: 0.5kb/s

Ports

  • Firewall tolerant means that a typical connection-oriented (SPI) firewall will allow that port through. Depending on the firewall, all ports may need to be forwarded in UDP.
Description Modifiable? Firewall Tolerant?
50301/udp Used to listen for game connections. yes no
50301/tcp Used to listen for remote admin (tcp rcon) connections. yes no
50328/udp Used to communicate with clients. yes yes
80/tcp Used for autoupdates no yes
443/tcp Used for API (server list, auth, minimaps, etc) server communication no yes

Installation

Linux Install

Basic Install

This guide is written for 32-bit Debian based Linux distro's (Ubuntu, Mint, etc).

  1. Download the server:
    wget http://dl.kag2d.com/kagbeta-linux32-dedicated.tar.gz
  2. Next, decompress the archive:
    tar -zxf kagbeta-linux32-dedicated.tar.gz
  3. Change to the new directory:
    cd kagbeta-linux32-dedicated
  4. Allow the server to be executed:
    chmod +x KAGdedi

  5. Run your server:
    ./KAGdedi

Using Screen

It is recommend to use Screen while hosting (multiple) servers (on a Virtual Server). Basically what screen is can be found here. In simple words screen is a program which lets you create multiple terminal sessions. For example, if you don't want to run all the processes on your main terminal you can easily create a 'screen' and run your server there. After you installed like stated above, stop before ./KAGdedi. This is where you don't run KAG but start the 'screen' and run it there.

  1. First, download screen if you haven't got it:
     sudo apt-get install screen
  2. Now, in you KAG server folder create a new screen:
    screen -S MyScreenName

Note that the -S is a capital s and not a small one (s)!
  1. Now, start your server:
    ./KAGdedi

Some basic screen instructions:
  1. To open a screen, for example when you shut down your terminal and you want to restart your server:
    screen -x MyScreenName

  2. Want to stop your server: Press "ctrl+c" (general Linux command to kill a process).
  3. Want to kill the screen as you don't use/need it anymore, do this in your screen: ctrl+a+k and press Y to confirm.
  4. Want to go out of a screen/detach, do this (in your screen, of course): ctrl+a+d.

Windows Install

  1. First, download the server: http://kag2d.com/en/download
  2. Next, decompress the archive. This can be done with many different programs, including PeaZip.
  3. Open the folder the archive was extracted into.
  4. Run your server by executing dedicatedserver.bat.

Port Forwarding

Router

As said before KAG Servers require various ports to be open for it to run properly. If you are using a router, it most likely has its own firewall. Unfortunately since there are many router manufacturers, its almost impossible for a universal guide that would offer step-by-step instructions on how to set up these 'port forwards'. Please consult your router manufacturer's website for more precise information on how to accomplish this.

Windows Firewall

If you are running a Windows OS this is most likely active on your computer blocking certain ports . The following steps were done on a Windows 7 computer but other Windows OS should be nearly identical.

  1. Go to Control Panel and open the Security and Security tab.
  2. Click on "Windows Firewall".
  3. Click on "Advanced settings" on the left hand side column.
  4. Right click on the "Inbound Rules" button, in the left hand side column, and select "New Rule..."
  5. Select "Port" and click "Next".
  6. Type in the port you wish to allow (they are found above) and click "Next".
  7. Select "Allow this connection and click "Next"
  8. (Recommended) Select "Domain", "Private" and "Public"
  9. Type in a Name and click "Finish.
  10. Repeat steps 4-9 for all the ports

Mac Firewall

  1. Download Portmap: http://www.macupdate.com/app/mac/27342/port-map/
  2. Next, decompress the archive. This can be done with many different programs, including PeaZip.
  3. Launch Portmap.
  4. Open the required ports.

Antivirus Firewall

Like Windows Firewall, if you have an antivirus it most always has a firewall. Unfortunately since there are many antivirus products on the market, its almost impossible for a universal guide that would offer step-by-step instructions on how to set up these 'port forwards'. Please consult your antivirus brand's website for more precise information on how to accomplish this.

Configuration

The KAG server is configured using text files. Customizing a KAG server installation involves modifying the variables in these files.

One of the most important decisions a server administrator must make is whether or not to allow the Royal Guard to police their server. Please read the opening posts in these threads (In-game moderators (AKA Royal Guard) & The Royal Guard - FAQ & Public Policy) so you can make an informed decision.

If you decide you don't want guards to moderate on your server, please ensure they are turned off in your autoconfig.cfg and in your security levels.

Rules/MODE/MapCycle.cfg

This defines what maps are loaded for the specified mode. You must separate paths to files with semicolons. Allowed files are generators, script files and maps in png format. More info...

Rules/MODE/gamemode.cfg

There are several files that form the specific gamemode at the rules folder. If your are changing the settings for a specific gamemode it is highly recommended to backup the files as a new update of KAG might reset the settings that are located at the default folders. Most variables are pretty self explanatory. More info...

Remote Control

<p>A server can be controlled in-game. While connected to the server, press the HOME key to open the console. A full list of available rcon commands can be found here. In order to remote control a server however you must be set as an administrator in the servers configuration files. The system KAG uses for this is found bellow.

You are also able to remotely control your server when you've set sv_tcpr to 1. More info at Remote Administration

Security Levels

King Arthur's Gold uses a system called 'Security Levels' (or 'seclevs' for short) to manage player access to various features on its servers. There are default, hardcoded levels setup but it is strongly advised that server owners take the time to setup their own specific seclev definitions.


Read more...

Blacklisting & Whitelisting

A player blacklists is the list of players who are not allowed to play on a given server. A whitelist is the inverse of a blacklist; if enabled, only those on the whitelist will be allowed to play.

The contents of the file securitysetup.cfg in /Security should look something like this:

# Security setup

# Set to 1 to allow only the names in the whitelist or 0 to disallow the names in the blacklist
whitelist_active = 0
whitelist_file = Security/whitelist.cfg
blacklist_file = Security/blacklist.cfg

# Path to file where security levels are defined
seclevs_file = Security/seclevs.cfg

Note: The whitelist overrides the blacklist if enabled.

Whitelist

If you are using the whitelist, then at the path specified in whitelist_file you can create a file that looks something like this:

# Whitelist format: name; anothername; yetanothername;
whitelist =
name;
anothername;
yetanothername;

Simply add usernames in this way to allow only those players access to the server.

Blacklist

If you are using the blacklist, then at the path specified in blacklist_file you can create a file that looks something like this:

# Blacklist format: name; IP; expiration time and date h:m:s:d:M:y; reason;
# IP of 0.0.0.0 means no IP is banned, and the user is just banned by username.
# Blank username means no user is banned for that entry and it's just by IP.
# The time is in C++ struct tm format except for the year, which is human readable. Get relative times from /listbans on the console.
#       eg: 10:30:0:31:11:2050 is 10:30 AM on the 31st of December 2050AD

blacklist =
name1; 0.0.0.0; 10:30:0:31:11:2050; Banned;
name2; 12.34.45.78; 10:30:0:31:11:2050; Banned;

Simply add player details in the format described to ban them from the server. Alternatively, just use the ban menus or rcon commands in game to ban users. Note that January is the 0th month

Managing Instability

As Alpha software, the KAG server in certain builds is very unstable. Build are sometimes crash prone but it varies from release to release due to new features mixed with bug fixes. As such, it is recommended practice to run the server in a keepalive script, which will restart it whenever it crashes. In addition, many people restart their server once a day, during the hours of least usage, to help decrease the risk of a crash while the server is being played upon.

Keep-alive Scripts

Linux/Mac

Trelawney's Keepalive Script, dedi.sh, will restart the KAG server 5 seconds after it crashes. Download it here.
If retyping/using copy and paste, make sure word wrapping is turned off in you text editor. (In nano, use nano -w dedi.sh .)
Once created, be sure to make the script executable with chmod +x dedi.sh.

#!/bin/bash
echo "Running KAG dedicated server"
echo "TO SET IP/PORT/SLOTS/PASSWORD ADD THESE COMMAND PARAMS: ip 127.0.0.1 port 50213 slots 32 password pass123"
mv KAGdedi.tmp KAGdedi
chmod +x KAGdedi
until ./KAGdedi nolauncher autostart Scripts/dedicated_autostart.gm autoconfig Scripts/dedicated_autoconfig.gm; do
        echo "KAG server running"
        sleep 5
done

To use, run the script: ./dedi.sh instead of the usual ./KAGdedi

Windows

The Beaz's Keepalive Script, dedi.bat, will restart the KAG server 5 seconds after it crashes. To use, create a text file, paste/type in the script below, and save it as dedi.bat.

@ECHO off
 
:restart
echo (%time%) Server Started - close this window to prevent restart.
 
start /wait KAG.exe nolauncher autostart Scripts/dedicated_autostart.gm autoconfig Scripts/dedicated_autoconfig.gm
 
echo (%time%) WARNING: Server closed or crashed, restarting.
 
goto restart

To make it work on Windows Vista or 7 you need to disable Windows Error Reporting. To do so:

  • Run regedit.exe
  • Modify HKCU\Software\Microsoft\Windows\Windows Error Reporting\DontShowUI entry with value 1

Daily Server Restarts

If a KAG server is running in a keepalive script, a scheduled task that kills the server once a day is, effectively, a daily restart because the keepalive script will automatically restart the server.

Linux/Mac - Cronjob

This script will kill all instances of KAGdedi at 3 AM.

  1. Use crontab -e to create a new cronjob. This will open your default text editor.
  2. In the text editor, type:
    0 3 * * * pkill -1 KAGdedi
  3. Close editor. Cronjob installed!

Windows - Task Scheduler

"Needs info"

Checking for Updates

So far there is not a public script to restart a server when an update is available, but the following logic should be able to be combined with a restart script above to restart a server once an update is available.

curl -s http://update.kag2d.com/linux32-dedicated-release/App/version.txt | head -n1 | cut -d ' ' -f2
1337154874-636-6e12e0f833b0

When that string (the 2nd whitespace-delimited element of the first line of that URL) changes, an update is available. The first number is the unix timestamp of the build, the 2nd is the code revision, the 3rd is a hex identifier used internally by the developers. You should be able to just monitor for a change. You could also use logic involving watching the first two parts of the string to see if they increment, but the format of this string may change in the future.