From 28190d595489a027d65b2991e1e4c6fef6fa55bf Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Fri, 11 Oct 2013 11:02:52 -0700 Subject: [PATCH] Make dhcp-all-interfaces block all interfaces Previously dhcp-all-interfaces was only blocking the first network interface to come up. We add an instance stanza to make it run one instance of generate-interfaces-file per interface. We then use flock to serialize runs of generate-interfaces-file. Fixes bug #1233577 Change-Id: Ib16bed6b37ce0789e315ef57e05ac561470a6f2a --- .../dhcp-all-interfaces/install.d/dhcp-all-interfaces.conf | 3 ++- .../install.d/generate-interfaces-file.sh | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.conf b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.conf index a459aa97..8cdbef00 100644 --- a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.conf +++ b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.conf @@ -3,7 +3,8 @@ description "DHCP any connected, but unconfigured network interfaces" -start on starting cloud-init-nonet +start on starting network-interface +instance $INTERFACE task diff --git a/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh b/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh index cc0877f5..bf9d5ac1 100755 --- a/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh +++ b/elements/dhcp-all-interfaces/install.d/generate-interfaces-file.sh @@ -6,6 +6,12 @@ INTERFACES_FILE="/etc/network/interfaces" +# Serialize runs so that we don't miss hot-add interfaces +FLOCK=${1:-} +if [ -z "$FLOCK" ] ; then + exec flock -x $INTERFACES_FILE $0 flocked +fi + function get_if_link() { cat /sys/class/net/${1}/carrier }