Skip to content

Commit

Permalink
Create /etc/hostname in initramfs
Browse files Browse the repository at this point in the history
Persist hostname in /etc/hostname in the initramfs if the hostname is
known.

Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
  • Loading branch information
bdrung committed Aug 21, 2019
1 parent 179707b commit 44c651d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/9990-networking.sh
Expand Up @@ -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}" ]
Expand Down

0 comments on commit 44c651d

Please sign in to comment.