xref: /OK3568_Linux_fs/buildroot/package/dbus/S30dbus (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2#
3# messagebus:   The D-BUS systemwide message bus
4#
5# chkconfig: 345 97 03
6# description:  This is a daemon which broadcasts notifications of system events \
7#               and other messages. See http://www.freedesktop.org/software/dbus/
8#
9# processname: dbus-daemon
10# pidfile: /run/messagebus.pid
11#
12
13# Create needed directories.
14[ -d /run/dbus ] || mkdir -p /run/dbus
15[ -d /var/lock/subsys ] || mkdir -p /var/lock/subsys
16[ -d /tmp/dbus ] || mkdir -p /tmp/dbus
17
18RETVAL=0
19
20start() {
21    printf "Starting system message bus: "
22
23    dbus-uuidgen --ensure
24    dbus-daemon --system
25    RETVAL=$?
26    echo "done"
27    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dbus-daemon
28}
29
30stop() {
31    printf "Stopping system message bus: "
32
33    ## we don't want to kill all the per-user $processname, we want
34    ## to use the pid file *only*; because we use the fake nonexistent
35    ## program name "$servicename" that should be safe-ish
36    killall dbus-daemon
37    RETVAL=$?
38    echo "done"
39    if [ $RETVAL -eq 0 ]; then
40        rm -f /var/lock/subsys/dbus-daemon
41        rm -f /run/messagebus.pid
42    fi
43}
44
45# See how we were called.
46case "$1" in
47    start)
48        start
49        ;;
50    stop)
51        stop
52        ;;
53    restart)
54        stop
55        start
56        ;;
57    condrestart)
58        if [ -f /var/lock/subsys/$servicename ]; then
59            stop
60            start
61        fi
62        ;;
63    reload)
64        echo "Message bus can't reload its configuration, you have to restart it"
65        RETVAL=$?
66        ;;
67    *)
68        echo "Usage: $0 {start|stop|restart|condrestart|reload}"
69        ;;
70esac
71exit $RETVAL
72