Do not use route, use ip only if available

* Do not use /sbin/route at all, and use ip only if it is available. The
    previous "fix" was in fact wrong, as net-tools and iproute2 aren't
    essential packages and adding it as depends wont fix.

Change-Id: I88aa9794f39725c249ca167092217b524446052c
This commit is contained in:
Thomas Goirand 2017-03-31 14:28:06 +02:00
parent 9f07414181
commit b68ebfe9d2
3 changed files with 14 additions and 3 deletions

8
debian/changelog vendored
View File

@ -1,3 +1,11 @@
keystone (2:10.0.0-8) unstable; urgency=medium
* Do not use /sbin/route at all, and use ip only if it is available. The
previous "fix" was in fact wrong, as net-tools and iproute2 aren't
essential packages and adding it as depends wont fix.
-- Thomas Goirand <zigo@debian.org> Fri, 31 Mar 2017 14:26:30 +0200
keystone (2:10.0.0-7) unstable; urgency=medium
* Team upload.

1
debian/control vendored
View File

@ -147,7 +147,6 @@ Depends: adduser,
dbconfig-common,
init-system-helpers (>= 1.22~),
libapache2-mod-wsgi,
net-tools,
python-keystone (= ${source:Version}),
q-text-as-data,
sqlite3,

View File

@ -65,9 +65,13 @@ keystone_create_endpoint_config () {
db_get keystone/endpoint-ip
IP=${RET}
if [ -z "${IP}" ] ; then
DEFROUTE_IF=`LC_ALL=C /sbin/route | grep default |awk -- '{ print $8 }' | cut -d" " -f1`
DEFROUTE_IF=`awk '{ if ( $2 == "00000000" ) print $1 }' /proc/net/route`
if [ -n "${DEFROUTE_IF}" ] ; then
DEFROUTE_IP=`LC_ALL=C ip addr show "${DEFROUTE_IF}" | grep inet | head -n 1 | awk '{print $2}' | cut -d/ -f1 | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
if [ -x /bin/ip ] ; then
DEFROUTE_IP=`LC_ALL=C ip addr show "${DEFROUTE_IF}" | grep inet | head -n 1 | awk '{print $2}' | cut -d/ -f1 | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
else
DEFROUTE_IP=`hostname -i | grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'`
fi
if [ -n "${DEFROUTE_IP}" ] ; then
db_set keystone/endpoint-ip ${DEFROUTE_IP}
fi