summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-09-13 20:02:37 -0400
committerScott Moser <smoser@ubuntu.com>2012-09-13 20:02:37 -0400
commitd2f00fd2af9417a91c78e9cab5747cd6e218aa39 (patch)
tree6ca3a0348a09b13e8e5c4768cb570d4a4d6424e7
parent67bf7722398278e7089098dfd683389ef4e418c5 (diff)
downloadvyos-cloud-init-d2f00fd2af9417a91c78e9cab5747cd6e218aa39.tar.gz
vyos-cloud-init-d2f00fd2af9417a91c78e9cab5747cd6e218aa39.zip
only emit if there is a device present.
-rw-r--r--upstart/cloud-init-container.conf14
1 files 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# }" ] ||