[ -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
# 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
# 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