#
# messagebus The D-BUS systemwide message bus
#
-# chkconfig: 345 97 03
+# chkconfig: 345 22 85
#
# description: This is a daemon which broadcasts notifications of system
# events and other messages.
#
-
+# pidfile: /var/run/dbus.pid
# Source function library
. /etc/rc.d/init.d/functions
+upstart_controlled
+
# Get network config
. /etc/sysconfig/network
# Check that networking is up.
if is_yes "${NETWORKING}"; then
if [ ! -f /var/lock/subsys/network ]; then
- # nls "ERROR: Networking is down. %s can't be run." messagebus
- msg_network_down messagebus
+ msg_network_down "D-BUS Message bus"
exit 1
fi
else
exit 0
fi
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/messagebus ]; then
+ msg_already_running "D-BUS Message bus"
+ return
+ fi
+
+ emit starting JOB=messagebus
+ msg_starting "D-BUS Message bus"
+ # if capability is modular, load it
+ if modinfo capability >/dev/null 2>&1; then
+ modprobe -s capability
+ fi
+ dbus-uuidgen --ensure
+ daemon --pidfile dbus.pid /usr/bin/dbus-daemon --system
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ] ; then
+ touch /var/lock/subsys/messagebus
+ emit --no-wait started JOB=messagebus
+ fi
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/messagebus ]; then
+ msg_not_running "D-BUS Message bus"
+ return
+ fi
+
+ # Stop daemons.
+ emit stopping JOB=messagebus
+ msg_stopping "D-BUS Message bus"
+ killproc --pidfile dbus.pid dbus-daemon
+ rm -f /var/lock/subsys/messagebus /var/run/dbus.pid
+ emit --no-wait stopped JOB=messagebus
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/messagebus ]; then
+ msg_not_running "D-BUS Message bus"
+ RETVAL=$1
+ return
+ fi
+
+ stop
+ start
+}
+reload() {
+ if [ ! -f /var/lock/subsys/messagebus ]; then
+ msg_not_running "D-BUS Message bus"
+ RETVAL=7
+ return
+ fi
+
+ msg_reloading "D-BUS Message bus"
+ killproc --pidfile dbus.pid dbus-daemon -HUP
+ RETVAL=$?
+}
+
+RETVAL=0
# See how we were called.
case "$1" in
start)
- # Check if the service is already running?
- if [ ! -f /var/lock/subsys/messagebus ]; then
- # show "Starting %s service" messagebus
- msg_starting messagebus
- daemon dbus-daemon-1 --system
- RETVAL=$?
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/messagebus
- else
- # show "%s service is already running." messagebus
- msg_already_running messagebus
- fi
+ start
;;
stop)
- if [ -f /var/lock/subsys/messagebus ]; then
- # Stop daemons.
- # show "Stopping %s service" messagebus
- msg_stopping messagebus
- killproc dbus-daemon-1
- rm -f /var/lock/subsys/messagebus
- rm -f /var/run/dbus/pid
- else
- # show "%s service is not running." messagebus
- msg_not_running messagebus
- fi
+ stop
;;
restart)
- $0 stop
- $0 start
- exit $?
+ stop
+ start
;;
- reload)
- if [ -f /var/lock/subsys/messagebus ]; then
- # show "Reload %s service" messagebus
- msg_reloading messagebus
- killproc dbus-daemon-1 -HUP
- RETVAL=$?
- else
- # show "%s service is not running." messagebus
- msg_not_running messagebus >&2
- RETVAL=7
- fi
+ try-restart)
+ condrestart 0
;;
- force-reload)
- # if program allows reloading without stopping
- $0 reload
-
- # or if it doesn't
- $0 restart
-
- exit $?
+ reload|force-reload)
+ reload
;;
status)
- status messagebus
+ status --pidfile dbus.pid messagebus dbus-daemon
RETVAL=$?
;;
*)
- # show "Usage: %s {start|stop|restart|reload|force-reload|status}"
- msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+ msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
exit 3
esac
exit $RETVAL
-
-# This must be last line !
-# vi:syntax=sh:tw=78:ts=8:sw=4