1 (edited by Pvpede 2008-05-08 18:35:07)

Topic: [GUIDE] How to host a server on Linux

Hi TeeWars Community!

- Today, I will show you how to successfully host a server on a Linux Ubuntu.

Requirements:
* Teeworlds
* An OK internet speed
* Linux Ubuntu 7.X or 8.X

Index:
1.0: Your Router
1.1: Port Forwarding
2.0: Setting up server
2.1: Running the server (thanks to: Tweek)



Part 1.0: Your Router
First thing would be to find your router name. Can be found in REAL LIFE .
I have placed mine in my entrance in the house (:
- or, you can try copy + paste one of these ip's and put them into your address bar:
192.168.0.1
192.168.2.1
192.168.2.0
192.168.1.0
192.168.1.1
And you'll access the router, and sometimes, there will be a name!

Example: Mine looks like this :: http://pvpede.be/imuu/images/334601screenie1.png






Part 1.1: Port Forwarding
First thing, would be to go to this page: http://portforward.com/routers.htm
- then, go find your router .
Mine is a Belkin, but it wont care which one I choose, because every Belkin have the same interface + functions.
So, I chose "Belkin: F5D7633-4v2" - [ http://portforward.com/english/routers/ … rvices.htm ]
It'll tell me WHAT IP I should go to for accessing my router (:
- Mine is: http://192.168.2.1/

Next thing would be to find the page where you can do the port forwarding stuff.
- On mine: http://192.168.2.1/fw_virt.htm
Now, the confusing part ::
You'll need to forward the port: 8303 - UDP
On Belkin, this is so easy (will show you a picture later)!
You'll need to know your IP on your router - Mine is 192.168.2.4
The last digit (4 in my situation) is the most important in this configure!
It is your private router IP.
- Find mine, with testing with every digit up to 9 . Example: 192.168.2.9 and 192.168.2.8 and so on
In my router: http://pvpede.be/imuu/images/32360screenie2.png

And that should be it!



Part 2.0: Setting Up Server
First, find your TeeWorlds main folder .
Download this CFG file, and save it into your TeeWorlds Main Folder: http://rapidshare.com/files/95109680/teewars.cfg
- Now, how to modify this?!?!

sv_name Test
sv_gametype DM
sv_warmup 1
sv_map dm6
sv_maprotation ctf1 ctf2 dm6 dm2 dm1
sv_max_clients 8 
sv_scorelimit 25
rcon_password Remote Console Password Here
sv_port 8303
sv_register 1
masterserver master.teewars.com

Explanation:
sv_name = Your Server name
sv_gametype = Gametype. (DM = Deathmatch , TDM = Team Deathmatch, CTF = Capture the Flag)
sv_warmup = Warmup time
sv_map = Starting map
sv_maprotation = What map it should take after the one before
sv_max_clients = How many players that can connect
sv_scorelimit = How many kills, until the game ends.
rcon_password = Put your Remote Console Password Here
sv_port = Your port! Don't touch it.
sv_sendheartbeats = Online / LAN Setting. (1 = Online, 0 = LAN)
masterserver = Master server. Will check if your ports is fine  - Don't touch it

Now, it should be done. Save & close it!




Part 2.1: Running the Server (thanks to Tweek)
First, open "Terminal" .
Write: sudo -s
- enter your username-password
It'll now say: root@computername
- Now, write:
cd '/home/USERNAME/TEEWORLDSFOLDER'

Example: cd '/home/pvpede/Desktop/Programs/Teeworlds'
- Mine will now show: root@pvpedes-ubuntu:~/Desktop/Programs/Teeworlds#
Now, write:
./teeworlds_srv -f teewars.cfg

The server will start up!

Mine shows:

root@pvpedes-ubuntu:~/Desktop/Programs/Teewars# ./teewars_srv -f teewars.cfg
[47c4322d][server]: starting...
[47c4322d][config/load]: loading teewars.cfg
[47c4322d][datafile]: datafile loading. filename='data/maps/ctf1.map'
[47c4322d][server]: data/maps/ctf1.map crc is 15a863e5
[47c4322d][server]: server name is '[DS] Clan Server! DSClan.org'
[47c4322d][datafile]: loading data index=8 size=158
[47c4322d][]: 0x8285024 0 -> -1 (init)
[47c4322d][]: 0x82852f8 0 -> -1 (init)
[47c4322d][]: 0x82855cc 3212308 -> -1 (init)
[47c4322d][]: 0x82858a0 0 -> -1 (init)
[47c4322d][]: 0x8285b74 0 -> -1 (init)
[47c4322d][]: 0x8285e48 0 -> -1 (init)
[47c4322d][]: 0x828611c 0 -> -1 (init)
[47c4322d][]: 0x82863f0 0 -> -1 (init)
[47c4322d][]: 0x82866c4 0 -> -1 (init)
[47c4322d][]: 0x8286998 0 -> -1 (init)
[47c4322d][]: 0x8286c6c 0 -> -1 (init)
[47c4322d][]: 0x8286f40 0 -> -1 (init)
[47c4322d][game]: -- Team Death Match --
[47c4322d][server]: version 0.3 e2d7973c6647a13c
[47c4322d][engine/mastersrv]: refreshing master server addresses
[47c4322d][register]: refreshing ip addresses
[47c4322d][engine/mastersrv]: saving addresses
[47c4322d][register]: fetching server counts
[47c4322d][register]: choosen 'master3.teewars.com' as master, sending heartbeats
[47c4322d][register]: no firewall/nat problems detected
[47c4322d][register]: no firewall/nat problems detected
[47c4322d][register]: server registered

Updated 13:44 - 29'th of March // 2008
Updated 18:56 - 8'th of May // 2008

Core2Quad QX9650 12MB 4x3,00GHz - Razer Lachesis - Corsair 8 GB XMS2 DDRII PC6400 RAM DualChannel - Nvidia GeForce 9800GX2 1GB PCI-E - Windows Vista Ultimate EN 64-bit

2 (edited by Dragony 2008-02-26 21:43:24)

Re: [GUIDE] How to host a server on Linux

If you want a log file, use 'nohup ./teewars_srv -f configfile > logfile &'
If you don't want a log file, use 'nohup ./teewars_srv -f configfile > dev/null/ &'

Should work...


Sorry for my bad english

3

Re: [GUIDE] How to host a server on Linux

Thanks for the 'note' smile

Core2Quad QX9650 12MB 4x3,00GHz - Razer Lachesis - Corsair 8 GB XMS2 DDRII PC6400 RAM DualChannel - Nvidia GeForce 9800GX2 1GB PCI-E - Windows Vista Ultimate EN 64-bit

4

Re: [GUIDE] How to host a server on Linux

it irks me a lot that you tell people to run the teewars server with root privileges, which is totally unnecessary.
you can just leave the sudo command out and it should work just the same, but i would personally recommend setting up a seperate teewars user if you're serious about security issues.

5

Re: [GUIDE] How to host a server on Linux

You get the most important parts and it's great. As an addon I'll recommend anyone to use screen if you want the server to be up long. Screen keeps the application going even if you close the terminal or detaches the screen.
Type:

screen -S twserver

where twserver will be the name of the screen, and then:

./teeworlds_srv

which will start your server.

To detach the screen, press ctrl+a, then d. To resume the screen again, just open the terminal on the same account and type:

screen -r twserver

"twserver" is optional, but if you have multiple screens at the same time you must include it.

6

Re: [GUIDE] How to host a server on Linux

my init script:

$cat /etc/init.d/teeworlds

#!/sbin/runscript

opts="${opts}"
DIR="/usr/local/games/teeworlds"

depend() {
        need net
}

start() {
        ebegin "Starting TeeWorlds Server"
        start-stop-daemon --start  --chdir /usr/local/games/teeworlds --background \
            --chuid games:games --exec $DIR/teeworlds_srv -- -f $DIR/conf.cfg
        PID=`ps ax | grep 'teeworlds_srv' | awk '{print $1}'| sed 2d`
        echo $PID > /var/run/teeworlds.pid
        eend $? "Failed to start TeeWorlds Server"
}

stop() {
        ebegin "Stopping TeeWorlds Server"
        start-stop-daemon --stop --pidfile /var/run/teeworlds.pid
        eend $? "Failed to stop TeeWorlds Server"
}
nightmare@gentoo ~ $ uname -a
Linux gentoo 2.6.24 #2 SMP Tue Mar 11 00:47:50 EET 2008 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux

7 (edited by dotty 2008-03-29 12:14:58)

Re: [GUIDE] How to host a server on Linux

Running a gameserver as root? Sry, but it's against the philosophy of linux. Should run as user instead for security reasons. 
Did it this way:

as root:

ln -s /path/to/teeworldsfolder /tw

Where /path/... is the path to the Teeworlds folder, where you can find teeworlds and teeworlds_srv
Then you switch to an other console with ALT+CTRL+F2 (e.g., can take also 3 to 5, has same effect)
there you just type:

cd /tw

and then

teeworlds -f name.cfg

That's it. Stops with CTRL+C.

so far, dotty

ftp://dotty.homeunix.net
user/pass=teeworlds

8 (edited by Deep-Ocean 2008-03-30 00:16:28)

Re: [GUIDE] How to host a server on Linux

dotty wrote:

Running a gameserver as root? Sry, but it's against the philosophy of linux. Should run as user instead for security reasons.

root? xD
see `man start-stop-daemon`

start-stop-daemon --start  --chdir /usr/local/games/teeworlds --background \
            --chuid games:games --exec $DIR/teeworlds_srv -- -f $DIR/conf.cfg

and folder $DIR have ownuser:owngroup as games:games

&

$ ps auxf | grep teeworlds_srv
games     7885  0.7  0.1   5276  1336 ?        Ss   00:18   0:00 /usr/local/games/teeworlds/teeworlds_srv -f /usr/local/games/teeworlds/conf.cfg
nightmare@gentoo ~ $ uname -a
Linux gentoo 2.6.24 #2 SMP Tue Mar 11 00:47:50 EET 2008 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux

9

Re: [GUIDE] How to host a server on Linux

@Deep: You do it this way, but the things the others have posted run as root...!

ftp://dotty.homeunix.net
user/pass=teeworlds

10

Re: [GUIDE] How to host a server on Linux

hi all, i just set up some teeworlds servers for my clan and this is the init-script i use:

#! /bin/sh

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="div0 Teeworlds 1on1 Server"
NAME=teeworlds_srv
SRVCFG=div0.1on1.cfg
DAEMONDIR=/usr/local/games/teeworlds
DAEMON=$DAEMONDIR/$NAME
PIDFILE=/var/run/$NAME$SRVCFG.pid
SCRIPTNAME=/etc/init.d/teeworlds1on1

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

# Read config file if it is present.
#if [ -r /etc/default/$NAME ]
#then
#    . /etc/default/$NAME
#fi

#
#    Function that starts the daemon/service.
#
d_start() {
    start-stop-daemon --start --quiet -m --pidfile $PIDFILE \
        --chdir $DAEMONDIR --chuid games:games \
        --background --exec $DAEMON -- -f $SRVCFG
}

#
#    Function that stops the daemon/service.
#
d_stop() {
    start-stop-daemon --stop --quiet --pidfile $PIDFILE \
        --name $NAME
}

#
#    Function that sends a SIGHUP to the daemon/service.
#
d_reload() {
    start-stop-daemon --stop --quiet --pidfile $PIDFILE \
        --name $NAME --signal 1
}

case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    d_start
    echo "."
    ;;
  stop)
    echo -n "Stopping $DESC: $NAME"
    d_stop
    echo "."
    ;;
  #reload)
    #
    #    If the daemon can reload its configuration without
    #    restarting (for example, when it is sent a SIGHUP),
    #    then implement that here.
    #
    #    If the daemon responds to changes in its config file
    #    directly anyway, make this an "exit 0".
    #
    # echo -n "Reloading $DESC configuration..."
    # d_reload
    # echo "done."
  #;;
  restart|force-reload)
    #
    #    If the "reload" option is implemented, move the "force-reload"
    #    option to the "reload" entry above. If not, "force-reload" is
    #    just the same as "restart".
    #
    echo -n "Restarting $DESC: $NAME"
    d_stop
    sleep 1
    d_start
    echo "."
    ;;
  *)
    # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0

