summaryrefslogtreecommitdiff
path: root/recipes-core/set-hostname/set-hostname_1.1.bb
diff options
context:
space:
mode:
authorHiago De Franco <hiago.franco@toradex.com>2024-04-22 09:52:03 -0300
committerMax Krummenacher <max.krummenacher@toradex.com>2024-04-24 09:40:57 +0200
commit563233bb3047429d4fb4561036a40e4a40e47d97 (patch)
tree6e0e785f34bc5e0bb675a5fd34fd1e6db4e601bf /recipes-core/set-hostname/set-hostname_1.1.bb
parentf97cd2d388e2b56aa9546d4c747a1944e3d60524 (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> (cherry picked from commit 9d2e8422f17a52e4dd7d2170c685cad2acba5550)
Diffstat (limited to 'recipes-core/set-hostname/set-hostname_1.1.bb')
-rw-r--r--recipes-core/set-hostname/set-hostname_1.1.bb32
1 files changed, 32 insertions, 0 deletions
diff --git a/recipes-core/set-hostname/set-hostname_1.1.bb b/recipes-core/set-hostname/set-hostname_1.1.bb
new file mode 100644
index 0000000..e9c3878
--- /dev/null
+++ b/recipes-core/set-hostname/set-hostname_1.1.bb
@@ -0,0 +1,32 @@
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+inherit systemd
+
+SRC_URI += " \
+ file://sethostname \
+ file://set-hostname.service \
+"
+
+FILES:${PN} = " \
+ ${bindir} \
+ ${systemd_system_unitdir} \
+"
+
+SYSTEMD_SERVICE:${PN} = " \
+ set-hostname.service \
+"
+
+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}
+ fi
+}