[systemd-devel] non-existent unit instances

Lennart Poettering lennart at poettering.net
Mon Sep 7 15:39:00 UTC 2020


On Sa, 05.09.20 18:46, Richard Hector (richard at walnut.gen.nz) wrote:

> Hi all,
>
> Quoting from another thread:
>
> On 5/09/20 4:36 am, Lennart Poettering wrote:
> > Unit instances can be activated on-the-fly without further prepartion
> > or regsitration of the instance string or so. it's sufficient if the
> > template unit exists.
>
> Is that preventable?
>
> I have some instance names that are easily typoed. When I start one with
> the wrong name, it sticks around trying to restart for ever - or at
> least till I notice it or reboot - where I'm much rather get an error
> message and stop.
>
> For reference, this is with the openvpn-client@ (and maybe
> openvpn-server@) units in Debian buster. Some of the content was
> modified/overwritten by me, so it could well be a bug introduced by me.
>
> The typos are because my instances are based on hostname, which can
> contain '-' but not '_'. Instance names can apparently not contain '-',
> so I have to use '_' instead, but my muscle memory for my hostnames is
> strong.
>
> I don't know if this is a result of the way the units are written, or an
> inherent issue with systemd.

Try:

    [Unit]
    AssertPathExists=%E/systemd/system/%n

(it's a bit sloppy though, since units can also be enabled via
"systemctl --runtime …" , which this does not cover, but you get the
idea).

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list