From 4ea137b286118347c472bf95359829f30edbb042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 25 Jan 2023 09:54:43 +0100 Subject: [PATCH 1/4] Update _common.sh --- scripts/_common.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index db504e8..0d39729 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -20,7 +20,7 @@ pkg_dependencies="apt-transport-https build-essential gzip curl fontconfig graph #================================================= 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} @@ -66,7 +66,7 @@ ynh_mongo_exec() { if [ -n "$user" ] then user="--username=$user" - + # If password is provided if [ -n "$password" ] then @@ -121,7 +121,7 @@ EOF else database="" fi - + mongosh --quiet $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command" fi } @@ -190,7 +190,7 @@ ynh_mongo_create_user() { # Create the user and set the user as admin of the db ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );' - + # Add clustermonitoring rights ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);' } @@ -282,12 +282,12 @@ ynh_mongo_setup_db() { local new_db_pwd=$(ynh_string_random) # Generate a random password # If $db_pwd is not provided, use new_db_pwd instead for db_pwd db_pwd="${db_pwd:-$new_db_pwd}" - + # Create the user and grant access to the database ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name" # Store the password in the app's config - ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd + ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd } # Remove a database if it exists, and the associated user @@ -331,14 +331,26 @@ 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 buster/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 ..." + # Install the version that works with the host cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64) + local mongo_debian_release=$(ynh_get_debian_release) + + if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then + ynh_print_error --message="The version of Mongo you're trying to install may not be compatible with your cpu (Missing avx instruction set)." + fi + if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" == "4.4" ]]; then + ynh_print_warn --message="Installing Mongo for Buster due to incompatible cpu." + 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" + + ynh_systemd_action --service_name=$mongodb_servicename --action=restart --line_match="aiting for connections" --log_path="systemd" --length=100 --timeout=60 # Integrate MongoDB service in YunoHost yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log" From 7f660b2486a01e65639ff50e35456859a5f30f4c Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 25 Jan 2023 08:54:53 +0000 Subject: [PATCH 2/4] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1499bde..7befe0d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Rocket.Chat for YunoHost -[![Integration level](https://dash.yunohost.org/integration/rocketchat.svg)](https://dash.yunohost.org/appci/app/rocketchat) ![Working status](https://ci-apps.yunohost.org/ci/badges/rocketchat.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/rocketchat.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/rocketchat.svg)](https://dash.yunohost.org/appci/app/rocketchat) ![Working status](https://ci-apps.yunohost.org/ci/badges/rocketchat.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/rocketchat.maintain.svg) [![Install Rocket.Chat with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=rocketchat) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index 0facff4..16601d1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Rocket.Chat pour YunoHost -[![Niveau d’intégration](https://dash.yunohost.org/integration/rocketchat.svg)](https://dash.yunohost.org/appci/app/rocketchat) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/rocketchat.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/rocketchat.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/rocketchat.svg)](https://dash.yunohost.org/appci/app/rocketchat) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/rocketchat.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/rocketchat.maintain.svg) [![Installer Rocket.Chat avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=rocketchat) *[Read this readme in english.](./README.md)* From d5e22bea582b5811ea6f8da52c367b09ee5cdcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:02:03 +0100 Subject: [PATCH 3/4] Update _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 0d39729..f9873b4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -336,7 +336,7 @@ ynh_install_mongo() { local mongo_debian_release=$(ynh_get_debian_release) if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then - ynh_print_error --message="The version of Mongo you're trying to install may not be compatible with your cpu (Missing avx instruction set)." + ynh_print_err --message="The version of Mongo you're trying to install may not be compatible with your cpu (Missing avx instruction set)." fi if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" == "4.4" ]]; then ynh_print_warn --message="Installing Mongo for Buster due to incompatible cpu." From aa4c30ffac5b5a65a04ea9207898a9e37fddd91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 26 Jan 2023 17:34:40 +0100 Subject: [PATCH 4/4] Update _common.sh --- scripts/_common.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f9873b4..e8498e3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -332,16 +332,16 @@ ynh_install_mongo() { mongo_version="${mongo_version:-$YNH_MONGO_VERSION}" ynh_print_info --message="Installing MongoDB Community Edition ..." - # Install the version that works with the host cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64) local mongo_debian_release=$(ynh_get_debian_release) if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" != "4.4" ]]; then - ynh_print_err --message="The version of Mongo you're trying to install may not be compatible with your cpu (Missing avx instruction set)." - fi - if [[ $(cat /proc/cpuinfo) != *"avx"* && "$mongo_version" == "4.4" ]]; then - ynh_print_warn --message="Installing Mongo for Buster due to incompatible cpu." + 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 + 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 @@ -350,7 +350,7 @@ ynh_install_mongo() { 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="systemd" --length=100 --timeout=60 + 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 yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log"