Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > by-pkgid > 4bc182a425f6c8310683ad65274c5ef2 > files > 2

ejabberd-2.1.3-2mdv2010.1.src.rpm

#!/bin/sh
#
# chkconfig: 345 70 30
# description: ejabberd is a Jabber (XMPP) instant messaging system server

### BEGIN INIT INFO
# Provides: ejabberd
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: ejabberd is a Jabber (XMPP) instant messaging system server
# Description: This startup script launches ejabberd, a instant messaging system server using xmpp.
### END INIT INFO

# Source function library
. /etc/rc.d/init.d/functions

# Set defaults and read configuration
NAME=ejabberd
LOCKFILE=/var/lock/subsys/$NAME

[ -f /etc/sysconfig/ejabberd ] && . /etc/sysconfig/ejabberd

if [ ! "$CONFIG_FILE" ]; then
    CONFIG_FILE=/etc/ejabberd/ejabberd.cfg
fi 

start() {
    res=0
    if [ ! -f $LOCKFILE ]; then
	echo -n "Starting $NAME:"
	daemon /usr/sbin/ejabberdctl start --config $CONFIG_FILE \
	 	--ctl-config /etc/ejabberd/ejabberdctl.cfg \
	 	--logs "/var/log/ejabberd" \
	 	--spool "/var/lib/ejabberd/spool" 2>/dev/null

	res=$?
	[ $res -eq 0 ] && touch $LOCKFILE
	echo
    fi
    return $res
}

stop() {
    echo -n "Stopping $NAME:"
    daemon /usr/sbin/ejabberdctl stop 2>/dev/null
    res=$?
    if [ $res -eq 0 ]; then
	success
       	rm -f $LOCKFILE
    else
	failure
    fi
    echo
    return $res
}

ejabberd_status() {
    su ejabberd -c "ejabberdctl --node ejabberd@`hostname -s` status"
}

restart() {
    stop
    start
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    reload|restart)
        restart
        ;;
    condreload|condrestart)
	if [ -f $LOCKFILE ]; then
	    restart
	fi
        ;;
    status)
        ejabberd_status
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|reload|condrestart|condreload|status}"
        exit 1
	;;
esac

exit $?