diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2021-12-20 16:48:54 +0100 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2021-12-21 11:00:43 +0100 |
commit | 2f6a4e41f66496b6719e9b493207b99b9446c837 (patch) | |
tree | fa127a9f03c32edc97b513e8fc4d7b02d3f8c6bc | |
parent | fddb6e505929b44dc7c98e9bb061648562e30de0 (diff) |
set-hostname: work around race condition
This service sets the hostname on boot to the machine name amended
by the serial number unless /etc/hostname already exists.
systemd does also set a hostname, if none is available it uses
'localhost' and creates an empty /etc/hostname.
This two mechanism have a race condition so that systemd might
run before set-hostname was able to create /etc/hostname. Likely
only seens a recent systemd update.
Fix that by changing the conditions for executing set-hostname to
run when there is no or an empty /etc/hostname file.
Related-to: ELB-4277
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
-rw-r--r-- | recipes-core/set-hostname/files/set-hostname.service | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/recipes-core/set-hostname/files/set-hostname.service b/recipes-core/set-hostname/files/set-hostname.service index 306528b..9bd2a63 100644 --- a/recipes-core/set-hostname/files/set-hostname.service +++ b/recipes-core/set-hostname/files/set-hostname.service @@ -1,5 +1,5 @@ [Unit] -ConditionPathExists=|!/etc/hostname +ConditionFileNotEmpty=|!/etc/hostname Wants=network-pre.target Before=network-pre.target After=local-fs.target |