Hi,
[ You don't even have to be that brave, or even run openrc! ]
I have been working on expanding and completing K Gopal Krishna's
systemd-unit-translator[1] that was started as part of the Google Summer of Code
2020. My expanded version is now ready for wider testing[2].
It can handle service, socket and timer units (although timers require
systemd-analyze; patches to handle this aspect in bash would be *very* welcome
-- I haven't looked at or touched it at all).
The forked source tree is
https://git.devuan.org/LeePen/systemd-unit-translator
It is a bash script. You can run the script without elevated privileges. Try it on an
individual unit or on all the units in a directory:-
find /lib/systemd/system -maxdepth 1 -type f -exec ./systemd-unit-translator '{}' /tmp/rc ';'
The final parameter is the destination and all the output files will be placed
beneath it (in this case /tmp/rc).
I am particularly interested in:-
- Does it work for you?
- What is broken for you?
- Are the output files syntactically sane[3]
- Do you have warnings about unsupported directives or conditions.
- Can the tests be improved[4]
Openrc only handles system processes, but you can also run the script on
/usr/lib/systemd/user to help decipher the mass of systemd units and give you
sane commands to run. For example on my system, having translated
/usr/lib/systemd/user/foot-server@.socket I can run:-
% RC_SVCNAME=$WAYLAND_DISPLAY sh -x /tmp/rc/init.d/foot-server.
description=Foot terminal server mode for WAYLAND_DISPLAY=wayland-1.
supervisor=supervise-daemon
command=/usr/bin/socket-activate
command_args=--unix::/run/user/1000/foot-wayland-1.sock -- /usr/bin/foot --server=3
[ Note to reader: socket-activate is another WIP, coming shortly! ]
This was an exercise in seeing how far I could get in implementing a
semi-automatic, but reasonably complete translator. Let's see how far I have
got.
Thanks for your help.
Mark
[1]
https://salsa.debian.org/kayg/systemd-unit-translator
[2]
https://git.devuan.org/LeePen/systemd-unit-translator
[3] sh -n /tmp/rc/init.d/* should succeed
[4] Although the script itself is bash, the generated openrc scripts must be POSIX.
--
Mark Hindley
GPG: 506C 15A4 2B0A F5A0 A854 23EE D28A 45BF 3287 D649