From: David Disseldorp Date: Wed, 27 Apr 2016 12:25:47 +0000 (+0200) Subject: vstart: use ip addr instead of ifconfig if available X-Git-Tag: v11.0.0~55^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=79a7d40ef1e5da3a68ffb7e6546499fbbfa99c26;p=ceph-ci.git vstart: use ip addr instead of ifconfig if available Ifconfig is obsolete with Linux 2.0+, and may not be in a user's PATH. Use ip addr by default and fall-back to ifconfig if it's missing. Signed-off-by: David Disseldorp --- diff --git a/src/vstart.sh b/src/vstart.sh index cfbdd1fc863..018d322f346 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -387,8 +387,13 @@ if [ -n "$ip" ]; then IP="$ip" else echo hostname $HOSTNAME + if [ -x "$(which ip 2>/dev/null)" ]; then + IP_CMD="ip addr" + else + IP_CMD="ifconfig" + fi # filter out IPv6 and localhost addresses - IP="$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1)" + IP="$($IP_CMD | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1)" # if nothing left, try using localhost address, it might work if [ -z "$IP" ]; then IP="127.0.0.1"; fi fi