Im running debian linux on my server so i just took the skeleton for init-scripts thats provided with debian and adjusted it a bit.
Now i can just copy it and set a different config file for each server i want to run. Remember that the teeworlds directory and its contents has to belong to games:games.
The script Deep-Ocean posted uses the runscript interpreter which seems to be included only with gentoo linux.

greetz
Cpt.Chaos

11

Re: [GUIDE] How to host a server on Linux

Hi,

I REALLY need help on this... IMPORTANT: How do I open terminal? smile\
Thanks, please reply asap. big_smile

I'll be smarter if you try to be nicer. (lol big_smile )

12

Re: [GUIDE] How to host a server on Linux

omg. The world must take it's responability NOW. We need drivers licenses for using computers, srsly.

If you have managed to successfully install Linux, which involves partitioning, iso burning and other stuff that can seem tempting for the newb, how come you fail to search thru the very logical Applications-menu which is present in most linux distros enough to find the alternative "Terminal" which I find rather self-explanatory..

Official Teeworlds map developer and community moderator
Administrator for the Teeworlds community Teesites

13

Re: [GUIDE] How to host a server on Linux

Well, the problem is, I'm running vista...hehe...
You can check on my server thread, I posted something there. smile

I'll be smarter if you try to be nicer. (lol big_smile )

