Ubuntu – Access dbus session bus from upstart script

dbusupstart

I was wandering if it is possible to access the DBUS session bus from within an upstart script.

The background is this:
I am running an upstart task in user mode and replaced the Upstart.conf dbus configuration file with the one from the upstart bzr repository.

Now it would like to access the gnome keyring within that tasks script using gkeyring, which needs to access the users upstart session bus. By default, I just get the Gnome keyring not available.

When I try to export DBUS_SESSION_BUS_ADDRESS=... within the upstart script, the script/initctl command just hangs, no output anywhere.

This leads me to believe that since upstart uses DBUS as well, using the session bus is problematic. Does someone have an idea to resolve this?

Best Answer

this might work for you ?...

script
    export HOME="/home/puma"
    chdir /home/puma/apps/whatever/bin
    dbus_file=$(ls $HOME/.dbus/session-bus/ -t1 | head -1)
    . "$HOME/.dbus/session-bus/$dbus_file"
    export DBUS_SESSION_BUS_ADDRESS
    exec su -s /bin/sh -c 'export DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS;exec /home/puma/apps/whatever/bin/appname' puma 
end script

hope it helps ?

Related Question