#!/bin/sh
#
# messagebus:	The D-BUS systemwide message bus
#
# chkconfig:	345 10 92
# description:	This is a daemon which broadcasts notifications of system events
#		and other messages. See http://www.freedesktop.org/software/dbus/
#
# processname:	dbus-daemon
# config:	/etc/dbus-1
# pidfile:	/var/run/messagebus.pid
#

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

DAEMON=/bin/dbus-daemon
LOCKFILE=/var/lock/subsys/messagebus
PIDFILE=/var/run/messagebus.pid
USER=messagebus

RETVAL=0

start() {
    if [ -x /bin/dbus-uuidgen ] ; then
        /bin/dbus-uuidgen --ensure
    fi

    msg_starting $"system message bus"
    start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --no-announce -- $DAEMON --system
    RETVAL=$?
    return $RETVAL
}

stop() {
    msg_stopping $"system message bus"
    stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --no-announce -- $DAEMON -TERM
    RETVAL=$?
    rm -f "$PIDFILE" ||:
    return $RETVAL
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
	status --pidfile "$PIDFILE" --expect-user "$USER" -- $DAEMON
	RETVAL=$?
        ;;
    restart)
        stop
        start
        ;;
    condstop)
	if [ -f "$LOCKFILE" ]; then
	    stop
	fi
	;;
    condrestart)
    	;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condstop|condrestart}"
        ;;
esac

exit $RETVAL
