]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
write-ifcfg.sh: add UUID=.. and save the lease files with the same uuid
authorWill Woods <wwoods@redhat.com>
Wed, 7 Mar 2012 22:21:54 +0000 (17:21 -0500)
committerHarald Hoyer <harald@redhat.com>
Thu, 8 Mar 2012 09:58:42 +0000 (10:58 +0100)
As described in https://bugzilla.redhat.com/show_bug.cgi?id=541410#c2,
if you want NetworkManager to take over an interface that you're using
for NFS root (or other network root device), you need to:

a) set UUID=<uuid> in ifcfg-<iface>, and
b) save the lease file as /var/lib/dhclient-<uuid>-<iface>.lease

This patch should make write-ifcfg handle both these things.

modules.d/45ifcfg/write-ifcfg.sh

index 0f431e3f23198d2a8670e22fb11adbb0893fd021..fe986df43be93364d1b74b752e4d8668f3a3fc72 100755 (executable)
@@ -18,11 +18,13 @@ if [ -e /tmp/bridge.info ]; then
 fi
 
 mkdir -m 0755 -p /tmp/ifcfg/
+mkdir -m 0755 -p /tmp/ifcfg-leases/
 
 for netif in $IFACES ; do
     # bridge?
     unset bridge
     unset bond
+    uuid=$(cat /proc/sys/kernel/random/uuid)
     if [ "$netif" = "$bridgename" ]; then
         bridge=yes
     elif [ "$netif" = "$bondname" ]; then
@@ -35,10 +37,12 @@ for netif in $IFACES ; do
         echo "DEVICE=$netif"
         echo "ONBOOT=yes"
         echo "NETBOOT=yes"
+        echo "UUID=$uuid"
         if [ -f /tmp/net.$netif.lease ]; then
             strstr "$ip" '*:*:*' &&
             echo "DHCPV6C=yes"
             echo "BOOTPROTO=dhcp"
+            cp /tmp/net.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
         else
             echo "BOOTPROTO=none"
         # If we've booted with static ip= lines, the override file is there
@@ -135,9 +139,12 @@ done
 
 # Pass network opts
 mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
+mkdir -m 0755 -p /run/initramfs/state/var/lib/dhclient
 echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
+echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
 {
     cp /tmp/net.* /run/initramfs/
     cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/
     cp -a -t /run/initramfs/state/etc/sysconfig/network-scripts/ /tmp/ifcfg/*
+    cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
 } > /dev/null 2>&1