1 (edited by daeli 2009-02-24 13:44:16)

Topic: Debian init.d script

Hello there - this is for everyone using debian:

----------------------------------------------------

#!/bin/sh

DIR="/usr/local/games/teeworlds"
CONF="conf.cfg"

case "$1" in
        start)
        echo "Starting Teeworlds Server..."
        start-stop-daemon --start  --chdir $DIR --background \
                --chuid games:games --exec $DIR/teeworlds_srv -- -f $DIR/$CONF
        PID=`ps ax | grep 'teeworlds_srv' | awk '{print $1}'| sed 2d`
        echo $PID > /var/run/teeworlds.pid
        echo "Started"
        ;;

        stop)
        echo "Stopping Teeworlds Server..."
        start-stop-daemon --stop --pidfile /var/run/teeworlds.pid
        echo "Stopped"
        ;;

        restart)
                $0 stop
                sleep 1
                $0 start
        ;;

        *)
        echo "Usage: /etc/init.d/teeworlds {start|stop}"
        exit 1
esac

exit 0



----------------------------------------------------

Use /etc/init.d/teeworlds to start/stop/restart your server

Greetings,
Daeli

2

Re: Debian init.d script

Great script! Thanks a lot smile

~{MonkeyStyle}~ - Instagib Teeworlds Clan
VISIT US: http://www.monkeystyle.tk
Check out our IRC channel: #monkeystyle on QuakeNet || Also check out the TeeWiki: http://teewiki.info

3

Re: Debian init.d script

Maybe you wanna make this sticky smile?

4

Re: Debian init.d script

Unfortunately this script only supports one teeworlds server instance.

5

Re: Debian init.d script

That was good, daeli, but apparently we have a pair of problems here.

1.- As Magnet says, it only allows one server instance, but I'm working on that right now doing multiple scripts and config
2.- Apparently, at least on my Ubuntu 8.04 x64, teeworlds_srv spans two processes, kill the first one, and it's the second the one that serves the game, so then, when you are launching the script, and looks for the PID ( PID=`ps ax | grep 'teeworlds_srv' | awk '{print $1}'| sed 2d` ), if it's done too fast, it gets the incorrect PID (the first one), and later, it doesn't know how to stop it.

The solution is adding right before that line a sleep command, for a second or two, so it gets the correct PID.

Thanks anyway, it saved me some work big_smile

ITC Teeworlds Server Admin
Madrid - Spain