14

Re: [GUIDE] How to host a server on Linux

Yeah, chi11y, we need licenses. Oh, and linux does not have to involve partitioning. Just usually.

if($poster["intelligence"] == $intelligence["idiot"])
        deny_post($poster);

15

Re: [GUIDE] How to host a server on Linux

Roanoke wrote:

Yeah, chi11y, we need licenses. Oh, and linux does not have to involve partitioning. Just usually.

depends, if you use wubi nowadays windows users do not need to partition anything: http://wubi-installer.org/

Its almost a 1 click installer.

16

Re: [GUIDE] How to host a server on Linux

Roanoke wrote:

Yeah, chi11y, we need licenses. Oh, and linux does not have to involve partitioning. Just usually.

Partitioning is everything that in some way alters your partition scheme. Linux always does that on install except wubi, which alters one partition to make it beleive it is two partitions.. smile

Official Teeworlds map developer and community moderator
Administrator for the Teeworlds community Teesites

17 (edited by catpaw 2008-07-17 09:55:12)

Re: [GUIDE] How to host a server on Linux

Chi11y wrote:

which alters one partition to make it beleive it is two partitions.. smile

This is somehow wrong. Wubi just creates a big file on your windows partition, and loop mounts it. The linux system is thus running from a file from the windows partition. Other than creating normal files in it, the windows parition is not altered at all.

