only emit if there is a device present.

This commit is contained in:
Scott Moser 2012-09-13 20:02:37 -04:00
parent 0d887da00f
commit 006048c68e
1 changed files with 12 additions and 2 deletions

View File

@ -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# }" ] ||