Re: non-existent unit instances

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 5 Sep 2020, Richard Hector 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.

Since the instance name for this unit is used to derive a configuration 
filename, a simple solution here would be to use:

    ConditionPathExists=/etc/openvpn/client/%i.conf

in the unit. Or, if you want the start job to fail when given a bad 
instance name:

    AssertPathExists=/etc/openvpn/client/%i.conf

> 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.

Instance names can contain hyphens, however depending on how they're used 
these hyphens will be translated into slashes. The %I specifier does this 
kind of translation, for instance.

This upstream OpenVPN units use %i when they reference configuration 
filenames, however, and this does not perform any translation on the 
instance name. I'm not sure why hyphens would cause problems for you.

> I don't know if this is a result of the way the units are written, or an
> inherent issue with systemd.
> 
> Cheers,
> Richard
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux