[systemd-devel] Waiting for (transient) hostname configuration

Alessio Igor Bogani alessio.bogani at elettra.eu
Wed Apr 20 20:09:04 UTC 2022


Hi Lennart,

On Wed, 20 Apr 2022 at 16:47, Lennart Poettering <lennart at poettering.net> wrote:
[...]
> > I use systemd-networkd and systemd-networkd-wait-online is enabled but
> > unfortunately it doesn't work anyway.

If you don't mind I show you one of my Unit files:

[Unit]
Description=Tango Starter service
Requires=network-online.target nss-lookup.target
Wants=tangorc.service
After=network-online.target tangorc.service nss-lookup.target
Conflicts=shutdown.target
RequiresMountsFor=/runtime

[Service]
User=controls
Group=controls
# ExecStart=/usr/bin/Starter %H
ExecStart=/bin/sh -c 'sleep 1; exec /usr/bin/Starter `hostname`'
KillMode=process
RestartSec=5s
Restart=on-failure

[Install]
WantedBy=multi-user.target

> What doesn't work precisely?

The %H specifier in the commented ExecStart always returns
"localhost". The following ExecStart is my workaround to have the
hostname provided by DHCP (in the first version it was a while loop
but a sleep works anyway and make things less convoluted).

Ciao,
Alessio


More information about the systemd-devel mailing list