2003-04-11 Havoc Pennington <hp@redhat.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         rm -f @DBUS_SYSTEM_PID_FILE@
41     fi
42 }
43
44 # See how we were called.
45 case "$1" in
46     start)
47         start
48         ;;
49     stop)
50         stop
51         ;;
52     status)
53         status messagebus
54         RETVAL=$?
55         ;;
56     restart)
57         stop
58         start
59         ;;
60     condrestart)
61         if [ -f @EXPANDED_LOCALSTATEDIR@/lock/subsys/messagebus ]; then
62             stop
63             start
64         fi
65         ;;
66     reload)
67         echo "Message bus can't reload its configuration, you have to restart it"
68         RETVAL=$?
69         ;;
70     *)
71         echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
72         ;;
73 esac
74 exit $RETVAL