blob: d3071755779734ff6a8a4453c687a25e214f4f6f [file] [log] [blame]
# Copyright (c) 2009 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.
# dbus
# Does some required setup and then starts the D-Bus daemon.
start on runlevel 2
# 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
end script
expect fork
exec /usr/bin/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