BEGIN {FS = " ";print "# This file is generated by RLM upon request from Ontap." ; \
        print "# Do NOT modify this file manually." ; \
#       print "auto lo" ; \
#       print "iface lo inet loopback" ; 
}

###### dhcp information ######
/^dhcp/ { dhcp_enabled=$2 }

###### ipv4 information ######
/^ip / { addr=$2 }
/^netmask/ { netmask=$2 }
/^gateway/ { gateway=$2 }

###### ipv6 information ######
/^ip6_addr/ { ip6_addr=$2 }
/^ip6_prefix/ { ip6_prefix=$2 }
/^ip6_gate/ { ip6_gate=$2 }

END {
	print "auto eth0"
	if (ipv4_enabled == 1) {
		if (dhcp_enabled == 1) {
			print "iface eth0 inet dhcp"
			print "   mtu 1400"
		} else {
			print "iface eth0 inet static"
			print "   mtu 1400"
			print "   address " addr
			print "   netmask " netmask
			print "   gateway " gateway
		}
	}
	if ((ipv6_enabled == 1) && (ipv6_global_present == 1)) {
		print "iface eth0 inet6 static"
		print "   mtu 1400"
		print "   address " ip6_addr
		print "   netmask " ip6_prefix
		print "   gateway " ip6_gate
	}
}
