#! /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: 3 5 # Default-Stop: 0 1 2 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. # We want it to be active in runlevels 3 # and 5, as these are the runlevels with the network # available. ### END INIT INFO # Used variables TWSERVER_BIN_DIR=/usr/games TWSERVER_CONFIG=/var/games/teeworlds/teeworlds_srv.cfg TWSERVER_DIR=/var/games/teeworlds TWSERVER_OPTS="-q -f $TWSERVER_CONFIG" TWSERVER_NAME=teeworlds-server TWSERVER_PIDFILE=/var/games/teeworlds/$TWSERVER_NAME.pid # Loading init-functions . /lib/lsb/init-functions # Check for missing binaries test -x $TWSERVER_BIN || { echo "$TWSERVER_BIN 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_CONFIG || { echo "$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 --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|force-reload}" exit 1 ;; esac exit 0