diff options
author | Hiago De Franco <hiago.franco@toradex.com> | 2024-04-22 09:52:03 -0300 |
---|---|---|
committer | Hiago De Franco <hiago.franco@toradex.com> | 2024-04-22 10:45:12 -0300 |
commit | 9d2e8422f17a52e4dd7d2170c685cad2acba5550 (patch) | |
tree | 8d8668dfadaa3a5eb049b0e5d682b99cfa7cc37e | |
parent | 0da03cf4aa7d96d12dfb6d26f839168fd2f3c3d3 (diff) |
set-hostname: update sethostname script to handle read-only root filesystem
The sethostname script has issues when the root filesystem is mounted
as read-only, making not possible to create or modify the /etc/hostname
file.
Therefore, this change updates the sethostname script and adds the
@@HOSTNAMECTL_OPT@@ that can further be replaced with the "--transient"
flag for hostnamectl if the system uses a read-only root FS. This flag
will change the hostname without creating the /etc/hostname file.
With this change, update recipe version from 1.0 to 1.1.
Related-to: ELB-5713
Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
-rw-r--r-- | recipes-core/set-hostname/files/sethostname | 2 | ||||
-rw-r--r-- | recipes-core/set-hostname/set-hostname_1.1.bb (renamed from recipes-core/set-hostname/set-hostname_1.0.bb) | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/recipes-core/set-hostname/files/sethostname b/recipes-core/set-hostname/files/sethostname index 87e6320..aacb7ab 100644 --- a/recipes-core/set-hostname/files/sethostname +++ b/recipes-core/set-hostname/files/sethostname @@ -13,7 +13,7 @@ fi hostname=@@MACHINE@@"-"${serial} if [ -f /usr/bin/hostnamectl ]; then - /usr/bin/hostnamectl set-hostname ${hostname} + /usr/bin/hostnamectl set-hostname @@HOSTNAMECTL_OPT@@ ${hostname} else hostname ${hostname} fi diff --git a/recipes-core/set-hostname/set-hostname_1.0.bb b/recipes-core/set-hostname/set-hostname_1.1.bb index b39abdb..e9c3878 100644 --- a/recipes-core/set-hostname/set-hostname_1.0.bb +++ b/recipes-core/set-hostname/set-hostname_1.1.bb @@ -23,6 +23,8 @@ do_install () { install -d ${D}${bindir} install -m 0755 ${WORKDIR}/sethostname ${D}${bindir} sed -i "s/@@MACHINE@@/${MACHINE}/g" ${D}${bindir}/sethostname + sed -i "s/@@HOSTNAMECTL_OPT@@/${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','--transient','',d)}/g" \ + ${D}${bindir}/sethostname if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then install -d ${D}${systemd_system_unitdir} install -m 0644 ${WORKDIR}/set-hostname.service ${D}${systemd_system_unitdir} |