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. 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. Sysvinit scripts are just that - touring-complete scripts. Systemd units are declarative. Here is the Gentoo mysqld unit, which is pretty simple: [Unit] Description=MySQL database server After=syslog.target After=network.target [Service] Type=simple User=mysql Group=mysql # Note: we set --basedir to prevent probes that might trigger SELinux alarms, # https://bugzilla.redhat.com/show_bug.cgi?id=547485 ExecStart=/usr/bin/mysqld_safe --basedir=/usr ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID # Give a reasonable amount of time for the server to start up/shut down TimeoutSec=300 # We rely on systemd, not mysqld_safe, to restart mysqld if it dies Restart=always # Place temp files in a secure directory, not /tmp PrivateTmp=true [Install] WantedBy=multi-user.target 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). 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. Rich