Why not enable templated units?

Ryan Kuester rkuester at insymbols.com
Thu Oct 2 01:48:28 BST 2014


On Thu, Oct 02, 2014 at 02:02:49AM +0200, Michael Biebl wrote:
> Am 02.10.2014 um 01:23 schrieb Ryan Kuester:
> > dh_systemd_enable in package init-system-helpers skips enabling
> > templated unit files (i.e., those with a "@" in their name), saying it's
> > not useful to do so [1]. Is that really true?
> 
> Yes, I think so. Template files themselves are usually not enabled, but
> instances of them. So it doesn't make sense to enable foo at .service, but
> it might make sense to enable foo at bar.service.
> 
> > I'm finding it useful in a templated service unit which declares a
> > WantedBy to another templated service unit. 'systemctl enable $service'
> > happily installs the expected symlink, and this construction causes both
> > services to be instantiated with the instance name substituted. 
> 
> Do you have a concrete example?

An example from private packages, not official Debian packages:

1. automount-usb-media at .service is instantiated and started as
   automount-usb-media at sdb1.service by a udev rule when a USB drive is
   plugged.

2. scan-usb-media at .service is instantiated and started as
   scan-usb-media at sdb1.service by virtue of being symlinked under
   automount-usb-media at .service.wants/, the symlink coming by means of
   enabling scan-usb-media at .service.

Perhaps my example isn't compelling to anyone except me :^), but is
there a reason to squash what systemctl and systemd seem to allow?
systemctl seems to allow enabling of templates and systemd instantiates
them in a reasonable way.

-- Ryan




More information about the Pkg-systemd-maintainers mailing list