]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(network-manager): hostname not set with old systemd service units
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Mon, 6 Oct 2025 15:41:08 +0000 (17:41 +0200)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 29 Oct 2025 16:39:28 +0000 (12:39 -0400)
Commit 83dffc58f606ad7ad47a32716ce240831d7f018f added support for using the new
systemd services provided by NetworkManager upstream if available, instead of
the old custom systemd services provided by dracut. Specifically,
`NetworkManager-config-initrd.service` sets /proc/sys/kernel/hostname if needed,
that's why the old code doing this in the initqueue hook `nm-run.sh` was
moved by mistake to the section that is executed when systemd is not present.

Fixes #1743

modules.d/35network-manager/nm-run.sh

index c7e8b4461825b7c47656a613c9a9f86f3e21e722..ef6b90364a934dfc260e825b2c75ad616d4b7bde 100755 (executable)
@@ -13,10 +13,11 @@ if [ -z "${DRACUT_SYSTEMD-}" ]; then
             break
         done
     fi
+fi
 
-    if [ -s /run/NetworkManager/initrd/hostname ]; then
-        cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname
-    fi
+if [ -e /usr/lib/systemd/system/nm-initrd.service ] \
+    && [ -s /run/NetworkManager/initrd/hostname ]; then
+    cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname
 fi
 
 kf_get_string() {