From 44c651dc8dcaaa41bb57dba636db97d4fe04bea8 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Wed, 21 Aug 2019 16:52:54 +0200 Subject: [PATCH] Create /etc/hostname in initramfs Persist hostname in /etc/hostname in the initramfs if the hostname is known. Signed-off-by: Benjamin Drung --- components/9990-networking.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/9990-networking.sh b/components/9990-networking.sh index cfafcb0..92c66ee 100755 --- a/components/9990-networking.sh +++ b/components/9990-networking.sh @@ -133,6 +133,12 @@ do_netsetup () HWADDR="$(cat "/sys/class/net/${interface}/address")" fi + if [ ! -e "/etc/hostname" ] && [ -n "${HOSTNAME}" ] + then + echo "Creating /etc/hostname" + echo "${HOSTNAME}" > /etc/hostname + fi + # Only create /etc/hosts if FQDN is known (to let 'hostname -f' query # this file). Otherwise DNS will be queried to determine the FQDN. if [ ! -e "/etc/hosts" ] && [ -n "${DNSDOMAIN}" ] -- 2.1.4