diff mbox series

[isar-cip-core,RFC,2/9] customizations: Add variable to set the HOSTNAME

Message ID 20231023150243.3990309-3-Quirin.Gylstorff@siemens.com (mailing list archive)
State Superseded
Headers show
Series cleanup of customizations | expand

Commit Message

Gylstorff Quirin Oct. 23, 2023, 3 p.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

Add the variable CUSTOM_HOSTNAME to modify the hostname of
the image.

The default value of CUSTOM_HOSTNAME is "demo".

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 recipes-core/customizations/common.inc                      | 6 +++++-
 .../customizations/files/{postinst => postinst.tmpl}        | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)
 rename recipes-core/customizations/files/{postinst => postinst.tmpl} (85%)
diff mbox series

Patch

diff --git a/recipes-core/customizations/common.inc b/recipes-core/customizations/common.inc
index 680a4d6..79bf80d 100644
--- a/recipes-core/customizations/common.inc
+++ b/recipes-core/customizations/common.inc
@@ -14,16 +14,20 @@  inherit dpkg-raw
 FILESPATH:append := ":${FILE_DIRNAME}/files"
 
 SRC_URI = " \
-    file://postinst \
+    file://postinst.tmpl \
     file://ethernet \
     file://99-silent-printk.conf \
     file://99-watchdog.conf"
 
 SRC_URI:append:swupdate = " file://swupdate.cfg"
 
+CUSTOM_HOSTNAME ??= "demo"
 WIRELESS_FIRMWARE_PACKAGE ?= ""
 INSTALL_WIRELESS_TOOLS ??= "0"
 
+TEMPLATE_FILES += "postinst.tmpl"
+TEMPLATE_VARS += "CUSTOM_HOSTNAME"
+
 DEPENDS += "sshd-regen-keys change-root-homedir"
 
 DEBIAN_DEPENDS = " \
diff --git a/recipes-core/customizations/files/postinst b/recipes-core/customizations/files/postinst.tmpl
similarity index 85%
rename from recipes-core/customizations/files/postinst
rename to recipes-core/customizations/files/postinst.tmpl
index 7e7ea36..2668a93 100644
--- a/recipes-core/customizations/files/postinst
+++ b/recipes-core/customizations/files/postinst.tmpl
@@ -2,7 +2,7 @@ 
 #
 # CIP Core, generic profile
 #
-# Copyright (c) Siemens AG, 2019
+# Copyright (c) Siemens AG, 2019-2023
 #
 # Authors:
 #  Jan Kiszka <jan.kiszka@siemens.com>
@@ -18,6 +18,6 @@  if ! grep -e "^PermitRootLogin.*yes" -q /etc/ssh/sshd_config; then
 	echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
 fi
 
-HOSTNAME=demo
+HOSTNAME="${CUSTOM_HOSTNAME}"
 echo "$HOSTNAME" > /etc/hostname
 echo "127.0.0.1 $HOSTNAME" >> /etc/hosts