summaryrefslogtreecommitdiff
path: root/recipes-core
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2021-12-20 16:48:54 +0100
committerMax Krummenacher <max.krummenacher@toradex.com>2022-02-21 15:10:59 +0100
commit7d4608e149468a03e9f58d3feae85b4942a55b94 (patch)
treed78ec88762e362d740a5ff2dce9acbe6090a4229 /recipes-core
parent5c07e50f3698b1ced65b898867cfc9402a3bf7e6 (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> (cherry picked from commit 2f6a4e41f66496b6719e9b493207b99b9446c837)
Diffstat (limited to 'recipes-core')
-rw-r--r--recipes-core/set-hostname/files/set-hostname.service2
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