#!/bin/sh # # xpilot-ng-server This shell script takes care of starting and stopping # the xpilot-ng game server. # # chkconfig: - 15 85 # description: The xpilot-ng server supports playing networked \ # multi-player games. # processname: xpilot-ng-server # config: /etc/sysconfig/xpilot-ng-server # pidfile: /var/run/xpilot-ng-server.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 exec="/usr/bin/xpilot-ng-server" prog=$(basename $exec) pidfile=/var/run/$prog.pid [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog lockfile=/var/lock/subsys/$prog start() { echo -n $"Starting Xpilot game server: " if [ -n "`/sbin/pidof $prog`" ]; then echo -n $"$prog already running" failure echo return 1 fi # This doesn't properly detect startup failures daemon --user games $exec $XPILOTD_OPTIONS >>/var/log/xpilot.log 2>&1 & retval=$? if [ $retval -eq 0 ]; then success touch $lockfile pidofproc $prog > $pidfile else failure fi echo return $retval } stop() { echo -n $"Stopping Xpilot game server: " killproc $prog retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop start } reload() { restart } force_reload() { restart } fdr_status() { status $prog } case "$1" in start|stop|restart|reload) $1 ;; force-reload) force_reload ;; status) fdr_status ;; condrestart|try-restart) [ ! -f $lockfile ] || restart ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}" exit 2 esac