From 2209d343720f994a71d9451c4b9297af969f7bf5 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 6 Dec 2016 15:51:12 +0100 Subject: [PATCH] debootstrap: avoid duplicate network configuration On Debian network configuration can be done via /etc/network/interfaces. It can accept a statement to load additional files, which varied in history: Wheezy only supports 'source' (see b822581) Jessie supports 'source-directory' and comes with the statement by default. However since 754dd05 we inconditionally inject 'source', thus on Jessie the configuration ends up with: source-directory /etc/network/interfaces.d/* source /etc/network/interfaces.d/* When networking is started, 'ifup -a' parses the list of interfaces twice. When configured with dhcp, that causes two dhclient to spawn which might conflict with each other. Inject the source statement only if there is neither a source or source-directory with the same path. Change-Id: Iefa9c9584f676e50481c621b4111eded3125a50b --- elements/debootstrap/install.d/10-debian-networking | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/elements/debootstrap/install.d/10-debian-networking b/elements/debootstrap/install.d/10-debian-networking index 7e85cbe57..d5cdc1400 100755 --- a/elements/debootstrap/install.d/10-debian-networking +++ b/elements/debootstrap/install.d/10-debian-networking @@ -26,7 +26,10 @@ echo $DISTRO_NAME > /etc/hostname # cloud images expect eth0 and eth1 to use dhcp. mkdir -p /etc/network/interfaces.d -echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces +if ! grep -E -q '^source(|-directory) /etc/network/interfaces.d/\*' /etc/network/interfaces; then + echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces + echo 'Network configuration set to source /etc/network/interfaces.d/*' +fi for interface in eth0 eth1; do cat << EOF | tee /etc/network/interfaces.d/$interface auto $interface