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>
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"