Skip to main content
Topic: Simulating systemd Type=dbus services (s6/dinit) (Read 249 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Simulating systemd Type=dbus services (s6/dinit)

systemd has a special service type that waits for the program to register itself on D-Bus before considering it ready (Type=dbus). For some packages, that's the only meaningful readiness information available, but s6 and dinit only support the simple "write newline to a fd" protocol. Therefore, in order to accurately translate these services, I needed a program that could wait until that happened, to then write the newline to the fd.

I found an old project laying around on GitHub called Unit2OpenRC that had a dbus-service-wait helper program that did the waiting part. To make it useful with s6, I'd need to write quite a bit of boilerplate in execline for every service so the waiting would be done in the background and a newline would be written after that. I made an extended version of the program that did just that without needing the execline script.

I forgot about it until last week when a dinit user on Telegram wanted help translating a Type=dbus systemd service. I polished it a bit further (fix help messages, etc.) and here it is, the extended version

To build:
Code: [Select]
git clone https://github.com/capezotte/dbus-service-wait && cd dbus-service-wait && ./build.sh

The resulting dbus-service-wait can be installed anywhere in your PATH.

To use it with s6 and dinit, for instance:
Code: [Select]
# Instead of the following 'run' file or 'command' variable
mako
# Write (dbus service name + executable), 3 is the notification-fd
dbus-service-wait -d3 org.freedesktop.Notifications mako

I hope it might be useful to you.



Runit doesn't have readiness notification so it can't really be used with it. Check the original project if you want something that can be used with OpenRC.