Creating bundles

If you are unlucky enough to have a package that does not supply service bundle directories for its services, you have some options.

You can build a bundle using parts from some public run script collections.

Gerrit Pape made a collection of some run scripts some years ago. Wayne Marshall has collected a few more. So has Kevin J. DeGraaf. And so has Glenn Strauss. Simply take an appropriate run script, add minimal start, stop, and restart programs, put the lot into a service directory, put that into a bundle directory, and enable/start the service.

Minimal start, stop, and restart scripts are simply:

#!/bin/nosh
true

Note that Gerrit Pape's and Wayne Marshall's collections use shells as the script interpreters. Several of the scripts can be simplified yet further with use of nosh and its built-in toolset. Some of them also rely upon tools such as chpst and tcpsvd, which one of course replaces with the equivalent daemontools-alike tool(s) and some combination of tcp-socket-listen, tcp-socket-accept, and ucspi-socket-rules-check.

You can import a systemd service unit file.

If the package comes with a systemd service unit file (and potentially an accompanying socket unit file), you can import it. Simply run system-control convert-systemd-units servicename and the import utility will attempt to import the service and write a bundle directory. (You can control where the bundle directory is written.) This can cope with many systemd service units, as long as they aren't Linux-specific, esoteric, or too clever by half.

The import utility will display warnings about anything that it didn't understand or ignored.

You can simply write a bundle.

As mentioned above, minimal start, stop, and restart scripts are very simple. So, too, are run scripts.

The service interdependencies and orderings are usually quite simple, too:

mkdir -p wants after before stopped-by wanted-by
ln -s /etc/service-bundles/targets/basic after/
ln -s /etc/service-bundles/targets/basic wants/
ln -s /etc/service-bundles/targets/shutdown before/
ln -s /etc/service-bundles/targets/shutdown stopped-by/
ln -s /etc/service-bundles/targets/workstation wanted-by/

Tailor this according to need, of course.

The standard targets are akin to the Solaris SMF milestones, including having distinct "server", "workstation", and "multi-user" targets instead of one single target that mixes all three. A rough guide for converting from the NetBSD rc.d system is:

FILESYSTEMS

This usually equivalent to the local-fs standard target, although cleanup services are usually related to the sysinit standard target instead.

LOGIN

This usually equivalent to the multi-user standard target.

SERVERS and DAEMON

One of the workstation, server, or sysinit standard targets is usually equivalent.