]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
vstart.sh: Filter out IPv6 and localhost IP addresses.
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Mon, 28 Mar 2011 22:45:45 +0000 (15:45 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Mon, 28 Mar 2011 22:50:57 +0000 (15:50 -0700)
On e.g. Ubuntu 10.10, hostname --ip-address outputs something
like "::1 10.1.2.3 127.0.1.1", and this makes the generated
config be invalid. Get rid of the entries we can't use.

Signed-off-by: Tommi Virtanen <tommi.virtanen@dreamhost.com>
src/vstart.sh

index 40da62af8a56ec283381eb88dbc685bea3283810..13542664ae338be93b334d5d0b0de281484f5f3d 100755 (executable)
@@ -215,7 +215,12 @@ if [ "$localhost" -eq 1 ]; then
 else
     HOSTNAME=`hostname`
     echo hostname $HOSTNAME
-    IP=`hostname --ip-address`
+    RAW_IP=`hostname --ip-address`
+    # 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
+    echo ip $IP
 fi
 echo "ip $IP"