#!/bin/sh
#
# crossfire This shell script takes care of starting and stopping
# the crossfire game server.
#
# chkconfig: - 15 85
# description: The crossfire server supports playing networked \
# multi-player games.
# processname: crossfire
# config: /etc/sysconfig/crossfire
# pidfile: /var/run/crossfire.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/crossfire"
prog=$(basename $exec)
pidfile=/var/run/$prog.pid
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
echo -n $"Starting Crossfire game server: "
if [ -n "`/sbin/pidof $prog`" ]; then
echo -n $"$prog already running"
failure
echo
return 1
fi
if selinuxenabled ; then
/usr/sbin/semanage port -a -t crossfire_port_t -p tcp 13327 &>/dev/null || :
fi
daemon --user crossfire $exec $CROSSFIRE_OPTIONS -detach -log /var/log/crossfire/crossfire.log
retval=$?
if [ $retval -eq 0 ]; then
success
touch $lockfile
pidofproc $prog > $pidfile
else
failure
fi
echo
return $retval
}
stop() {
echo -n $"Stopping Crossfire game server: "
killproc $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
if selinuxenabled ; then
/usr/sbin/semanage port -d -t crossfire_port_t -p tcp 13327 &>/dev/null || :
fi
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