1

Topic: How Do I Auto-Start Teeworlds Server on Ubuntu?

I looked it up online to run stuff on my rc.local, but it seems that there are some things to consider.

First, you need multiple "exit" lines of command for rc.local. I'm not sure how Teeworlds handles this, because you need it to keep it running.

Second, I have another line of command for auto-starting TeamSpeak.

Anybody happen to know how this works?

2

Re: How Do I Auto-Start Teeworlds Server on Ubuntu?

I'm not sure what's the problem. Why can't you start a teeworlds server like you start TeamSpeak?

Not Luck, Just Magic.

3

Re: How Do I Auto-Start Teeworlds Server on Ubuntu?

In Ubuntu, there's a file called "rc.local" which you put your commands into so that when the computer is turned on, it runs the script in rc.local. However, I'm not a huge expert on it and there doesn't seem to be much of a guide out there for it.

Currently, I've found this so far and the links are broken. I'm assuming that either the IP address changed and/or just took the entire server down. (Anybody have those start scripts downloaded before in 2012? If you did, please post them here!)

I found that guy's GitHub here but it seems like he didn't upload his start script work for it. Pretty much the same story here which is a German TW community site (anybody on that site downloaded or talked about it?).

I found this guide in which I don't understand some parts probably because of Ubuntu updates and I'm not familiar with older versions of Ubuntu. I have no idea what changing Default-Start to 2 3 5 does, because it's just information for people to see, not really a functional thing.

Anybody familiar with a Teeworlds player with an alias "Stas" perhaps?

#! /bin/sh -e
# Copyright (c) 2008 Stas Sushkov (stas@nerd.ro)
# Released under GPL 3.0 (http://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

4

Re: How Do I Auto-Start Teeworlds Server on Ubuntu?

There's easier and more secure way to start servers on Linux - use crontab!
Type in terminal
crontab -e
it will open text editor - add a line

@reboot cd /path/to/teeworlds && /usr/bin/setsid ./teeworlds_srv >server.log 2>&1

Save, exit, reboot - Teeworlds server will start at boot, using your own user account, not root.