Feature 11071: Modular OSM installation
Change-Id: Ia9aa75afdce98d061b1b18b6efa6f33e19045d86
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/library/all_funcs b/library/all_funcs
new file mode 100644
index 0000000..144ac6a
--- /dev/null
+++ b/library/all_funcs
@@ -0,0 +1,28 @@
+# this file is meant to be sourced
+#
+# Copyright 2016 RIFT.IO Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# import all functions
+#
+# 24 June 2016 -- Jeremy Mordkoff -- Genesis
+
+if [ -z "$OSM_DEVOPS" ]; then
+ export OSM_DEVOPS=$(realpath ${BASH_SOURCE[0]} )
+fi
+
+for file in logging config container git_functions track utils.sh functions.sh trap.sh; do
+ . ${OSM_DEVOPS}/library/$file
+ INFO "$file sourced"
+done
diff --git a/library/config b/library/config
new file mode 100644
index 0000000..7f49381
--- /dev/null
+++ b/library/config
@@ -0,0 +1,40 @@
+#!/bin/bash
+# This file is meant to be SOURCED
+#
+# Copyright 2016 RIFT.IO Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# config functions
+# 24 June 2016 -- Jeremy Mordkoff -- Genesis
+
+
+OSM_load_config() {
+ OSM_load_config_file ${OSM_JENKINS}/SETTINGS
+ if [ -z "$OSM_MDG" ]; then
+ WARNING "OSM_MDG not set"
+ else
+ OSM_load_config_file ${OSM_JENKINS}/${OSM_MDG}/SETTINGS
+ fi
+}
+
+OSM_load_config_file() {
+ [ $# -eq 1 ] || FATAL "arg is filename"
+ if [ -f "$1" ]; then
+ . "$1"
+ INFO "config file $1 loaded"
+ else
+ WARNING "$1 not found"
+ fi
+}
+
diff --git a/library/container b/library/container
new file mode 100644
index 0000000..e29d5eb
--- /dev/null
+++ b/library/container
@@ -0,0 +1,89 @@
+# This file is meant to be SOURCED
+#
+# Copyright 2016 RIFT.IO Inc
+# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# container_funcs
+# 24 June 2016 -- Jeremy Mordkoff -- Genesis
+# -- Gerardo García
+
+container_exists() {
+ if [ $# -ne 1 ]; then
+ FATAL "arg is container name"
+ fi
+ lxc config show $1 >/dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ DEBUG "container $1 exists"
+ return 0
+ else
+ DEBUG "container $1 not found"
+ return 1
+ fi
+}
+
+create_container() {
+ if [ $# -lt 2 ]; then
+ FATAL "args are image container [options]"
+ fi
+ INFO "creating container $2 using image $1"
+ image=$1
+ container=$2
+ shift 2
+ DEBUG "lxc launch $image $container $*"
+ lxc launch "$image" "$container" $*
+}
+
+container_exec() {
+ container="$1"
+ shift
+ DEBUG "exec in $container \"$*\""
+ lxc exec "$container" -- $*
+}
+
+container_exec_stderr() {
+ container="$1"
+ shift
+ DEBUG "exec in $container \"$*\""
+ lxc exec "$container" -- $* 2>&1
+}
+
+wait_container_up() {
+ [ $# -eq 1 ] || FATAL "arg is container name got $# args - $*"
+ RE="200"
+ ct=0
+ while [ $ct -lt 10 ]; do
+ let ct=ct+1
+ output=$(container_exec_stderr "$1" curl -sL -w "%{http_code}\\n" "http://www.google.com/" -o /dev/null)
+ if [[ $output =~ $RE ]]; then
+ DEBUG "$1 is up"
+ return
+ fi
+ INFO "waiting for container $1 to start"
+ DEBUG "expected '$RE' in $output"
+ sleep 5
+ done
+ FATAL "container $1 did not start"
+}
+container_push_tree() {
+ # create a tarball locally, pipe it into the container and unpack it there
+ [ $# -eq 3 ] || FATAL "args are container dir_from dir_to (dir_to MUST exist)"
+ tar -C "$2" -c . -f - | container_exec $1 tar -C "$3" -x -f -
+}
+
+container_push_devops() {
+ [ $# -eq 1 ] || FATAL "arg is container name got $# args - $*"
+ container_exec "$1" mkdir -p /root/devops
+ container_push_tree "$1" "$(dirname $OSM_JENKINS)" "/root/devops"
+}
diff --git a/library/functions.sh b/library/functions.sh
new file mode 100755
index 0000000..638a1d2
--- /dev/null
+++ b/library/functions.sh
@@ -0,0 +1,91 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+BLUE='\033[0;34m'
+CYAN='\033[0;36m'
+RESET='\033[0m'
+
+# Colored messages (blue is the default)
+# Examples:
+# m "hello world"
+# m "hello world" "$GREEN"
+function m() {
+ local COLOR=${2:-$BLUE}
+ echo -e "$COLOR$1$RESET"
+}
+
+function copy_function() {
+ local ORIG_FUNC=$(declare -f $1)
+ local NEWNAME_FUNC="$2${ORIG_FUNC#$1}"
+ eval "$NEWNAME_FUNC"
+}
+
+function replace_text() {
+ local FILE=$1
+ local START=$2
+ local END=$3
+ local NEW=$4
+ local T=$(mktemp)
+ head -n $((START-1)) "$FILE" > "$T"
+ echo "$NEW" >> "$T"
+ tail -n +$((END+1)) "$FILE" >> "$T"
+ mv "$T" "$FILE"
+}
+
+function insert_text() {
+ local FILE=$1
+ local START=$2
+ local NEW=$3
+ local T=$(mktemp)
+ head -n $((START-1)) "$FILE" > "$T"
+ echo "$NEW" >> "$T"
+ tail -n +$START "$FILE" >> "$T"
+ mv "$T" "$FILE"
+}
+
+function remove_text() {
+ local FILE=$1
+ local START=$2
+ local END=$3
+ local T=$(mktemp)
+ head -n $((START-1)) "$FILE" > "$T"
+ tail -n +$((END+1)) "$FILE" >> "$T"
+ mv "$T" "$FILE"
+}
+
+function envsubst_cp() {
+ local FROM_FILE=$1
+ local TO_FILE=$2
+ mkdir --parents "$(dirname "$TO_FILE")"
+ cat "$FROM_FILE" | envsubst > "$TO_FILE"
+}
+
+function envsubst_dir() {
+ local FROM_DIR=$1
+ local TO_DIR=$2
+ rm --recursive --force "$TO_DIR"
+ mkdir --parents "$TO_DIR"
+ pushd "$FROM_DIR" > /dev/null
+ local F
+ find . -type f | while read F; do
+ envsubst_cp "$F" "$TO_DIR/$F"
+ done
+ popd > /dev/null
+}
diff --git a/library/git_functions b/library/git_functions
new file mode 100644
index 0000000..7cfee88
--- /dev/null
+++ b/library/git_functions
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+GIT() {
+ CMD git "$@"
+}
+
+
+OSM_git_checkout() {
+
+ # Updates all the branches in the local repo (clones if it does not exist)
+ if [ -d $OSM_MDG ]; then
+ INFO "reusing existing workspace"
+ cd $OSM_MDG
+ GIT fetch --all --tags
+ #git checkout master #to make sure that we are in the right branch before pulling the code
+ #git pull
+ else
+ INFO "cloning MDG $OSM_MDG from $OSM_GIT_URL/$OSM_MDG"
+ GIT clone $OSM_GIT_URL/$OSM_MDG
+ cd $OSM_MDG
+ for remote in `git branch -r |grep -v /HEAD`; do GIT branch --track ${remote#origin/} $remote; done
+ fi
+
+ if [ $# -gt 0 ]; then
+ if [ "$1" = "checkout" ]; then
+ INFO "Code to compile: '$2'"
+ GIT checkout $2
+ else
+ INFO "Code to compile: gerrit refspec '$1', commit-id: '$2'"
+ GIT fetch origin $1 || FATAL "git fetch origin '$1' didn't work"
+ GIT checkout -f $2 || FATAL "git checkout -f '$2' didn't work"
+ fi
+ else
+ INFO "Code to compile: master"
+ GIT checkout master
+ fi
+
+}
+
diff --git a/library/logging b/library/logging
new file mode 100644
index 0000000..080eb63
--- /dev/null
+++ b/library/logging
@@ -0,0 +1,68 @@
+#!/bin/bash
+# This file is meant to be SOURCED
+#
+# Copyright 2016 RIFT.IO Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# container_funcs
+# 24 June 2016 -- Jeremy Mordkoff -- Genesis
+
+print_stack() {
+ local i
+ local stack_size=${#FUNCNAME[1]}
+ echo "BACKTRACE:" >&2
+ for (( i=1; i<$stack_size ; i++ )); do
+ local func="${FUNCNAME[$i]}"
+ [ x$func = x ] && func=MAIN
+ local linen="${BASH_LINENO[(( i - 1 ))]}"
+ local src="${BASH_SOURCE[$i]}"
+ [ x"$src" = x ] && src=non_file_source
+ echo "### $func $src $linen" >&2
+ done
+ echo "-------" >&2
+}
+
+
+FATAL_TRACK() {
+ echo -e "\n### $(date) ${FUNCNAME[1]}: FATAL error: $*" >&2
+ track end fatal $1 "'${@:2}'" none
+ print_stack
+ exit 1
+}
+
+FATAL() {
+ echo -e "\n### $(date) ${FUNCNAME[1]}: FATAL error: $*" >&2
+ print_stack
+ exit 1
+}
+
+WARNING() {
+ echo -e "\n### $(date) ${FUNCNAME[1]}: WARNING error: $*" >&2
+}
+
+INFO() {
+ echo "## $(date) ${FUNCNAME[1]}: INFO: $*" >&2
+}
+
+DEBUG() {
+ echo "# $(date) ${FUNCNAME[1]}: DEBUG: $*" >&2
+}
+
+CMD() {
+ echo "# executing '$*' ..."
+ "$@"
+ rc=$?
+ echo "# .... '$*' done RC was $rc"
+ return $rc
+}
diff --git a/library/track b/library/track
new file mode 100644
index 0000000..6b47826
--- /dev/null
+++ b/library/track
@@ -0,0 +1,96 @@
+#!/bin/bash
+# This file is meant to be SOURCED
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+function track(){
+# Tracks events by sending HTTP GET requests with query strings to a web server
+# Input:
+# - First argument (mandatory): event name
+# - Rest of arguments:
+# - If they exist, they correspond to tuples of operation-value-comment-tags
+# - operation: particular operation in an event
+# - value: particular value for an operation
+# - comment
+# - none will be passed when empty
+# - will be parsed to replace spaces by underscores
+# - tags
+# - none will be passed when empty
+# - will be parsed to replace spaces by ~
+# - If no arguments:
+# - operation: like event
+# - value: ""
+# - comment: ""
+# - tags: ""
+# Output:
+# Sends as many HTTP requests as operations with the following query string
+# "&{OSM_TRACK_INSTALLATION_ID}&{TIMESTAMP}&{EVENT}&{OPERATION}&{VALUE}&{COMMENT}&{TAGS}"
+#
+
+ if [ $# -lt 1 ]; then
+ echo "Unexpected error in track function. At least 1 arg is expected: event"
+ return 1
+ fi
+
+ osm_track_event_name=$1
+
+ ctime=`date +%s`
+
+ query_string=""
+ query_string="${query_string}&installation_id=${OSM_TRACK_INSTALLATION_ID}"
+ query_string="${query_string}&local_ts=${ctime}"
+ query_string="${query_string}&event=${osm_track_event_name}"
+
+ shift 1
+ if [ $# -eq 0 ]; then
+ operation="${osm_track_event_name}"
+ value=""
+ comment=""
+ tags=""
+ final_query_string="${query_string}"
+ final_query_string="${final_query_string}&operation=${operation}"
+ final_query_string="${final_query_string}&value=${value}"
+ final_query_string="${final_query_string}&comment=${comment}"
+ final_query_string="${final_query_string}&tags=${tags}"
+ url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
+ echo "Track $osm_track_event_name $operation: ${url}"
+ LANG=C wget -q -O /dev/null "$url"
+ else
+ while (( "$#" > 0 )); do
+ operation="${1:-${osm_track_event_name}}"
+ shift 1
+ value="${1:-}"
+ value="${value// /_}"
+ shift 1
+ comment="${1:-}"
+ comment="${comment// /_}"
+ shift 1
+ tags="${1:-}"
+ tags="${tags//,/\~}"
+ shift 1
+ [ "$value" == "none" ] && value=""
+ [ "$comment" == "none" ] && comment=""
+ [ "$tags" == "none" ] && tags=""
+ final_query_string="${query_string}"
+ final_query_string="${final_query_string}&operation=${operation}"
+ final_query_string="${final_query_string}&value=${value}"
+ final_query_string="${final_query_string}&comment=${comment}"
+ final_query_string="${final_query_string}&tags=${tags}"
+ url="https://osm.etsi.org/InstallLog.php?${final_query_string}"
+ echo "Track $osm_track_event_name $operation: ${url}"
+ LANG=C wget -q -O /dev/null "$url"
+ done
+ fi
+ return 0
+}
diff --git a/library/trap.sh b/library/trap.sh
new file mode 100755
index 0000000..2a1156d
--- /dev/null
+++ b/library/trap.sh
@@ -0,0 +1,48 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+
+function goodbye() {
+ local DURATION=$(date --date=@$(( "$(date +%s)" - "$TRAP_START_TIME" )) --utc +%T)
+ local CODE=$1
+ cd "$TRAP_DIR"
+ if [ "$CODE" == 0 ]; then
+ m "$(realpath --relative-to="$HERE" "$0") succeeded! $DURATION" "$GREEN"
+ elif [ "$CODE" == abort ]; then
+ m "Aborted $(realpath --relative-to="$HERE" "$0")! $DURATION" "$RED"
+ else
+ m "Oh no! $(realpath --relative-to="$HERE" "$0") failed! $DURATION" "$RED"
+ fi
+}
+
+function trap_EXIT() {
+ local ERR=$?
+ goodbye "$ERR"
+ exit "$ERR"
+}
+
+function trap_INT() {
+ goodbye abort
+ trap - EXIT
+ exit 1
+}
+
+TRAP_DIR=$PWD
+TRAP_START_TIME=$(date +%s)
+
+trap trap_INT INT
+
+trap trap_EXIT EXIT
diff --git a/library/utils.sh b/library/utils.sh
new file mode 100755
index 0000000..4fda090
--- /dev/null
+++ b/library/utils.sh
@@ -0,0 +1,121 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+
+
+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 parse_docker_registry_url() {
+ DOCKER_REGISTRY_USER=$(echo "$1" | awk '{split($1,a,"@"); split(a[1],b,":"); print b[1]}')
+ DOCKER_REGISTRY_PASSWORD=$(echo "$1" | awk '{split($1,a,"@"); split(a[1],b,":"); print b[2]}')
+ DOCKER_REGISTRY_URL=$(echo "$1" | awk '{split($1,a,"@"); print a[2]}')
+}
+
+function configure_apt_proxy() {
+ OSM_APT_PROXY=$1
+ OSM_APT_PROXY_FILE="/etc/apt/apt.conf.d/osm-apt"
+ echo "Configuring apt proxy in file ${OSM_APT_PROXY_FILE}"
+ if [ ! -f ${OSM_APT_PROXY_FILE} ]; then
+ sudo bash -c "cat <<EOF > ${OSM_APT_PROXY}
+Acquire::http { Proxy \"${OSM_APT_PROXY}\"; }
+EOF"
+ else
+ sudo sed -i "s|Proxy.*|Proxy \"${OSM_APT_PROXY}\"; }|" ${OSM_APT_PROXY_FILE}
+ fi
+ sudo apt-get update || FATAL "Configured apt proxy, but couldn't run 'apt-get update'. Check ${OSM_APT_PROXY_FILE}"
+ track prereq apt_proxy_configured_ok
+ [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
+function ask_user(){
+ # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
+ # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
+ # Return: true(0) if user type 'yes'; false (1) if user type 'no'
+ [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+ read -e -p "$1" USER_CONFIRMATION
+ while true ; do
+ [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
+ [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
+ [ "${USER_CONFIRMATION,,}" == "yes" ] || [ "${USER_CONFIRMATION,,}" == "y" ] && return 0
+ [ "${USER_CONFIRMATION,,}" == "no" ] || [ "${USER_CONFIRMATION,,}" == "n" ] && return 1
+ read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
+ done
+ [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
+function docker_login() {
+ echo "Docker login"
+ DEBUG "Docker registry user: ${DOCKER_REGISTRY_USER}"
+ sg docker -c "docker login -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PASSWORD} --password-stdin"
+}
+
+function ask_proceed() {
+ [ -z "$ASSUME_YES" ] && ! ask_user "The installation will do the following
+ 1. Install client tools (helm, kubectl, osmclient, wget, git, curl, tar, yq, flux, argo, kustomize)
+ 2. Deploy auxiliary services (Git, S3)
+ 3. Deploy mgmt cluster
+ 4. Deploy OSM
+ 5. Provision OSM
+ Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
+}
+
+function check_osm_behind_proxy() {
+ export OSM_BEHIND_PROXY=""
+ export OSM_PROXY_ENV_VARIABLES=""
+ [ -n "${http_proxy}" ] && OSM_BEHIND_PROXY="y" && echo "http_proxy=${http_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} http_proxy"
+ [ -n "${https_proxy}" ] && OSM_BEHIND_PROXY="y" && echo "https_proxy=${https_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} https_proxy"
+ [ -n "${HTTP_PROXY}" ] && OSM_BEHIND_PROXY="y" && echo "HTTP_PROXY=${HTTP_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} HTTP_PROXY"
+ [ -n "${HTTPS_PROXY}" ] && OSM_BEHIND_PROXY="y" && echo "HTTPS_PROXY=${HTTPS_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} HTTPS_PROXY"
+ [ -n "${no_proxy}" ] && echo "no_proxy=${no_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} no_proxy"
+ [ -n "${NO_PROXY}" ] && echo "NO_PROXY=${NO_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} NO_PROXY"
+
+ echo "OSM_BEHIND_PROXY=${OSM_BEHIND_PROXY}"
+ echo "OSM_PROXY_ENV_VARIABLES=${OSM_PROXY_ENV_VARIABLES}"
+
+ if [ -n "${OSM_BEHIND_PROXY}" ]; then
+ [ -z "$ASSUME_YES" ] && ! ask_user "
+The following env variables have been found for the current user:
+${OSM_PROXY_ENV_VARIABLES}.
+
+This suggests that this machine is behind a proxy and a special configuration is required.
+The installer will install Docker CE and a Kubernetes to work behind a proxy using those
+env variables.
+
+Take into account that the installer uses apt, curl, wget and docker.
+Depending on the program, the env variables to work behind a proxy might be different
+(e.g. http_proxy vs HTTP_PROXY).
+
+For that reason, it is strongly recommended that at least http_proxy, https_proxy, HTTP_PROXY
+and HTTPS_PROXY are defined.
+
+Finally, some of the programs (apt) are run as sudoer, requiring that those env variables
+are also set for root user. If you are not sure whether those variables are configured for
+the root user, you can stop the installation now.
+
+Do you want to proceed with the installation (Y/n)? " y && echo "Cancelled!" && exit 1
+ else
+ echo "This machine is not behind a proxy"
+ fi
+}
+