X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Finstall_lxd.sh;h=7395c731d8b62e1a1b5c4d4ddda4ae4aef9f98dd;hb=2e1c9f81d3cfc11f238156ad176471991eab3d90;hp=a499eae3ad4ca438849b2f4b7dbdc86de6c82c84;hpb=8fed108b98ba8089f9ea6a2655399f26bcaf040e;p=osm%2Fdevops.git diff --git a/installers/install_lxd.sh b/installers/install_lxd.sh index a499eae3..7395c731 100755 --- a/installers/install_lxd.sh +++ b/installers/install_lxd.sh @@ -49,32 +49,47 @@ function install_lxd() { sudo snap install lxd --channel $LXD_VERSION/stable fi + # Get default iface, IP and MTU + if [ -n "${OSM_DEFAULT_IF}" ]; then + 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" + fi + DEFAULT_MTU=$(ip addr show ${OSM_DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}') + 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" + # Configure LXD sudo usermod -a -G lxd `whoami` - cat ${OSM_DEVOPS}/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$DEFAULT_IP':8443/' | sg lxd -c "lxd init --preseed" + cat ${OSM_DEVOPS}/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$OSM_DEFAULT_IP':8443/' | sg lxd -c "lxd init --preseed" sg lxd -c "lxd waitready" - DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}') - [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}') - [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" - DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}') sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU" sg lxd -c "lxc network set lxdbr0 bridge.mtu $DEFAULT_MTU" # sudo systemctl stop lxd-bridge # 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}" + OSM_DEFAULT_IF="${OPTARG}" ;; d) OSM_DOCKER_WORK_DIR="${OPTARG}" @@ -82,6 +97,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 @@ -109,9 +127,10 @@ source $OSM_DEVOPS/common/logging source $OSM_DEVOPS/common/track echo "DEBUG_INSTALL=$DEBUG_INSTALL" -echo "DEFAULT_IP=$DEFAULT_IP" +echo "OSM_BEHIND_PROXY=$OSM_BEHIND_PROXY" +echo "OSM_DEFAULT_IF=$OSM_DEFAULT_IF" echo "OSM_DEVOPS=$OSM_DEVOPS" [ -z "$INSTALL_NOJUJU" ] && install_lxd -track juju juju_install_ok +track prereq lxd_install_ok