Feature 10593 Air-gapped installation. OSM behind proxy
[osm/devops.git] / installers / install_lxd.sh
index a499eae..ed50135 100755 (executable)
@@ -63,15 +63,24 @@ function install_lxd() {
     # sudo systemctl --system daemon-reload
     # sudo systemctl enable lxd-bridge
     # sudo systemctl start lxd-bridge
+
+    # Configure LXD to work behind a proxy
+    if [ -n "${OSM_BEHIND_PROXY}" ] ; then
+        [ -n "${HTTP_PROXY}" ] && sg lxd -c "lxc config set core.proxy_http $HTTP_PROXY"
+        [ -n "${HTTPS_PROXY}" ] && sg lxd -c "lxc config set core.proxy_https $HTTPS_PROXY"
+        [ -n "${NO_PROXY}" ] && sg lxd -c "lxc config set core.proxy_ignore_hosts $NO_PROXY"
+    fi
+
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
 DEBUG_INSTALL=""
 LXD_VERSION=5.0
 OSM_DEVOPS=
+OSM_BEHIND_PROXY=""
 
 # main
-while getopts ":D:d:i:-: h" o; do
+while getopts ":D:d:i:-: hP" o; do
     case "${o}" in
         i)
             DEFAULT_IP="${OPTARG}"
@@ -82,6 +91,9 @@ while getopts ":D:d:i:-: h" o; do
         D)
             OSM_DEVOPS="${OPTARG}"
             ;;
+        P)
+            OSM_BEHIND_PROXY="y"
+            ;;
         -)
             [ "${OPTARG}" == "help" ] && usage && exit 0
             [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
@@ -110,6 +122,7 @@ source $OSM_DEVOPS/common/track
 
 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
 echo "DEFAULT_IP=$DEFAULT_IP"
+echo "OSM_BEHIND_PROXY=$OSM_BEHIND_PROXY"
 echo "OSM_DEVOPS=$OSM_DEVOPS"
 
 [ -z "$INSTALL_NOJUJU" ] && install_lxd