]> git.pld-linux.org Git - packages/dbus.git/blob - messagebus.init
- respawn
[packages/dbus.git] / messagebus.init
1 #!/bin/sh
2 #
3 # messagebus    The D-BUS systemwide message bus
4 #
5 # chkconfig:    345 22 85
6 #
7 # description:  This is a daemon which broadcasts notifications of system
8 #               events and other messages.
9 #
10 # pidfile:      /var/run/dbus.pid
11
12 # Source function library
13 . /etc/rc.d/init.d/functions
14
15 # Get network config
16 . /etc/sysconfig/network
17
18 # Check that networking is up.
19 if is_yes "${NETWORKING}"; then
20         if [ ! -f /var/lock/subsys/network ]; then
21                 msg_network_down "D-BUS Message bus"
22                 exit 1
23         fi
24 else
25         exit 0
26 fi
27
28 start() {
29         # Check if the service is already running?
30         if [ -f /var/lock/subsys/messagebus ]; then
31                 msg_already_running "D-BUS Message bus"
32                 return
33         fi
34
35         emit starting messagebus
36         msg_starting "D-BUS Message bus"
37         # if capability is modular, load it
38         if modinfo capability >/dev/null 2>&1; then
39                 modprobe -s capability
40         fi
41         dbus-uuidgen --ensure
42         daemon --pidfile dbus.pid /usr/bin/dbus-daemon --system
43         RETVAL=$?
44         if [ $RETVAL -eq 0 ] ; then
45                 touch /var/lock/subsys/messagebus
46                 emit --no-wait started messagebus
47         fi
48 }
49
50 stop() {
51         if [ ! -f /var/lock/subsys/messagebus ]; then
52                 msg_not_running "D-BUS Message bus"
53                 return
54         fi
55
56         # Stop daemons.
57         emit stopping messagebus
58         msg_stopping "D-BUS Message bus"
59         killproc --pidfile dbus.pid dbus-daemon
60         rm -f /var/lock/subsys/messagebus /var/run/dbus.pid
61         emit --no-wait stopped messagebus
62 }
63
64 condrestart() {
65         if [ ! -f /var/lock/subsys/messagebus ]; then
66                 msg_not_running "D-BUS Message bus"
67                 RETVAL=$1
68                 return
69         fi
70
71         stop
72         start
73 }
74
75 reload() {
76         if [ ! -f /var/lock/subsys/messagebus ]; then
77                 msg_not_running "D-BUS Message bus"
78                 RETVAL=7
79                 return
80         fi
81
82         msg_reloading "D-BUS Message bus"
83         killproc --pidfile dbus.pid dbus-daemon -HUP
84         RETVAL=$?
85 }
86
87 upstart_controlled
88
89 RETVAL=0
90 # See how we were called.
91 case "$1" in
92   start)
93         start
94         ;;
95   stop)
96         stop
97         ;;
98   restart)
99         stop
100         start
101         ;;
102   try-restart)
103         condrestart 0
104         ;;
105   reload|force-reload)
106         reload
107         ;;
108   status)
109         status --pidfile dbus.pid messagebus dbus-daemon
110         RETVAL=$?
111         ;;
112   *)
113         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
114         exit 3
115 esac
116
117 exit $RETVAL
This page took 1.187612 seconds and 3 git commands to generate.