Browse code

Merge "Support detection of interfaces with non-word chars in the name"

Jenkins authored on 2015/03/19 02:44:58
Showing 1 changed files
... ...
@@ -542,11 +542,11 @@ function get_default_host_ip {
542 542
     local host_ip_iface=$3
543 543
     local host_ip=$4
544 544
 
545
-    # Find the interface used for the default route
546
-    host_ip_iface=${host_ip_iface:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }' | head -1)}
547 545
     # Search for an IP unless an explicit is set by ``HOST_IP`` environment variable
548 546
     if [ -z "$host_ip" -o "$host_ip" == "dhcp" ]; then
549 547
         host_ip=""
548
+        # Find the interface used for the default route
549
+        host_ip_iface=${host_ip_iface:-$(ip route | awk '/default/ {print $5}' | head -1)}
550 550
         local host_ips=$(LC_ALL=C ip -f inet addr show ${host_ip_iface} | awk '/inet/ {split($2,parts,"/");  print parts[1]}')
551 551
         local ip
552 552
         for ip in $host_ips; do