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