Also if you install traditional Linux on a empty computer, without windows preinstalled you just have to click "okay" at the installation process and don't have to know to anything about partitions.

18

Re: [GUIDE] How to host a server on Linux

catpaw wrote:
Chi11y wrote:

which alters one partition to make it beleive it is two partitions.. smile

This is somehow wrong. Wubi just creates a big file on your windows partition, and loop mounts it. The linux system is thus running from a file from the windows partition. Other than creating normal files in it, the windows parition is not altered at all.

Also if you install traditional Linux on a empty computer, without windows preinstalled you just have to click "okay" at the installation process and don't have to know to anything about partitions.

Okay, I've never used wubi so I just talked from what I've heard wink .

And even if you are installing linux fresh and just pressing okay you are indeed partitioning, even if it doesnt make you do anything tongue .

Official Teeworlds map developer and community moderator
Administrator for the Teeworlds community Teesites

19

Re: [GUIDE] How to host a server on Linux

Chi11y wrote:

And even if you are installing linux fresh and just pressing okay you are indeed partitioning, even if it doesnt make you do anything tongue .

So does windows :-)

20

Re: [GUIDE] How to host a server on Linux

"So does windows :-)"
nope, there you've to make partitions yourself...(have you ever set up a win xp?)

21

Re: [GUIDE] How to host a server on Linux

You need no partitioning if you e.g. use a kubuntu-live-cd

Antoine de Saint Exupéry: It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away.
Besides -  I am the gfx guy!

22

Re: [GUIDE] How to host a server on Linux

No no, Wubi creates a virtual file system for the operating system to run in. Sort of like a "Sandbox" that the os lives in. In Windows, the vfs appears as a file in the file manager, but to the operating system inside it, the vfs appears as a partition.

Ubuntu Member
Power tends to corrupt and absolute power corrupts absolutely. - Lord Acton

23

Re: [GUIDE] How to host a server on Linux

Landil wrote:

You need no partitioning if you e.g. use a kubuntu-live-cd

You would if you wanted to install it wink

Official Teeworlds map developer and community moderator
Administrator for the Teeworlds community Teesites

24

Re: [GUIDE] How to host a server on Linux

Is there a substitute for terminal? I have windows. smile

I'll be smarter if you try to be nicer. (lol big_smile )

25

Re: [GUIDE] How to host a server on Linux

nope.
there is only a MS-DOS prompt...