From d2f00fd2af9417a91c78e9cab5747cd6e218aa39 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 13 Sep 2012 20:02:37 -0400 Subject: only emit if there is a device present. --- upstart/cloud-init-container.conf | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/upstart/cloud-init-container.conf b/upstart/cloud-init-container.conf index b3123721..497e75c8 100644 --- a/upstart/cloud-init-container.conf +++ b/upstart/cloud-init-container.conf @@ -27,13 +27,23 @@ script set -- ${auto_list} [ "$*" = "lo" ] && exit 0 - to_emit="" + # we only want to emit for interfaces that do not exist, so filter + # out anything that does not exist. for iface in "$@"; do [ "$iface" = "lo" ] && continue # skip interfaces that are already up [ -f "${MARK_DEV_PREFIX}${iface}" ] && continue + + if [ -d /sys/net ]; then + # if /sys is mounted, and there is no /sys/net/iface, then no device + [ -e "/sys/net/$iface" ] && continue + else + # sys wasn't mounted, so just check via 'ifconfig' + ifconfig "$iface" >/dev/null 2>&1 || continue + fi initctl emit --no-wait net-device-added "INTERFACE=$iface" && - emitted="${emitted} ${iface}" || : + emitted="$emitted $iface" || + echo "warn: ${UPSTART_JOB} failed to emit net-device-added INTERFACE=$iface" done [ -z "${emitted# }" ] || -- cgit v1.2.3