| # Copyright (c) 2011 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 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 /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 |