blob: 661c986035787c250ce4c8184c74971d01028e9f [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "D-Bus message bus daemon"
author "chromium-os-dev@chromium.org"
# Stop conditions for this job deliberately omitted: D-Bus clients
# routinely terminate with crashes when dbus-daemon terminates before
# them. Ordering process termination with upstart is hard, so we
# simply leave dbus-daemon running to ensure the rest of the system
# can shut down cleanly.
start on starting boot-services
respawn
# Sets up the D-Bus environment.
pre-start script
mkdir -p /var/run/dbus
chown messagebus:messagebus /var/run/dbus
mkdir -p /var/lib/dbus
#
# The following ensures that there is a valid machine-id for dbus. Just
# running dbus-uuidgen --ensure is not enough if there is an invalid
# machine-id. For instance if machine-id is not a 33 byte file
# dbus-uuidgen will fail without regenerating a UUID. The operation of
# generating a new UUID takes 4ms on CortexA9, so the boot performance
# impact is minimal.
#
# Only generate a new id if dbus-uuidgen fails, otherwise a new id is
# generated every reboot, which confuses code that expects it to remain
# constant (e.g. PulseAudio).
#
if ! dbus-uuidgen --ensure; then
rm -f /var/lib/dbus/machine-id
dbus-uuidgen --ensure
fi
end script
expect fork
exec dbus-daemon --system --fork
# The post-stop script will clean up after d-dbus. It's better to put this
# here rather than in pre-start since post-stop is always guaranteed to run
# while pre-start can exit pre-maturely.
post-stop script
rm -rf /var/run/dbus
end script