]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
vstart.sh: use portable way to get ip address
authorYan, Zheng <zyan@redhat.com>
Thu, 23 Jul 2015 02:24:33 +0000 (10:24 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 31 Aug 2015 08:00:23 +0000 (16:00 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/vstart.sh

index dcb131f4f64fb3b59c069ed197474b0a51380082..8f3ca4def82cd9b03afe34079d08685bfd4c5c5d 100755 (executable)
@@ -326,11 +326,10 @@ if [ -n "$ip" ]; then
     IP="$ip"
 else
     echo hostname $HOSTNAME
-    RAW_IP=`hostname -I`
     # filter out IPv6 and localhost addresses
-    IP="$(echo "$RAW_IP"|tr ' ' '\012'|grep -v :|grep -v '^127\.'|head -n1)"
-    # if that left nothing, then try to use the raw thing, it might work
-    if [ -z "$IP" ]; then IP="$RAW_IP"; fi
+    IP="$(ifconfig | 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
     echo ip $IP
 fi
 echo "ip $IP"