On 19/07/2020 10:10, Richard Hector wrote: > Hi all, > > I'm running into a problem with systemd and my openvpn instances. > > To start a vpn, I run 'systemctl start openvpn-client@foo_host2' or > similar. That has to be an underscore, because as far as I can see, > using a hyphen/dash will break the instance mechanism. Of course, the > actual hostname has to have a hyphen, because you can't have an > underscore in the DNS. > > This means I will inevitably end up typing 'systemctl start > openvpn-client@foo-host2' by mistake. > > When that happens, it appears that systemd will try to start it, and > fail because foo-host2.conf doesn't exist - and try for ever. Showing > the status of foo_host2 works fine, of course, so I don't notice until I > look at the logs. > > Is this an inherent part of how systemd works, or is there a way to make > it return an error message, rather than silently trying the impossible? > > Thanks, > Richard > Systemd acknowledges that the string you might want to put in an instance name isn't always a good string to put in a filename, so it uses an escaping mechanism detailed at https://www.freedesktop.org/software/systemd/man/systemd.unit.html#String Escaping for Inclusion in Unit Names
Additionally, if you find yourself typing a dash instead of an underscore, consider training yourself to take advantage of your shell's completion functions. "systemctl start openvpn-client@foo<tab>" (where "<tab>" represents pressing the tab key) should complete the string for you. If there are multiple completions possible, a single tab will not add any more characters to the command but two tabs in quick succession will display further possibilities. Generally, you can navigate these with cursor keys for a rudimentary menu.
signature.asc
Description: OpenPGP digital signature