From 642671d6410af8718ef092afd66c434516bbb782 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 18 Mar 2020 02:45:41 +0100 Subject: [PATCH 01/10] Switch to MongoDB Community Edition Fix #78 --- scripts/_common.sh | 2 +- scripts/install | 3 +- scripts/restore | 4 +- scripts/upgrade | 3 +- scripts/ynh_add_extra_apt_repos__3 | 294 +++++++++++++++++++++++++++++ 5 files changed, 301 insertions(+), 5 deletions(-) create mode 100644 scripts/ynh_add_extra_apt_repos__3 diff --git a/scripts/_common.sh b/scripts/_common.sh index 681c2d6..1725bd1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="mongodb mongodb-server mongo-tools" +pkg_dependencies="mongodb-org mongodb-org-server mongo-org-tools" nodejsversion=12.15.0 #================================================= diff --git a/scripts/install b/scripts/install index ecc2135..c702b08 100755 --- a/scripts/install +++ b/scripts/install @@ -8,6 +8,7 @@ source _common.sh source ynh_detect_arch__2 +source ynh_add_extra_apt_repos__3 source /usr/share/yunohost/helpers #================================================= @@ -78,7 +79,7 @@ ynh_print_info --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_app_dependencies $pkg_dependencies +ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package=$pkg_dependencies --key="https://www.mongodb.org/static/pgp/server-4.2.asc" #================================================= # CREATE A MONGODB DATABASE diff --git a/scripts/restore b/scripts/restore index cbf1c11..fff5c11 100644 --- a/scripts/restore +++ b/scripts/restore @@ -7,7 +7,7 @@ #================================================= source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_systemd_action +source ../settings/scripts/ynh_add_extra_apt_repos__3 source /usr/share/yunohost/helpers #================================================= @@ -87,7 +87,7 @@ ynh_print_info --message="Reinstalling dependencies..." ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_app_dependencies $pkg_dependencies +ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package=$pkg_dependencies --key="https://www.mongodb.org/static/pgp/server-4.2.asc" #================================================= # RESTORE THE MONGODB DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index fb58336..ca00405 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_add_extra_apt_repos__3 source ynh_package_version source ynh_detect_arch__2 source /usr/share/yunohost/helpers @@ -163,7 +164,7 @@ ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_app_dependencies $pkg_dependencies +ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package=$pkg_dependencies --key="https://www.mongodb.org/static/pgp/server-4.2.asc" #================================================= # CREATE DEDICATED USER diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/ynh_add_extra_apt_repos__3 new file mode 100644 index 0000000..3276f00 --- /dev/null +++ b/scripts/ynh_add_extra_apt_repos__3 @@ -0,0 +1,294 @@ +#!/bin/bash + +# Pin a repository. +# +# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] +# | arg: -p, --package - Packages concerned by the pin. Or all, *. +# | arg: -i, --pin - Filter for the pin. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. +# +ynh_pin_repo () { + # Declare an array to define the options of this helper. + local legacy_args=pirna + declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) + local package + local pin + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package="${package:-*}" + priority=${priority:-50} + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/preferences.d" + echo "Package: $package +Pin: $pin +Pin-Priority: $priority" \ + | $append "/etc/apt/preferences.d/$name" +} + +# Add a repository. +# +# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] +# | arg: -u, --uri - Uri of the repository. +# | arg: -s, --suite - Suite of the repository. +# | arg: -c, --component - Component of the repository. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable +# uri suite component +# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable +# +ynh_add_repo () { + # Declare an array to define the options of this helper. + local legacy_args=uscna + declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) + local uri + local suite + local component + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/sources.list.d" + # Add the new repo in sources.list.d + echo "deb $uri $suite $component" \ + | $append "/etc/apt/sources.list.d/$name.list" +} + +# Add an extra repository correctly, pin it and get the key. +# +# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -k, --key - url to get the public key. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +ynh_install_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=rkpna + declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) + local repo + local key + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + key=${key:-0} + priority=${priority:-} + + if [ $append -eq 1 ] + then + append="--append" + wget_append="tee -a" + else + append="" + wget_append="tee" + fi + + # Split the repository into uri, suite and components. + # Remove "deb " at the beginning of the repo. + repo="${repo#deb }" + + # Get the uri + local uri="$(echo "$repo" | awk '{ print $1 }')" + + # Get the suite + local suite="$(echo "$repo" | awk '{ print $2 }')" + + # Get the components + local component="${repo##$uri $suite }" + + # Add the repository into sources.list.d + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append + + # Pin the new repo with the default priority, so it won't be used for upgrades. + # Build $pin from the uri without http and any sub path + local pin="${uri#*://}" + pin="${pin%%/*}" + # Set a priority only if asked + if [ -n "$priority" ] + then + priority="--priority=$priority" + fi + ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append + + # Get the public key for the repo + if [ -n "$key" ] + then + mkdir -p "/etc/apt/trusted.gpg.d" + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null + fi + + # Update the list of package with the new repo + ynh_package_update +} + +# Remove an extra repository and the assiociated configuration. +# +# usage: ynh_remove_extra_repo [--name=name] +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_remove_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=n + declare -Ar args_array=( [n]=name= ) + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + + ynh_secure_remove "/etc/apt/sources.list.d/$name.list" + ynh_secure_remove "/etc/apt/preferences.d/$name" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" + + # Update the list of package to exclude the old repo + ynh_package_update +} + +# Install packages from an extra repository properly. +# +# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -p, --package - The packages to install from this extra repository +# | arg: -k, --key - url to get the public key. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_install_extra_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=rpkn + declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) + local repo + local package + local key + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + key=${key:-0} + + # Set a key only if asked + if [ -n "$key" ] + then + key="--key=$key" + fi + # Add an extra repository for those packages + ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name + + # Install requested dependencies from this extra repository. + ynh_add_app_dependencies --package="$package" + + # Remove this extra repository after packages are installed + ynh_remove_extra_repo --name=$app +} + +#================================================= + +# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies + +# Define and install dependencies with a equivs control file +# This helper can/should only be called once per app +# +# usage: ynh_install_app_dependencies dep [dep [...]] +# | arg: dep - the package name to install in dependence +# You can give a choice between some package with this syntax : "dep1|dep2" +# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" +# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) +# +# Requires YunoHost version 2.6.4 or higher. +ynh_install_app_dependencies () { + local dependencies=$@ + dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" + dependencies=${dependencies//|/ | } + local manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + + local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. + if [ ${#version} -eq 0 ]; then + version="1.0" + fi + local dep_app=${app//_/-} # Replace all '_' by '-' + + # Handle specific versions + if [[ "$dependencies" =~ [\<=\>] ]] + then + # Replace version specifications by relationships syntax + # https://www.debian.org/doc/debian-policy/ch-relationships.html + # Sed clarification + # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. + # [\<=\>] matches < = or > + # \+ matches one or more occurence of the previous characters, for >= or >>. + # [^,]\+ matches all characters except ',' + # Ex: package>=1.0 will be replaced by package (>= 1.0) + dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" + fi + + cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build +Section: misc +Priority: optional +Package: ${dep_app}-ynh-deps +Version: ${version} +Depends: ${dependencies} +Architecture: all +Description: Fake package for $app (YunoHost app) dependencies + This meta-package is only responsible of installing its dependencies. +EOF + ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ + || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies + rm /tmp/${dep_app}-ynh-deps.control + ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" +} + +ynh_add_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=pr + declare -Ar args_array=( [p]=package= [r]=replace) + local package + local replace + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + replace=${replace:-0} + + local current_dependencies="" + if [ $replace -eq 0 ] + then + local dep_app=${app//_/-} # Replace all '_' by '-' + if ynh_package_is_installed --package="${dep_app}-ynh-deps" + then + current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " + fi + + current_dependencies=${current_dependencies// | /|} + fi + + ynh_install_app_dependencies "${current_dependencies}${package}" +} From 9745bb7cc9237b2ef91cbf150823a089374c0263 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 18 Mar 2020 11:03:27 +0100 Subject: [PATCH 02/10] Fix dependencies install error --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index c702b08..fb8e429 100755 --- a/scripts/install +++ b/scripts/install @@ -79,7 +79,7 @@ ynh_print_info --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package=$pkg_dependencies --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" #================================================= # CREATE A MONGODB DATABASE diff --git a/scripts/restore b/scripts/restore index fff5c11..af3780f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -87,7 +87,7 @@ ynh_print_info --message="Reinstalling dependencies..." ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package=$pkg_dependencies --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" #================================================= # RESTORE THE MONGODB DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index ca00405..593847c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -164,7 +164,7 @@ ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package=$pkg_dependencies --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" #================================================= # CREATE DEDICATED USER From 190b806379b603bb5f36f6de887bef6d52b5edd3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 19 Mar 2020 22:20:33 +0100 Subject: [PATCH 03/10] fix dependencies --- scripts/_common.sh | 3 ++- scripts/install | 6 +++++- scripts/restore | 6 +++++- scripts/upgrade | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 1725bd1..a7886cb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,8 @@ #================================================= # dependencies used by the app -pkg_dependencies="mongodb-org mongodb-org-server mongo-org-tools" +pkg_dependencies="mongodb mongodb-server mongo-tools" +pkg_dependencies_buster="mongodb-org mongodb-org-server mongo-org-tools" nodejsversion=12.15.0 #================================================= diff --git a/scripts/install b/scripts/install index fb8e429..d360a76 100755 --- a/scripts/install +++ b/scripts/install @@ -79,7 +79,11 @@ ynh_print_info --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +if [ "$(lsb_release --codename --short)" = "buster" ]; then + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +else + ynh_install_app_dependencies $pkg_dependencies +fi #================================================= # CREATE A MONGODB DATABASE diff --git a/scripts/restore b/scripts/restore index af3780f..44c8cdc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -87,7 +87,11 @@ ynh_print_info --message="Reinstalling dependencies..." ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +if [ "$(lsb_release --codename --short)" = "buster" ]; then + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +else + ynh_install_app_dependencies $pkg_dependencies +fi #================================================= # RESTORE THE MONGODB DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 593847c..65f1578 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -164,7 +164,11 @@ ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs -ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +if [ "$(lsb_release --codename --short)" = "buster" ]; then + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" +else + ynh_install_app_dependencies $pkg_dependencies +fi #================================================= # CREATE DEDICATED USER From 9b2f53526256e193edf4a618652c4245473acef4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 19 Mar 2020 22:22:10 +0100 Subject: [PATCH 04/10] Fix buster dependencies --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index d360a76..1ec5a31 100755 --- a/scripts/install +++ b/scripts/install @@ -80,7 +80,7 @@ ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then - ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" else ynh_install_app_dependencies $pkg_dependencies fi diff --git a/scripts/restore b/scripts/restore index 44c8cdc..e795562 100644 --- a/scripts/restore +++ b/scripts/restore @@ -88,7 +88,7 @@ ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then - ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" else ynh_install_app_dependencies $pkg_dependencies fi diff --git a/scripts/upgrade b/scripts/upgrade index 65f1578..94f2507 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -165,7 +165,7 @@ ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then - ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" else ynh_install_app_dependencies $pkg_dependencies fi From 6dd939b9e2cc1a3818baaca44cd692aa001d0d0d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 20 Mar 2020 12:50:51 +0100 Subject: [PATCH 05/10] fixing buster dependencies --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a7886cb..b7d73d6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="mongodb mongodb-server mongo-tools" +pkg_dependencies="mongodb mongodb-server mongodb-org-tools" pkg_dependencies_buster="mongodb-org mongodb-org-server mongo-org-tools" nodejsversion=12.15.0 From 0814fca58c8d8b1a8ccc79ec8b4fcb5a46a48802 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 20 Mar 2020 13:22:41 +0100 Subject: [PATCH 06/10] typo :/ --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b7d73d6..2bdc4db 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,8 +5,8 @@ #================================================= # dependencies used by the app -pkg_dependencies="mongodb mongodb-server mongodb-org-tools" -pkg_dependencies_buster="mongodb-org mongodb-org-server mongo-org-tools" +pkg_dependencies="mongodb mongodb-server mongo-tools" +pkg_dependencies_buster="mongodb-org mongodb-org-server mongodb-org-tools" nodejsversion=12.15.0 #================================================= From 2875a939258138980c20f70372ee7830492014a8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 21 Mar 2020 13:40:23 +0100 Subject: [PATCH 07/10] removing service dependencies as service name is different for stretch and buster --- conf/systemd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index 9fbf394..e5ed9ca 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,7 +1,7 @@ [Unit] Description=Wekan, task board Wants=mongodb.service -After=network.target mongodb.service +After=network.target [Service] Type=simple From 7f5ecfb75bc93410ef88b6d7417f4b20fd3df733 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 21 Mar 2020 22:29:43 +0100 Subject: [PATCH 08/10] Fixing mongodb service name --- conf/systemd.service | 4 ++-- scripts/_common.sh | 2 ++ scripts/install | 7 +++++-- scripts/restore | 6 ++++-- scripts/upgrade | 3 +++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index e5ed9ca..f626c23 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,7 +1,7 @@ [Unit] Description=Wekan, task board -Wants=mongodb.service -After=network.target +Wants=__MOGODB_SERVICENAME__.service +After=network.target __MOGODB_SERVICENAME__.service [Service] Type=simple diff --git a/scripts/_common.sh b/scripts/_common.sh index 2bdc4db..fe27352 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,6 +7,8 @@ # dependencies used by the app pkg_dependencies="mongodb mongodb-server mongo-tools" pkg_dependencies_buster="mongodb-org mongodb-org-server mongodb-org-tools" +mongodb_stretch="mongodb" +mongodb_buster="mongod" nodejsversion=12.15.0 #================================================= diff --git a/scripts/install b/scripts/install index 1ec5a31..e51b971 100755 --- a/scripts/install +++ b/scripts/install @@ -81,8 +81,10 @@ ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + mongodb_servicename=$mongodb_buster else ynh_install_app_dependencies $pkg_dependencies + mongodb_servicename=$mongodb_stretch fi #================================================= @@ -91,8 +93,8 @@ fi ynh_print_info --message="Creating a MongoDB database..." # Start mongodb -systemctl enable mongodb -systemctl start mongodb +systemctl enable $mongodb_servicename +systemctl start $mongodb_servicename # Registering db name db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -132,6 +134,7 @@ ynh_print_info --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__MOGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" ynh_add_systemd_config #================================================= diff --git a/scripts/restore b/scripts/restore index e795562..445e21f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,8 +89,10 @@ ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + mongodb_servicename=$mongodb_buster else ynh_install_app_dependencies $pkg_dependencies + mongodb_servicename=$mongodb_stretch fi #================================================= @@ -99,8 +101,8 @@ fi ynh_print_info --message="Restoring the MongoDB database..." # Start mongodb -systemctl enable mongodb -systemctl start mongodb +systemctl enable $mongodb_servicename +systemctl start $mongodb_servicename mongorestore --db $db_name ./dump/$db_name #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 94f2507..42045cd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -166,8 +166,10 @@ ynh_use_nodejs if [ "$(lsb_release --codename --short)" = "buster" ]; then ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" --package="$pkg_dependencies_buster" --key="https://www.mongodb.org/static/pgp/server-4.2.asc" + mongodb_servicename=$mongodb_buster else ynh_install_app_dependencies $pkg_dependencies + mongodb_servicename=$mongodb_stretch fi #================================================= @@ -201,6 +203,7 @@ ynh_print_info --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__MOGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" ynh_add_systemd_config #================================================= From 2fb75b3a63d5468c0c257f3c8b2ded38440bc03c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 22 Mar 2020 23:17:42 +0100 Subject: [PATCH 09/10] removing upgrade_check from previous version as installation is not working for buster --- check_process | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/check_process b/check_process index 634a3da..8a7cdfd 100644 --- a/check_process +++ b/check_process @@ -12,17 +12,17 @@ setup_public=1 upgrade=1 # 1.07~ynh2 - upgrade=1 from_commit=37d226544f2738bd37f97b612ff4798545b3dc5a + # upgrade=1 from_commit=37d226544f2738bd37f97b612ff4798545b3dc5a # 2.09~ynh1 - upgrade=1 from_commit=3105eb5a3c515ea55a38b8b80c9b5dda1277a82e + # upgrade=1 from_commit=3105eb5a3c515ea55a38b8b80c9b5dda1277a82e # 2.56~ynh2 - upgrade=1 from_commit=b26768aad2627da739677da740429591ffbb9a6e + # upgrade=1 from_commit=b26768aad2627da739677da740429591ffbb9a6e # 2.98~ynh2 - upgrade=1 from_commit=dab614bd7679f2f7978d1df2e360fba7ae0edfa4 + # upgrade=1 from_commit=dab614bd7679f2f7978d1df2e360fba7ae0edfa4 # 3.45~ynh1 - upgrade=1 from_commit=2e6131af03c723cf9eaf82e13aa9488f42c085f9 + # upgrade=1 from_commit=2e6131af03c723cf9eaf82e13aa9488f42c085f9 # 3.55~ynh1 - upgrade=1 from_commit=3be3f1d7290b534f7689222645a42c06f3103589 + # upgrade=1 from_commit=3be3f1d7290b534f7689222645a42c06f3103589 backup_restore=1 multi_instance=1 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. From 6b931e883ec0b815e40bd3f0911c8396d697999e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 23 Mar 2020 13:52:04 +0100 Subject: [PATCH 10/10] typo --- conf/systemd.service | 4 ++-- scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index f626c23..7b13646 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,7 +1,7 @@ [Unit] Description=Wekan, task board -Wants=__MOGODB_SERVICENAME__.service -After=network.target __MOGODB_SERVICENAME__.service +Wants=__MONGODB_SERVICENAME__.service +After=network.target __MONGODB_SERVICENAME__.service [Service] Type=simple diff --git a/scripts/install b/scripts/install index e51b971..347ac42 100755 --- a/scripts/install +++ b/scripts/install @@ -134,7 +134,7 @@ ynh_print_info --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__MOGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__MONGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" ynh_add_systemd_config #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 42045cd..1119fca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -203,7 +203,7 @@ ynh_print_info --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__MOGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__MONGODB_SERVICENAME__" --replace_string="$mongodb_servicename" --target_file="../conf/systemd.service" ynh_add_systemd_config #=================================================