]> git.pld-linux.org Git - packages/dbus.git/blob - messagebus.init
up to 1.14.10
[packages/dbus.git] / messagebus.init
1 #!/bin/sh
2 #
3 # messagebus    The D-BUS systemwide message bus
4 #
5 # chkconfig:    345 22 78
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         msg_starting "D-BUS Message bus"
36         # if capability is modular, load it
37         if modinfo capability >/dev/null 2>&1; then
38                 modprobe -s capability
39         fi
40         dbus-uuidgen --ensure
41         daemon --pidfile dbus.pid --redirfds /usr/bin/dbus-daemon --system
42         RETVAL=$?
43         if [ $RETVAL -eq 0 ] ; then
44                 touch /var/lock/subsys/messagebus
45         fi
46 }
47
48 stop() {
49         if [ ! -f /var/lock/subsys/messagebus ]; then
50                 msg_not_running "D-BUS Message bus"
51                 return
52         fi
53
54         # Stop daemons.
55         msg_stopping "D-BUS Message bus"
56         killproc --pidfile dbus.pid dbus-daemon
57         rm -f /var/lock/subsys/messagebus /var/run/dbus.pid
58 }
59
60 condrestart() {
61         if [ ! -f /var/lock/subsys/messagebus ]; then
62                 msg_not_running "D-BUS Message bus"
63                 RETVAL=$1
64                 return
65         fi
66
67         stop
68         start
69 }
70
71 reload() {
72         if [ ! -f /var/lock/subsys/messagebus ]; then
73                 msg_not_running "D-BUS Message bus"
74                 RETVAL=7
75                 return
76         fi
77
78         msg_reloading "D-BUS Message bus"
79         killproc --pidfile dbus.pid dbus-daemon -HUP
80         RETVAL=$?
81 }
82
83 RETVAL=0
84 # See how we were called.
85 case "$1" in
86   start)
87         start
88         ;;
89   stop)
90         stop
91         ;;
92   restart)
93         stop
94         start
95         ;;
96   try-restart)
97         condrestart 0
98         ;;
99   reload|force-reload)
100         reload
101         ;;
102   status)
103         status --pidfile dbus.pid messagebus dbus-daemon
104         RETVAL=$?
105         ;;
106   *)
107         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
108         exit 3
109 esac
110
111 exit $RETVAL
This page took 0.041043 seconds and 3 git commands to generate.