From f7a207d02c18a59ff573f059a1c1f5225676e3e5 Mon Sep 17 00:00:00 2001 From: garciadeblas <gerardo.garciadeblas@telefonica.com> Date: Thu, 30 Jan 2025 15:54:08 +0100 Subject: [PATCH] Setup IP address env vars before running installation of specific components Change-Id: I5e03fbe660a68845726188c0abba9ecf78a28908 Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com> --- installers/full_install_osm.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index f6f30e07..2875228a 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -473,6 +473,16 @@ function deploy_osm() { [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } +function setup_external_ip() { + echo "Determining IP address of the interface with the default route" + [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}') + [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}') + [ -z "$OSM_DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" + OSM_DEFAULT_IP=`ip -o -4 a s ${OSM_DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}'` + [ -z "$OSM_DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" + OSM_K8S_EXTERNAL_IP=${OSM_K8S_EXTERNAL_IP:-${OSM_DEFAULT_IP}} +} + function install_osm() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function @@ -497,13 +507,8 @@ function install_osm() { [ -n "$DOCKER_REGISTRY_URL" ] && parse_docker_registry_url - echo "Determining IP address of the interface with the default route" - [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}') - [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}') - [ -z "$OSM_DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" - OSM_DEFAULT_IP=`ip -o -4 a s ${OSM_DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}'` - [ -z "$OSM_DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" - OSM_K8S_EXTERNAL_IP=${OSM_K8S_EXTERNAL_IP:-${OSM_DEFAULT_IP}} + echo "Setting up external IP address" + setup_external_ip # configure apt proxy [ -n "$APT_PROXY_URL" ] && configure_apt_proxy $APT_PROXY_URL @@ -1021,6 +1026,7 @@ else # Community_installer # Special cases go first if [ -n "$INSTALL_ONLY" ]; then + setup_external_ip [ -n "$INSTALL_ONLY_DOCKER_CE" ] && install_docker_ce [ -n "$INSTALL_ONLY_K8S_CLUSTER" ] && install_k8s_cluster [ -n "$INSTALL_K8S_MONITOR" ] && install_k8s_monitoring -- GitLab