LINUX: ifconfig is deprecated 92/12192/3
authorMichael Meffie <mmeffie@sinenomine.net>
Wed, 24 Feb 2016 21:57:11 +0000 (16:57 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 28 Feb 2016 20:36:56 +0000 (15:36 -0500)
ifconfig is deprecated and is no longer installed by default on RHEL 7 and
Centos 7. Use the replacement ip command in the init script for linux.
Fallback to ifconfig in the event the ip command is not available.

Thanks to Ben Kaduk for pointing out the hash built-in command.

Change-Id: I7ffe272eb712cd83a70a7d880d239f72b40cb5df
Reviewed-on: http://gerrit.openafs.org/12192
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/afsd/afs.rc.linux

index 4df45a1..288baab 100644 (file)
@@ -82,7 +82,15 @@ is_on() {
 }
 
 on_network() {
-    ADDRS=`LANG=C ifconfig -a | grep 'inet ' | grep -v 127.0.0.1 | wc -l`
+    if hash ip 2>/dev/null >/dev/null; then
+        IP="ip -4 addr"
+    elif hash ifconfg 2>/dev/null >/dev/null; then
+        IP="ifconfig -a"
+    else
+        echo afs: Unable to check interfaces. 1>&2
+        return 1
+    fi
+    ADDRS=`LANG=C ${IP} | grep 'inet ' | grep -v 127.0.0.1 | wc -l`
     if [ "$ADDRS" = "" ]; then
        echo afs: No interfaces with IP address 1>&2
        return 1