A Teeworlds dedicated server with Ubuntu and autostart on boot

I installed it in Xubuntu 12.04 and in a Raspberry PI with Raspbian/Debian.
You'll not need to use ‘screen’ and Teeworlds will be a service in the system.

Let's go!

Install teeworlds:

sudo apt-get install teeworlds teeworlds-server

Create directory and set the firewall:

sudo mkdir -p /var/games/teeworlds  
sudo ufw allow 8303 

Create the Teeworlds config file:

sudo vi /var/games/teeworlds/teeworlds\_srv.cfg

Paste these lines, by example:

sv\_name Ubuntu Teeworlds Server  
sv\_motd Welcome!  
sv\_gametype ctf  
sv\_warmup 0  
sv\_map ctf1  
sv\_max\_clients 12  
sv\_scorelimit 1000  
sv\_rcon\_password your\_password\_here  
sv\_timelimit 20  
sv\_port 8303  
sv\_external\_port 8303  
sv\_max\_clients 12  
sv\_tournament\_mode 0  
sv\_teamdamage 0  
sv\_powerups 1  
logfile /var/log/teeworlds-server.log  
sv\_register 1

Set permissions and create log file:

sudo chown root:your_group -R /var/games/teeworlds
sudo chmod 770 -R /var/games/teeworlds
sudo touch /var/log/teeworlds-server.log
sudo chown root:your_group /var/log/teeworlds-server.log
sudo chmod 770 /var/log/teeworlds-server.log

Know your run-level:

runlevel

Paste this script:

sudo vi /etc/init.d/teeworlds-server

and change:

In Default-Start: 2 3 5 Set your current level (my run-level is 2)
In '–chuid games:games' set your normal user as –chuid your_user:your_user

#! /bin/sh -e  
\# Copyright (c) 2008 Stas Sushkov (stas@nerd.ro)  
\# Released under GPL 3.0 (https://creativecommons.org/licenses/GPL/2.0/)  
\# Author: Stas Sushkov, Sept. 2008  
\### BEGIN INIT INFO  
\# Provides:          teeworlds-server  
\# Required-Start:    $network  
\# Required-Stop:  
\# **Default-Start:   2** 3 5  
\# Default-Stop:      0 1 6  
\# Short-Description: teeworlds-server daemon, providing teeworlds server administration  
\# Description:       Teeworlds is an online multi-player plat‐form 2D shooter.  
\# teeworlds-server is a server for Teeworlds game.  
\### END INIT INFO  
  
\# Used variables  
TWSERVER\_BIN\_DIR=/usr/games  
TWSERVER\_DIR=/var/games/teeworlds  
TWSERVER\_CONFIG=teeworlds\_srv.cfg  
TWSERVER\_NAME=teeworlds-server  
TWSERVER\_OPTS="-q -f $TWSERVER\_DIR/$TWSERVER\_CONFIG"  
TWSERVER\_PIDFILE=$TWSERVER\_DIR/$TWSERVER\_NAME.pid  
  
\# Loading init-functions  
. /lib/lsb/init-functions  
  
\# Check for missing binaries  
test -x $TWSERVER\_BIN\_DIR/$TWSERVER\_NAME || { echo "$TWSERVER\_BIN\_DIR/$TWSERVER\_NAME not installed";  
        if \[ "$1" = "stop" \]; then exit 0;  
 else exit 5; fi; }  
  
\# Check for existence of needed config file and read it  
test -r $TWSERVER\_DIR/$TWSERVER\_CONFIG || { echo "$TWSERVER\_DIR/$TWSERVER\_CONFIG not existing";  
 if \[ "$1" = "stop" \]; then exit 0;  
 else exit 6; fi; }  
  
case "$1" in  
 start)  
  log\_begin\_msg "Starting Teeworlds Server..."  
  umask 002  
  if start-stop-daemon -v --start --background \\  
   --pidfile $TWSERVER\_PIDFILE --make-pidfile \\  
   -d $TWSERVER\_DIR \\  
   --chuid **games:games** \\  
   --exec $TWSERVER\_BIN\_DIR/$TWSERVER\_NAME -- $TWSERVER\_OPTS; then  
   log\_end\_msg 0  
  else  
   log\_end\_msg $?  
  fi  
 ;;  
  
 stop)  
  log\_begin\_msg "Stopping Teeworlds Server..."  
  if start-stop-daemon --stop \\  
   --pidfile $TWSERVER\_PIDFILE; then  
   log\_end\_msg 0  
  else  
   log\_end\_msg $?  
  fi  
 ;;  
  
 restart|force-reload)  
  "$0" stop && "$0" start  
 ;;  
  
 \*)  
 echo "Usage: /etc/init.d/teeworlds-server {start|stop|restart}"  
  exit 1  
 ;;  
esac  
  
exit 0 

Set permissions:

sudo chown root:root /etc/init.d/teeworlds-server
sudo chmod 755 /etc/init.d/teeworlds-server

Is all OK? (run as normal user):

/etc/init.d/teeworlds-server start
ps -ef | grep teeworlds
`cat /var/log/teeworlds-server.log`
/etc/init.d/teeworlds-server stop

Set the autostart on boot:

sudo update-rc.d teeworlds-server defaults

Now, just enter your IP in the Host address in Teeworlds game and you'll connect to your map.
Thanks to Stas for the info :) Cheers!