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