X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Ffull_install_osm.sh;h=75949846a3e29652e80b96c4ead152731b5bdb6a;hb=89a4f0a8a7e73cb984d0bcd6a592d0df3edb0ab9;hp=3447de1f235eabe6cbd483ced19b73104840323c;hpb=f4f0e0f7fc07e6cc687be49f89295263cde2be63;p=osm%2Fdevops.git diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 3447de1f..75949846 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -139,6 +139,20 @@ function generate_secret() { [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } +function check_packages() { + NEEDED_PACKAGES="$1" + echo -e "Checking required packages: ${NEEDED_PACKAGES}" + for PACKAGE in ${NEEDED_PACKAGES} ; do + dpkg -L ${PACKAGE} &>/dev/null + if [ $? -ne 0 ]; then + echo -e "Package ${PACKAGE} is not installed. Updating apt" + sudo apt-get update + sudo apt-get install -y ${PACKAGE} || FATAL "failed to install ${PACKAGE}" + fi + done + echo -e "Required packages are present: ${NEEDED_PACKAGES}" +} + function install_lxd() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function # Apply sysctl production values for optimal performance @@ -633,7 +647,7 @@ function install_osm() { 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_IP=`ip -o -4 a s ${DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]}'` + DEFAULT_IP=`ip -o -4 a s ${DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}'` [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" # configure apt proxy @@ -641,16 +655,7 @@ function install_osm() { # if no host is passed in, we need to install lxd/juju, unless explicilty asked not to if [ -z "$OSM_VCA_HOST" ] && [ -z "$INSTALL_NOLXD" ] && [ -z "$LXD_CLOUD_FILE" ]; then - need_packages_lw="snapd" - echo -e "Checking required packages: $need_packages_lw" - dpkg -l $need_packages_lw &>/dev/null \ - || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \ - || sudo apt-get update \ - || FATAL "failed to run apt-get update" - dpkg -l $need_packages_lw &>/dev/null \ - || ! echo -e "Installing $need_packages_lw requires root privileges." \ - || sudo apt-get install -y $need_packages_lw \ - || FATAL "failed to install $need_packages_lw" + check_packages "snapd" install_lxd fi @@ -1138,17 +1143,8 @@ fi # if develop, we force master [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master" -need_packages="git wget curl tar" - -echo -e "Checking required packages: $need_packages" -dpkg -l $need_packages &>/dev/null \ - || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \ - || sudo apt-get update \ - || FATAL "failed to run apt-get update" -dpkg -l $need_packages &>/dev/null \ - || ! echo -e "Installing $need_packages requires root privileges." \ - || sudo apt-get install -y $need_packages \ - || FATAL "failed to install $need_packages" +check_packages "git wget curl tar" + sudo snap install jq if [ -z "$OSM_DEVOPS" ]; then if [ -n "$TEST_INSTALLER" ]; then