]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
net-lib: remove calls to ip with -oneline option 500/head
authorNorbert Lange <norbert.lange@andritz.com>
Fri, 7 Dec 2018 15:12:06 +0000 (16:12 +0100)
committerNorbert Lange <norbert.lange@andritz.com>
Wed, 12 Dec 2018 15:13:50 +0000 (16:13 +0100)
busybox seems to not properly support this option,
and it can be be safely ommitted or replaced
with piping the output through head.

Rev 2:
*   rebased on master
*   addressed open points from review

modules.d/40network/net-lib.sh

index 964ed3ab81576d5c70f4262c62ef64bc02da084f..19a2fa53a6e3f736102625c3daa270ec6976f5c1 100755 (executable)
@@ -14,20 +14,20 @@ is_ip() {
 
 get_ip() {
     local iface="$1" ip=""
-    ip=$(ip -o -f inet addr show $iface)
+    ip=$(ip -f inet addr show $iface)
     ip=${ip%%/*}
     ip=${ip##* }
     echo $ip
 }
 
 iface_for_remote_addr() {
-    set -- $(ip -o route get to $1)
-    echo $5
+    set -- $(ip route get to $1 | sed  's/.*\bdev\b//p;q')
+    echo $1
 }
 
 iface_for_ip() {
-    set -- $(ip -o addr show to $1)
-    echo $2
+    set -- $(ip addr show to $1)
+    echo ${2%:}
 }
 
 iface_for_mac() {
@@ -593,7 +593,7 @@ wait_for_if_link() {
     timeout=$(($timeout*10))
 
     while [ $cnt -lt $timeout ]; do
-        li=$(ip -o link show dev $1 2>/dev/null)
+        li=$(ip link show dev $1 2>/dev/null)
         [ -n "$li" ] && return 0
         sleep 0.1
         cnt=$(($cnt+1))
@@ -609,7 +609,7 @@ wait_for_if_up() {
     timeout=$(($timeout*10))
 
     while [ $cnt -lt $timeout ]; do
-        li=$(ip -o link show up dev $1)
+        li=$(ip link show up dev $1)
         if [ -n "$li" ]; then
             case "$li" in
                 *\<UP*)
@@ -721,12 +721,12 @@ iface_has_carrier() {
 
     linkup "$1"
 
-    li=$(ip -o link show up dev $1)
+    li=$(ip link show up dev $1)
     strstr "$li" "NO-CARRIER" && _no_carrier_flag=1
 
     while [ $cnt -lt $timeout ]; do
         if [ -n "$_no_carrier_flag" ]; then
-            li=$(ip -o link show up dev $1)
+            li=$(ip link show up dev $1)
             # NO-CARRIER flag was cleared
             strstr "$li" "NO-CARRIER" || return 0
         elif ! [ -e "$interface/carrier" ]; then
@@ -747,7 +747,7 @@ iface_has_link() {
 
 iface_is_enslaved() {
     local _li
-    _li=$(ip -o link show dev $1)
+    _li=$(ip link show dev $1)
     strstr "$li" " master " || return 1
     return 0
 }