diff -Nru cloud-initramfs-tools-0.27ubuntu1.1/cloud-initramfs-dyn-netconf cloud-initramfs-tools-0.27ubuntu1.2/cloud-initramfs-dyn-netconf --- cloud-initramfs-tools-0.27ubuntu1.1/cloud-initramfs-dyn-netconf 2016-09-26 14:23:31.000000000 +0000 +++ cloud-initramfs-tools-0.27ubuntu1.2/cloud-initramfs-dyn-netconf 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -#!/bin/sh -set -e - -PREREQS="" -case $1 in - prereqs) echo "${PREREQS}"; exit 0;; -esac - -. /scripts/functions - -PATH=/usr/sbin:/usr/bin:/sbin:/bin - -# doc in klibc-utils /usr/share/doc/libklibc/README.ipconfig.gz -# example below: -#DEVICE='eth0' -#PROTO='dhcp' ## none, off, static. not present in precise -#IPV4ADDR='192.168.122.89' -#IPV4BROADCAST='192.168.122.255' -#IPV4NETMASK='255.255.255.0' -#IPV4GATEWAY='192.168.122.1' -#IPV4DNS0='192.168.122.1' ## only come from dhcp -#IPV4DNS1='0.0.0.0' -#HOSTNAME='' -#DNSDOMAIN='' -#NISDOMAIN='' -#ROOTSERVER='192.168.122.1' -#ROOTPATH='' -#filename='' -#UPTIME='21' -#DHCPLEASETIME='3600' -#DOMAINSEARCH='' - -error() { echo "${0##*/}:" "$@" 1>&2; } -configure_net_if_needed() { - # we want to call configure_networking if and only if ip= was seen - # on the command line (LP: #1463846) - local ip="$1" - # empty 'ip' or ip=none or ip=off specifically mean do not bring up - [ -z "$ip" ] && return 0 - case "$ip" in - none|off) return 0;; - esac - # configure_networking does not set any flags indicating it tried - # to run and failed, so we can only look for indication - # that ipconfig ran, which creates files in /run/net-.conf - # - # configure_networking does a check like this. however, its check is - # broken in the event that BOOTIF is not found on the command line. - for f in /run/net-*.conf /tmp/net-*.conf; do - [ -f "$f" ] && return 0 - done - - configure_networking -} - -ni_header() { - echo "## This file is generated by cloud-initramfs-dyn-netconf" - echo "auto lo" - echo "iface lo inet loopback" -} - - -configure_net_if_needed "$IP" || - echo "WARN: ${0##*/}: configure_networking failed" 1>&2 - -tmpf="/tmp/${0##*/}.ni" - -ni_header > "$tmpf" -seen="," -for f in /run/net-*.conf /tmp/net-*.conf; do - [ -f "$f" ] || continue - dev=${f#*/net-}; dev=${dev%.conf}; - # perhaps we saw this device from /run and now we're in /tmp - [ "${seen#*,${dev},}" = "${seen}" ] || continue - - seen="${seen}${dev}," - - DEVICE=""; PROTO=""; IPV4ADDR=""; IPV4NETMASK=""; IPV4GATEWAY=""; - IPV4DNS0=""; IPV4DNS1=""; DNSDOMAIN=""; DOMAINSEARCH=""; filename=""; - IPV4PROTO=""; IPV6PROTO=""; IPV6ADDR=""; IPV6NETMASK=""; - IPV6GATEWAY=""; IPV6DNS0=""; IPV6DNS1=""; IPV6DOMAINSEARCH=""; - . "$f" - - if [ -z "$DEVICE" ]; then - error "WARNING: $f had no 'DEVICE' set" - continue - fi - # If IPv6 is supported, we get both of these, and one of them is set. - # Prior to that, PROTO was used, so we know it's IPv4 we want. - if [ -z "$IPV4PROTO" -a -z "$IPV6PROTO" ]; then - IPV4PROTO="$PROTO" - fi - # ipconfig on precise does not write PROTO. - if [ -z "$IPV4PROTO" -a -z "$IPV6PROTO" ]; then - if [ -n "$filename" ]; then - IPV4PROTO="dhcp" - else - IPV4PROTO="static" - fi - fi - - echo "manual $DEVICE" - if [ "$IPV4PROTO" = "dhcp" ]; then - echo "iface $DEVICE inet dhcp" - elif [ "$IPV4PROTO" = "static" ]; then - echo "iface $DEVICE inet static" - [ -n "$IPV4ADDR" ] && printf "\t%s\n" "address $IPV4ADDR" - [ -n "$IPV4NETMASK" ] && printf "\t%s\n" "netmask $IPV4NETMASK" - [ -n "$IPV4GATEWAY" ] && printf "\t%s\n" "gateway $IPV4GATEWAY" - fi - if [ "$IPV6PROTO" = "dhcp" ]; then - echo "iface $DEVICE inet6 dhcp" - elif [ "$IPV6PROTO" = "static" ]; then - echo "iface $DEVICE inet6 static" - [ -n "$IPV6ADDR" ] && printf "\t%s\n" "address $IPV6ADDR" - [ -n "$IPV6NETMASK" ] && printf "\t%s\n" "netmask $IPV6NETMASK" - [ -n "$IPV6GATEWAY" ] && printf "\t%s\n" "gateway $IPV6GATEWAY" - fi - if [ -n "$IPV4DNS0" -a "$IPV4DNS0" != "0.0.0.0" ]; then - nsline="${IPV4DNS0}" - [ -n "$IPV4DNS1" -a "$IPV4DNS1" != "0.0.0.0" ] && - nsline="${nsline} ${IPV4DNS1}" - fi - if [ -n "$IPV6DNS0" -a "$IPV6DNS0" != "0.0.0.0" ]; then - nsline="${IPV6DNS0}" - [ -n "$IPV6DNS1" -a "$IPV6DNS1" != "0.0.0.0" ] && - nsline="${nsline} ${IPV6DNS1}" - fi - [ -n "$nsline" ] && printf "\tdns-nameservers %s\n" "$nsline" - [ -n "$DNSDOMAIN" -o -n "$DOMAINSEARCH" -o -n $IPV6DOMAINSEARCH] && - SEARCH=" ${DNSDOMAIN} ${DOMAINSEARCH} ${IPV6DOMAINSEARCH}" && - printf "\tdns-search %s\n" "${SEARCH}" -done >> "$tmpf" - -[ -d /run/network ] || mkdir /run/network -mv "$tmpf" /run/network/dynamic-interfaces - -# vi: ts=4 noexpandtab diff -Nru cloud-initramfs-tools-0.27ubuntu1.1/debian/changelog cloud-initramfs-tools-0.27ubuntu1.2/debian/changelog --- cloud-initramfs-tools-0.27ubuntu1.1/debian/changelog 2016-09-26 14:23:31.000000000 +0000 +++ cloud-initramfs-tools-0.27ubuntu1.2/debian/changelog 2016-10-04 20:52:53.000000000 +0000 @@ -1,8 +1,8 @@ -cloud-initramfs-tools (0.27ubuntu1.1) xenial; urgency=medium +cloud-initramfs-tools (0.27ubuntu1.2) xenial; urgency=medium * Add IPV6 support to cloud-initramfs-dyn-netconf. (LP: #1621615) - -- LaMont Jones Mon, 26 Sep 2016 08:23:31 -0600 + -- LaMont Jones Tue, 04 Oct 2016 14:52:53 -0600 cloud-initramfs-tools (0.27ubuntu1) wily; urgency=medium diff -Nru cloud-initramfs-tools-0.27ubuntu1.1/dyn-netconf/scripts/init-bottom/cloud-initramfs-dyn-netconf cloud-initramfs-tools-0.27ubuntu1.2/dyn-netconf/scripts/init-bottom/cloud-initramfs-dyn-netconf --- cloud-initramfs-tools-0.27ubuntu1.1/dyn-netconf/scripts/init-bottom/cloud-initramfs-dyn-netconf 2016-09-26 14:23:31.000000000 +0000 +++ cloud-initramfs-tools-0.27ubuntu1.2/dyn-netconf/scripts/init-bottom/cloud-initramfs-dyn-netconf 2016-10-04 20:51:25.000000000 +0000 @@ -67,7 +67,9 @@ # on the command line (LP: #1463846) local ip="$1" # empty 'ip' or ip=none or ip=off specifically mean do not bring up - [ -z "$ip" ] && return 0 + if [ -z "$ip" ]; then + return 0 + fi case "$ip" in none|off) return 0;; esac @@ -78,7 +80,9 @@ # configure_networking does a check like this. however, its check is # broken in the event that BOOTIF is not found on the command line. for f in /run/net-*.conf /tmp/net-*.conf; do - [ -f "$f" ] && return 0 + if [ -f "$f" ]; then + return 0 + fi done configure_networking @@ -108,15 +112,16 @@ DEVICE=""; PROTO=""; IPV4ADDR=""; IPV4NETMASK=""; IPV4GATEWAY=""; IPV4DNS0=""; IPV4DNS1=""; DNSDOMAIN=""; DOMAINSEARCH=""; filename=""; - IPV4PROTO=""; IPV6PROTO=""; IPV6ADDR=""; IPV6NETMASK=""; - IPV6GATEWAY=""; IPV6DNS0=""; IPV6DNS1=""; IPV6DOMAINSEARCH=""; + IPV4PROTO=""; IPV6PROTO=""; IPV6ADDR=""; IPV6NETMASK=""; + IPV6GATEWAY=""; IPV6DNS0=""; IPV6DNS1=""; IPV6DOMAINSEARCH=""; . "$f" if [ -z "$DEVICE" ]; then error "WARNING: $f had no 'DEVICE' set" continue fi - # If IPv6 is supported, we get both of these, and one of them is set. + # If IPv6 is supported, we get both of these, and at least one of them + # is set. If we get both, use IPv4. # Prior to that, PROTO was used, so we know it's IPv4 we want. if [ -z "$IPV4PROTO" -a -z "$IPV6PROTO" ]; then IPV4PROTO="$PROTO" @@ -130,37 +135,59 @@ fi fi + # We need to use care, since the script is running set -e. echo "manual $DEVICE" if [ "$IPV4PROTO" = "dhcp" ]; then echo "iface $DEVICE inet dhcp" elif [ "$IPV4PROTO" = "static" ]; then echo "iface $DEVICE inet static" - [ -n "$IPV4ADDR" ] && printf "\t%s\n" "address $IPV4ADDR" - [ -n "$IPV4NETMASK" ] && printf "\t%s\n" "netmask $IPV4NETMASK" - [ -n "$IPV4GATEWAY" ] && printf "\t%s\n" "gateway $IPV4GATEWAY" - fi - if [ "$IPV6PROTO" = "dhcp6" ]; then + if [ -n "$IPV4ADDR" ]; then + printf "\t%s\n" "address $IPV4ADDR" + else + error "WARNING: $f static with no address" + fi + if [ -n "$IPV4NETMASK" ]; then + printf "\t%s\n" "netmask $IPV4NETMASK" + else + error "WARNING: $f static with no netmask" + fi + if [ -n "$IPV4GATEWAY" ]; then + printf "\t%s\n" "gateway $IPV4GATEWAY" + fi + elif [ "$IPV6PROTO" = "dhcp6" ]; then echo "iface $DEVICE inet6 dhcp" elif [ "$IPV6PROTO" = "static" ]; then echo "iface $DEVICE inet6 static" - [ -n "$IPV6ADDR" ] && printf "\t%s\n" "address $IPV6ADDR" - [ -n "$IPV6NETMASK" ] && printf "\t%s\n" "netmask $IPV6NETMASK" - [ -n "$IPV6GATEWAY" ] && printf "\t%s\n" "gateway $IPV6GATEWAY" + if [ -n "$IPV6ADDR" ]; then + printf "\t%s\n" "address $IPV6ADDR" + else + error "WARNING: $f static with no address" + fi + if [ -n "$IPV6NETMASK" ]; then + printf "\t%s\n" "netmask $IPV6NETMASK" + else + error "WARNING: $f static with no netmask" + fi + if [ -n "$IPV6GATEWAY" ]; then + printf "\t%s\n" "gateway $IPV6GATEWAY" + fi fi + nsline="" if [ -n "$IPV4DNS0" -a "$IPV4DNS0" != "0.0.0.0" ]; then nsline="${IPV4DNS0}" - [ -n "$IPV4DNS1" -a "$IPV4DNS1" != "0.0.0.0" ] && + if [ -n "$IPV4DNS1" -a "$IPV4DNS1" = "0.0.0.0" ]; then nsline="${nsline} ${IPV4DNS1}" - fi - if [ -n "$IPV6DNS0" ]; then - nsline="${IPV6DNS0}" - [ -n "$IPV6DNS1" ] && nsline="${nsline} ${IPV6DNS1}" - fi - [ -n "$nsline" ] && printf "\tdns-nameservers %s\n" "$nsline" - [ -n "$DNSDOMAIN" -o -n "$DOMAINSEARCH" -o -n $IPV6DOMAINSEARCH] && - SEARCH=" ${DNSDOMAIN} ${DOMAINSEARCH} ${IPV6DOMAINSEARCH}" && + fi + elif [ -n "$IPV6DNS0" ]; then + nsline="${nsline} ${IPV6DNS0}" + [ -z "$IPV6DNS1" ] || nsline="${nsline} ${IPV6DNS1}" + fi + [ -z "$nsline" ] || printf "\tdns-nameservers %s\n" "$nsline" + if [ -n "${DNSDOMAIN}${DOMAINSEARCH}${IPV6DOMAINSEARCH}" ]; then + SEARCH=" ${DNSDOMAIN} ${DOMAINSEARCH} ${IPV6DOMAINSEARCH}" printf "\tdns-search %s\n" "${SEARCH}" + fi done >> "$tmpf" [ -d /run/network ] || mkdir /run/network