summaryrefslogtreecommitdiff
path: root/packages/dbus
diff options
context:
space:
mode:
authorKoen Kooi <koen@openembedded.org>2005-07-30 16:20:50 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2005-07-30 16:20:50 +0000
commitb5edeb751c7d12b6526440022396f6a976b583d7 (patch)
tree9ba3f73f07407f7e4391ce04ad385d145e2db7bc /packages/dbus
parent21144d81926d426df3e4bfa86de1ae9d1231a535 (diff)
Apply dbus-init patch, Courtesy Philipp Zabel
Diffstat (limited to 'packages/dbus')
-rw-r--r--packages/dbus/dbus/dbus-1.init87
1 files changed, 58 insertions, 29 deletions
diff --git a/packages/dbus/dbus/dbus-1.init b/packages/dbus/dbus/dbus-1.init
index 118b801da7..bd31b6208c 100644
--- a/packages/dbus/dbus/dbus-1.init
+++ b/packages/dbus/dbus/dbus-1.init
@@ -1,15 +1,17 @@
#! /bin/sh
-# -*- coding: iso8859-1 -*-
+# -*- coding: utf-8 -*-
# Debian init.d script for D-BUS
-# Copyright (c) 2003 Colin Walters <walters@debian.org>
+# Copyright © 2003 Colin Walters <walters@debian.org>
set -e
DAEMON=/usr/bin/dbus-daemon-1
NAME=dbus-1
DAEMONUSER=messagebus
-PIDFILE=/var/run/dbus/pid
+PIDDIR=/var/run/dbus
+PIDFILE=$PIDDIR/pid
DESC="system message bus"
+EVENTDIR=/etc/dbus-1/event.d
test -x $DAEMON || exit 0
@@ -17,41 +19,68 @@ test -x $DAEMON || exit 0
ENABLED=1
PARAMS=""
if [ -e /etc/default/dbus-1 ]; then
- . /etc/default/dbus-1
+ . /etc/default/dbus-1
fi
test "$ENABLED" != "0" || exit 0
+start_it_up()
+{
+ if [ ! -d $PIDDIR ]; then
+ mkdir -p $PIDDIR
+ chown $DAEMONUSER $PIDDIR
+ chgrp $DAEMONUSER $PIDDIR
+ fi
+ if [ -e $PIDFILE ]; then
+ PIDDIR=/proc/$(cat $PIDFILE)
+ if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
+ echo "$DESC already started; not starting."
+ else
+ echo "Removing stale PID file $PIDFILE."
+ rm -f $PIDFILE
+ fi
+ fi
+ echo -n "Starting $DESC: "
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --user $DAEMONUSER --exec $DAEMON -- --system $PARAMS
+ echo "$NAME."
+ if [ -d $EVENTDIR ]; then
+ run-parts --arg=start $EVENTDIR
+ fi
+}
+
+shut_it_down()
+{
+ if [ -d $EVENTDIR ]; then
+ run-parts --reverse --arg=stop $EVENTDIR
+ fi
+ echo -n "Stopping $DESC: "
+ start-stop-daemon --stop --retry 60 --quiet --oknodo --pidfile $PIDFILE \
+ --user $DAEMONUSER
+ # We no longer include these arguments so that start-stop-daemon
+ # can do its job even given that we may have been upgraded.
+ # We rely on the pidfile being sanely managed
+ # --exec $DAEMON -- --system $PARAMS
+ echo "$NAME."
+ rm -f $PIDFILE
+}
+
case "$1" in
start)
- echo -n "Starting $DESC: "
- if [ ! -d /var/run/dbus ]; then
- mkdir /var/run/dbus
- chown $DAEMONUSER:$DAEMONUSER /var/run/dbus
- fi
- start-stop-daemon -S \
- -u $DAEMONUSER -x $DAEMON -- --system $PARAMS
- echo "$NAME."
- ;;
+ start_it_up
+ ;;
stop)
- echo -n "Stopping $DESC: "
- start-stop-daemon -K \
- -u $DAEMONUSER -x $DAEMON -- --system $PARAMS
- echo "$NAME."
- ;;
+ shut_it_down
+ ;;
restart|force-reload)
- echo -n "Restarting $DESC: "
- start-stop-daemon -K \
- -u $DAEMONUSER -x $DAEMON -- --system $PARAMS
- sleep 1
- start-stop-daemon -S \
- -u $DAEMONUSER -x $DAEMON -- --system $PARAMS
- echo "$NAME."
- ;;
+ shut_it_down
+ sleep 1
+ start_it_up
+ ;;
*)
- echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
- exit 1
- ;;
+ echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
+ exit 1
+ ;;
esac
exit 0