summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-core/dbus/dbus/dbus-1.init
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-core/dbus/dbus/dbus-1.init')
-rw-r--r--meta-oe/recipes-core/dbus/dbus/dbus-1.init111
1 files changed, 111 insertions, 0 deletions
diff --git a/meta-oe/recipes-core/dbus/dbus/dbus-1.init b/meta-oe/recipes-core/dbus/dbus/dbus-1.init
new file mode 100644
index 000000000..a70e7a237
--- /dev/null
+++ b/meta-oe/recipes-core/dbus/dbus/dbus-1.init
@@ -0,0 +1,111 @@
1#! /bin/sh
2# -*- coding: utf-8 -*-
3# Debian init.d script for D-BUS
4# Copyright © 2003 Colin Walters <walters@debian.org>
5# Copyright 2008 OE Team
6
7set -e
8
9DAEMON=/usr/bin/dbus-daemon
10NAME=dbus
11DAEMONUSER=messagebus
12RUNDIR=/var/run/dbus
13PIDFILE=/var/run/dbus/pid
14UUIDDIR=/var/lib/dbus
15DESC="system message bus"
16EVENTDIR=/etc/dbus-1/event.d
17
18test -x $DAEMON || exit 0
19
20# Source defaults file; edit that file to configure this script.
21ENABLED=1
22PARAMS=""
23if [ -e /etc/default/dbus ]; then
24 . /etc/default/dbus
25fi
26
27test "$ENABLED" != "0" || exit 0
28
29start_it_up()
30{
31 if [ ! -d $RUNDIR ]; then
32 mkdir -p $RUNDIR
33 chown $DAEMONUSER $RUNDIR
34 chgrp $DAEMONUSER $RUNDIR
35 fi
36 if [ -e $PIDFILE ]; then
37 PIDDIR=/proc/$(cat $PIDFILE)
38 if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
39 echo "$DESC already started; not starting."
40 else
41 echo "Removing stale PID file $PIDFILE."
42 rm -f $PIDFILE
43 fi
44 fi
45
46 if [ ! -d $UUIDDIR ]; then
47 mkdir -p $UUIDDIR
48 chown $DAEMONUSER $UUIDDIR
49 chgrp $DAEMONUSER $UUIDDIR
50 fi
51
52 dbus-uuidgen --ensure
53
54 echo -n "Starting $DESC: "
55 start-stop-daemon --start --pidfile $PIDFILE \
56 --user $DAEMONUSER --exec $DAEMON -- --system $PARAMS
57 echo "$NAME."
58 if [ -d $EVENTDIR ]; then
59 run-parts --arg=start $EVENTDIR
60 fi
61}
62
63shut_it_down()
64{
65 if [ -d $EVENTDIR ]; then
66 # TODO: --reverse when busybox supports it
67 run-parts --arg=stop $EVENTDIR
68 fi
69 echo -n "Stopping $DESC: "
70 start-stop-daemon --stop --oknodo --pidfile $PIDFILE \
71 --user $DAEMONUSER
72 # We no longer include these arguments so that start-stop-daemon
73 # can do its job even given that we may have been upgraded.
74 # We rely on the pidfile being sanely managed
75 # --exec $DAEMON -- --system $PARAMS
76 echo "$NAME."
77 rm -f $PIDFILE
78}
79
80reload_it()
81{
82 echo -n "Reloading $DESC config: "
83 dbus-send --print-reply --system --type=method_call \
84 --dest=org.freedesktop.DBus \
85 / org.freedesktop.DBus.ReloadConfig > /dev/null
86 # hopefully this is enough time for dbus to reload it's config file.
87 echo "done."
88}
89
90case "$1" in
91 start)
92 start_it_up
93 ;;
94 stop)
95 shut_it_down
96 ;;
97 reload|force-reload)
98 reload_it
99 ;;
100 restart)
101 shut_it_down
102 sleep 1
103 start_it_up
104 ;;
105 *)
106 echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2
107 exit 1
108 ;;
109esac
110
111exit 0