rendered paste bodydaemon daemon/dbus {
need = system/initial system/mountfs system/bootmisc;
pid_file = /var/run/dbus/pid;
#env_file=/etc/default/dbus-1
script daemon = {
#Debian and Ubuntu are using different files
if [ -x /usr/bin/dbus-daemon-1 ]; then
DAEMON=/usr/bin/dbus-daemon-1
NAME=dbus-1
elif [ -x /usr/bin/dbus-daemon ]; then
DAEMON=/usr/bin/dbus-daemon
NAME=dbus
else
echo "/usr/bin/dbus-daemon or /usr/bin/dbus-daemon-1 not found!"
exit 1
fi
DAEMONUSER=messagebus
PIDDIR=/var/run/dbus
PIDFILE=$PIDDIR/pid
DESC="system message bus"
# Source defaults file; edit that file to configure this script.
ENABLED=1
PARAMS=""
if [ -e /etc/default/dbus-1 ]; then
. /etc/default/dbus-1
elif [ -e /etc/default/dbus ]; then
. /etc/default/dbus
fi
test "$ENABLED" != "0" || exit 0
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
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--user $DAEMONUSER --exec $DAEMON -- --system $PARAMS
};
}