From 0a311ee0376b4bbfc0fc813ff48a2f4b4dba8242 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Mon, 4 May 2020 06:49:50 +0000 Subject: [PATCH] full_install_osm: replacing the use of route by ip route list as first option Change-Id: I058b891bc00104d29e230a58ec2db634181fff47 Signed-off-by: garciadeblas --- installers/full_install_osm.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 47bcdb2d..7d06ba8b 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -125,7 +125,8 @@ function remove_iptables() { fi if [ -z "$DEFAULT_IP" ]; then - DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'` + DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5}') + [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8}') [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'` [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" @@ -256,7 +257,8 @@ function install_lxd() { sudo usermod -a -G lxd `whoami` cat /usr/share/osm-devops/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$DEFAULT_IP':8443/' | sg lxd -c "lxd init --preseed" sg lxd -c "lxd waitready" - DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}') + DEFAULT_INTERFACE=$(ip route list|awk '$1=="default" {print $5}') + [ -z "$DEFAULT_INTERFACE" ] && DEFAULT_INTERFACE=$(route -n |awk '$1~/^0.0.0.0/ {print $8}') DEFAULT_MTU=$(ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}') sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU" #sudo systemctl stop lxd-bridge @@ -921,7 +923,8 @@ function install_lightweight() { echo "Installing lightweight build of OSM" LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")" trap 'rm -rf "${LWTEMPDIR}"' EXIT - DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'` + DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5}') + [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8}') [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'` [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" -- 2.17.1