Write ifcfg style file upon successful netboot.
authorWarren Togami <wtogami@redhat.com>
Wed, 10 Jun 2009 17:16:50 +0000 (13:16 -0400)
committerWarren Togami <wtogami@redhat.com>
Wed, 10 Jun 2009 17:16:50 +0000 (13:16 -0400)
TODO: static must be implemented, example in comments.

modules.d/40network/netroot

index 8b91d74..cd988e9 100755 (executable)
@@ -47,9 +47,26 @@ fi
 # XXX other variables to export?
 export NEWROOT
 if $handler $netif $root; then
+    # Network rootfs mount successful
     [ -f /tmp/dhclient.$netif.lease ] &&    cp /tmp/dhclient.$netif.lease    /tmp/net.$netif.lease
     [ -f /tmp/dhclient.$netif.dhcpopts ] && cp /tmp/dhclient.$netif.dhcpopts /tmp/net.$netif.dhcpopts
     cat /sys/class/net/eth0/address > /tmp/net.$netif.hwaddr
+    echo "# Generated by dracut initrd" > /tmp/net.$netif.ifcfg
+    echo "DEVICE=$netif" >> /tmp/net.$netif.ifcfg
+    echo "HWADDR=$(cat /sys/class/net/eth0/address)" >> /tmp/net.$netif.ifcfg
+    echo "TYPE=Ethernet" >> /tmp/net.$netif.ifcfg
+    echo "ONBOOT=yes" >> /tmp/net.$netif.ifcfg
+    if [ -f /tmp/net.$netif.lease ]; then
+        echo "BOOTPROTO=dhcp" >> /tmp/net.$netif.ifcfg
+    else
+        echo "BOOTPROTO=none" >> /tmp/net.$netif.ifcfg
+        # Static: XXX Implement me!
+        #IPADDR=172.16.101.1
+        #NETMASK=255.255.255.0
+        #DNS1=1.2.3.4
+        #DNS2=1.2.3.5
+        #GATEWAY=172.16.101.254
+    fi
     >/tmp/netroot.done
 fi
 exit 0