Pick just the first route when looking for the host interface
The current code will fail miserably if multiple default routes are
present (perfectly normal if they have different metrics). Fixing
the code to pick the first/top entry
Fixes LP# 1084470
Change-Id: Ieda16b575685071ff831c92e6b2a29737d6f849b
diff --git a/stack.sh b/stack.sh
index 005d88e..2709667 100755
--- a/stack.sh
+++ b/stack.sh
@@ -253,7 +253,7 @@
NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
# Find the interface used for the default route
-HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }')}
+HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }' | head -1)}
# Search for an IP unless an explicit is set by ``HOST_IP`` environment variable
if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then
HOST_IP=""