Thursday, August 31, 2006

Tremulous Init Script

edit: to have a cron job restart the deamon, I had to specify the whole path to the start-stop-daemon.


I modified an init script from http://wiki.splitbrain.org/q3aserver

Setting it up to chroot shouldn't be to difficult, I just haven't taken the time to wrap my head around the path insanity that follows :)

I've named it tremded.x86 and it is placed in /etc/init.d/ as an executable (chmod u+x should do)



#! /bin/sh
set -e

BASEPATH="/usr/local/tremulous/.tremulous"
BINARY="tremded.x86"
DAEMON="$BASEPATH/$BINARY"
OPTIONS="2>>./tuplestestserver.log +set dedicated 2 +set fs_game base2 +exec server.cfg"
RUNAS="tremulous:tremulous"
PIDFILE="$BASEPATH/$BINARY.pid"

test -x $DAEMON || exit 0

#export HOME=$BASEPATH
export HOME=/usr/local/tremulous

case "$1" in
start)
echo -n "Starting Tremulous Server"
cd $BASEPATH
start-stop-daemon --start --quiet -c $RUNAS --pidfile $PIDFILE \
-N -2 -m -b -d $BASEPATH --exec $DAEMON -- $OPTIONS
echo "."
;;
stop)
echo -n "Stopping Tremulous Server"
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--exec $DAEMON
echo "."
;;
restart|force-reload)
echo -n "Cycling Tremulous Server - "
$0 stop
sleep 3
$0 start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0

No comments: