write-ifcfg: Save static ip configuration
authorPhilippe Seewer <philippe.seewer@bfh.ch>
Tue, 16 Jun 2009 10:14:02 +0000 (12:14 +0200)
committerPhilippe Seewer <philippe.seewer@bfh.ch>
Wed, 17 Jun 2009 06:37:39 +0000 (08:37 +0200)
Saveing ip= options in ifup makes the information available for
later use. This solves the problem how to write static ip configuration
in ifcfg files.

modules.d/40network/write-ifcfg.sh

index 2a88b3b..e5f25d5 100755 (executable)
@@ -15,10 +15,9 @@ 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
+    # If we've booted with static ip= lines, the override file is there
+    . /tmp/net.$netif.override 
+    echo "IPADDR=$ip" >> /tmp/net.$netif.ifcfg
+    echo "NETMASK=$mask" >> /tmp/net.$netif.ifcfg
+    [ -n "$gw" ] && echo "GATEWAY=$gw" >> /tmp/net.$netif.ifcfg
 fi