From 955b38c196d09d73493ab38dc3c275ac185871c6 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Thu, 2 Apr 2020 18:14:11 +0500 Subject: [PATCH] Add MongoDB 4.2 to linux images (#591) * Add MongoDB 4.2 to linux images * use the same installation script for all versions * Add helpers to get Ubuntu version * Improve helper functions * Rename install.sh to os.sh Co-authored-by: Sergey Dolin --- images/linux/scripts/helpers/os.sh | 20 ++++++++++++++++ images/linux/scripts/installers/mongodb.sh | 27 ++++++++++++++++++++++ images/linux/ubuntu1604.json | 3 ++- images/linux/ubuntu1804.json | 3 ++- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 images/linux/scripts/helpers/os.sh create mode 100644 images/linux/scripts/installers/mongodb.sh diff --git a/images/linux/scripts/helpers/os.sh b/images/linux/scripts/helpers/os.sh new file mode 100644 index 000000000..fa2d4cf44 --- /dev/null +++ b/images/linux/scripts/helpers/os.sh @@ -0,0 +1,20 @@ +#!/bin/bash +################################################################################ +## File: install-helpers.sh +## Desc: Helper functions for installing tools +################################################################################ + +function isUbuntu16 +{ + lsb_release -d|grep 'Ubuntu 16' > /dev/null +} + +function isUbuntu18 +{ + lsb_release -d|grep 'Ubuntu 18' > /dev/null +} + +function getOSVersionLabel +{ + isUbuntu16 && echo xenial || echo bionic +} \ No newline at end of file diff --git a/images/linux/scripts/installers/mongodb.sh b/images/linux/scripts/installers/mongodb.sh new file mode 100644 index 000000000..545253e5a --- /dev/null +++ b/images/linux/scripts/installers/mongodb.sh @@ -0,0 +1,27 @@ +#!/bin/bash +################################################################################ +## File: homebrew.sh +## Desc: Installs Mongo DB +################################################################################ + +# Source the helpers +source $HELPER_SCRIPTS/os.sh +source $HELPER_SCRIPTS/document.sh + +# Install Mongo DB +wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add - +version=$(getOSVersionLabel) +echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $version/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list +sudo apt-get update +sudo apt-get install -y mongodb-org + +# Validate the installation +echo "Validate the installation" +if ! command -v mongod; then + echo "mongodb was not installed" + exit 1 +fi + +# Document the installed version +echo "Document the installed version" +DocumentInstalledItem "MongoDB on Linux ($(mongod -v|grep -i version 2>&1))" diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 78a0d8041..e5a28b64a 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -187,7 +187,8 @@ "{{template_dir}}/scripts/installers/vcpkg.sh", "{{template_dir}}/scripts/installers/zeit-now.sh", "{{template_dir}}/scripts/installers/updatepath.sh", - "{{template_dir}}/scripts/installers/dpkg-config.sh" + "{{template_dir}}/scripts/installers/dpkg-config.sh", + "{{template_dir}}/scripts/installers/mongodb.sh" ], "environment_vars": [ diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 70ab724ab..222bc8cdd 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -190,7 +190,8 @@ "{{template_dir}}/scripts/installers/vcpkg.sh", "{{template_dir}}/scripts/installers/zeit-now.sh", "{{template_dir}}/scripts/installers/updatepath.sh", - "{{template_dir}}/scripts/installers/dpkg-config.sh" + "{{template_dir}}/scripts/installers/dpkg-config.sh", + "{{template_dir}}/scripts/installers/mongodb.sh" ], "environment_vars": [ "METADATA_FILE={{user `metadata_file`}}",