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
This commit is contained in:
Clint Byrum 2013-10-11 11:02:52 -07:00
parent 2129d78124
commit 28190d5954
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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
}