[Swan-dev] [ot] getting systemd to set the KVM test domain's hostname

Paul Wouters paul at nohats.ca
Thu Aug 6 00:55:14 UTC 2020


On Wed, 5 Aug 2020, Andrew Cagney wrote:

>> Using a oneshot service we install via anaconda ?
>>
>> https://gist.github.com/tuxfight3r/937be13b08395101d7201883d7410a0d
>
> it is a starting point, however the disk image (or clones) are:
> - created using kick-start
> - booted as base to install packages
> - booted as build to build libvirt
> - booted as east, ..., to test
> so a simple oneshot would have happened long ago

It is one shot per boot. The system just waits for it to complete, and
once it exits it is deemed completed and fine and won't start again
until the system has rebooted.

> the .network files - all of which are installed - now look like this:
> https://github.com/libreswan/libreswan/commit/c89711225f3a1c4384d6df8d17b2508997e26a0e
> so the network is figured out using systemd

Oh that's good. espcially if that removes the "service network restart"
completely.

eg:

On the base system, ensure /etc/hostname is an empty file. then install
this:

# /lib/systemd/system/hostnaming.service
[Unit]
Description=Figure out who we are
ConditionFileNotEmpty=|!/etc/hostname
After=systemd-networkd.service
Before=network.target

[Service]
Type=oneshot
ExecStart=/testing/guestbin/hostnamer

[Install]
WantedBy=multi-user.target



Paul


More information about the Swan-dev mailing list