From 3ff8701f38b9ff9351e858c5ca62dd1128c6add1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Collin?= Date: Thu, 26 Jan 2023 17:01:03 +0100 Subject: [PATCH] Upgraded mongo install script --- manifest.json | 2 +- scripts/ynh_mongo_db__2 | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 2b0db6d..9fe62d3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "An admin server for Mongo and optionally a Mongo database", "fr": "Un serveur d'administration pour Mongo ainsi qu'optionnellement une base Mongo" }, - "version": "1.0~ynh3", + "version": "1.0~ynh4", "url": "https://github.com/mongo-express/mongo-express", "upstream": { "license": "MIT", diff --git a/scripts/ynh_mongo_db__2 b/scripts/ynh_mongo_db__2 index 7fac585..e1c17a6 100644 --- a/scripts/ynh_mongo_db__2 +++ b/scripts/ynh_mongo_db__2 @@ -1,7 +1,7 @@ #!/bin/bash readonly YNH_DEFAULT_MONGO_VERSION=4.4 -# Declare the actual MongoDB version to use: 4.4 ; 5.0 +# Declare the actual MongoDB version to use: 4.4 ; 5.0 ; 6.0 # A packager willing to use another version of MongoDB can override the variable into its _common.sh. YNH_MONGO_VERSION=${YNH_MONGO_VERSION:-$YNH_DEFAULT_MONGO_VERSION} @@ -312,13 +312,25 @@ ynh_install_mongo() { ynh_handle_getopts_args "$@" mongo_version="${mongo_version:-$YNH_MONGO_VERSION}" - ynh_print_info --message="Installing MongoDB Community Edition..." - ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $(ynh_get_debian_release)/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc" + ynh_print_info --message="Installing MongoDB Community Edition ..." + local mongo_debian_release=$(ynh_get_debian_release) + + if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then + ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)." + mongo_version="4.4" + fi + if [[ "$mongo_version" == "4.4" && "$mongo_debian_release" != "buster" ]]; then + ynh_print_warn --message="Switched to buster install as Mongo 4.4 is not compatible with $mongo_debian_release." + mongo_debian_release=buster + fi + + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc" mongodb_servicename=mongod # Make sure MongoDB is started and enabled systemctl enable $mongodb_servicename --quiet systemctl daemon-reload --quiet + ynh_systemd_action --service_name=$mongodb_servicename --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$mongodb_servicename.log" # Integrate MongoDB service in YunoHost