2003-04-06 Havoc Pennington <hp@pobox.com>
[platform/upstream/dbus.git] / bus / messagebus.in
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-1
10 # pidfile: @DBUS_SYSTEM_PID_FILE@
11 #
12
13 # Sanity checks.
14 [ -x @EXPANDED_BINDIR@/dbus-daemon-1 ] || exit 0
15
16 # Source function library.
17 . @EXPANDED_SYSCONFDIR@/rc.d/init.d/functions
18
19 RETVAL=0
20
21 start() {
22     echo -n $"Starting system message bus: "
23     daemon --check messagebus dbus-daemon-1 --system
24     RETVAL=$?
25     echo
26     [ $RETVAL -eq 0 ] && touch @EXPANDED_LOCALSTATEDIR@/lock/subsys/messagebus
27 }
28
29 stop() {
30     echo -n $"Stopping system message bus: "
31
32     ## we don't want to kill all the per-user dbus-daemon-1, we want
33     ## to use the pid file *only*; because we use the fake nonexistent 
34     ## program name "messagebus" that should be safe-ish
35     killproc messagebus -TERM
36     RETVAL=$?
37     echo
38     if [ $RETVAL -eq 0 ]; then
39         rm -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/messagebus
40     fi
41 }
42
43 # See how we were called.
44 case "$1" in
45     start)
46         start
47         ;;
48     stop)
49         stop
50         ;;
51     status)
52         status messagebus
53         RETVAL=$?
54         ;;
55     restart)
56         stop
57         start
58         ;;
59     condrestart)
60         if [ -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/messagebus ]; then
61             stop
62             start
63         fi
64         ;;
65     reload)
66         echo "Message bus can't reload its configuration, you have to restart it"
67         RETVAL=$?
68         ;;
69     *)
70         echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
71         ;;
72 esac
73 exit $RETVAL