|
Harald Hoyer |
308914 |
From eb770a4a207b2e9e3080068c1df22b69ed44d4b5 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
308914 |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
Harald Hoyer |
308914 |
Date: Thu, 7 May 2020 07:48:12 +0200
|
|
Harald Hoyer |
308914 |
Subject: [PATCH] network-manager: set kernel hostname from the command line
|
|
Harald Hoyer |
308914 |
|
|
Harald Hoyer |
308914 |
Since commit ff70adf873ef ("initrd: save hostname to a file in /run"),
|
|
Harald Hoyer |
308914 |
the initrd generator of NetworkManager parses the hostname from 'ip='
|
|
Harald Hoyer |
308914 |
options of the kernel command line and writes it to
|
|
Harald Hoyer |
308914 |
/run/NetworkManager/initrd/hostname.
|
|
Harald Hoyer |
308914 |
|
|
Harald Hoyer |
308914 |
When that file exists, set the kernel hostname.
|
|
Harald Hoyer |
308914 |
|
|
Harald Hoyer |
308914 |
In presence of multiple hostnames in the command line, the last one
|
|
Harald Hoyer |
308914 |
wins. Hostnames from command line always have precedence over ones
|
|
Harald Hoyer |
308914 |
received through DHCP. This is a bit different from the legacy network
|
|
Harald Hoyer |
308914 |
module that gives higher precedence to the hostname (from DHCP or
|
|
Harald Hoyer |
308914 |
command line) of the last interface that is brought up, which depends
|
|
Harald Hoyer |
308914 |
on the udev order.
|
|
Harald Hoyer |
308914 |
---
|
|
Harald Hoyer |
308914 |
modules.d/35network-manager/nm-run.sh | 4 ++++
|
|
Harald Hoyer |
308914 |
1 file changed, 4 insertions(+)
|
|
Harald Hoyer |
308914 |
|
|
Harald Hoyer |
308914 |
diff --git a/modules.d/35network-manager/nm-run.sh b/modules.d/35network-manager/nm-run.sh
|
|
Harald Hoyer |
308914 |
index fc5280a1..61752384 100755
|
|
Harald Hoyer |
308914 |
--- a/modules.d/35network-manager/nm-run.sh
|
|
Harald Hoyer |
308914 |
+++ b/modules.d/35network-manager/nm-run.sh
|
|
Harald Hoyer |
308914 |
@@ -10,6 +10,10 @@ for i in /usr/lib/NetworkManager/system-connections/* \
|
|
Harald Hoyer |
308914 |
else
|
|
Harald Hoyer |
308914 |
/usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
|
|
Harald Hoyer |
308914 |
fi
|
|
Harald Hoyer |
308914 |
+
|
|
Harald Hoyer |
308914 |
+ if [ -s /run/NetworkManager/initrd/hostname ]; then
|
|
Harald Hoyer |
308914 |
+ cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname
|
|
Harald Hoyer |
308914 |
+ fi
|
|
Harald Hoyer |
308914 |
break
|
|
Harald Hoyer |
308914 |
done
|
|
Harald Hoyer |
308914 |
|
|
Harald Hoyer |
308914 |
|