On 2014-08-11, Rich Freeman <ri...@gentoo.org> wrote: > On Mon, Aug 11, 2014 at 4:05 PM, Grant Edwards ><grant.b.edwa...@gmail.com> wrote: >> >> Any advice on whether it would be easier to use a common init script >> with sysV/OpenRC/systemd or to write a separate .service file? > > I'd almost certainly generate a proper unit, and not try to use a > compatibility mode, especially if you're generating these using > software.
It wouldn't be generated by software. Both the sysv init script and .service file would be maintained by hand. > If anything it would make more sense to make a sysvinit script which > is a wrapper for a systemd unit than the other way around. Thanks, I'll consider that, but I'm reluctant to do so for fear of breaking compatibility with various ancient systems in use out there. [I can't even find hardware old enough to run some of the Linux kernels and distro's some customers are still using.] [...] > Most daemons will be fairly similar to this, though a daemon which > forks will be slightly different (type=forking, and will have a > PIDfile setting). The daemon is currently of the traditional forking variety with a PID file, so it should lend itself to Type=forking PIDFile=/var/run/whatever.pid. But, there are a number of housekeeping tasks that are performed before starting the daemon and after terminating the daemon (checking configuration files, verifying presence of kernel module .ko/.o files, loading a kernel module and logging some pertinent info from that module, unloading the kernel module, etc.). It looks like I should write ExecStartPre and ExecStopPost scripts for systemd to invoke. One thing I'm still wondering about is the canonical location to install things like ExecStartPre and ExecStopPost scripts. I could modify the daemon to provide a "no-fork" option and then exec it at the end of a startup script, but I don't really see much benefit to that. > This one is a bit fancy in that it has a post-exec script/program > that just checks for the main service to be ready (so that reverse > dependencies aren't started prematurely). > > It is important that whatever is in execstart doesn't die if this is > a daemon. If this is just going to modprobe something and terminate > that is fine, but there is a slightly different way to express those > so that it isn't considered a failure. Thanks much for the advice. -- Grant Edwards grant.b.edwards Yow! I am covered with at pure vegetable oil and I am gmail.com writing a best seller!