From 76daa53c46a930c505e51de49642b235a497eabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Collin?= Date: Tue, 31 Jan 2023 16:47:54 +0100 Subject: [PATCH 1/2] New version of Java helpers and fix for sudoers backup --- manifest.json | 2 +- scripts/backup | 6 +++++- scripts/install | 4 ++-- scripts/remove | 12 +++++++++--- scripts/restore | 2 +- scripts/upgrade | 2 +- scripts/{ynh_java => ynh_install_java} | 15 +++++++++++++++ 7 files changed, 34 insertions(+), 9 deletions(-) rename scripts/{ynh_java => ynh_install_java} (88%) diff --git a/manifest.json b/manifest.json index 216f2ed..cf812d0 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Install services and databases needed to support Dont-code platform", "fr": "Installe les services et base de données nécessaires pour utiliser la plateforme Dont-code" }, - "version": "0.2~ynh3", + "version": "0.2~ynh4", "url": "https://dont-code.net", "upstream": { "license": "AGPL-3.0-or-later", diff --git a/scripts/backup b/scripts/backup index 672fc79..3d2288b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -33,6 +33,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) html_path=$(ynh_app_setting_get --app=$app --key=html_path) document_path=$(ynh_app_setting_get --app=$app --key=document_path) +public_key=$(ynh_app_setting_get --app=$app --key=public_key) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -65,7 +66,10 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= -ynh_backup --src_path="/etc/sudoers.d/$app-sudoers" +if [ -n "$public_key" ] +then + ynh_backup --src_path="/etc/sudoers.d/$app-sudoers" +fi # BACKUP LOGROTATE diff --git a/scripts/install b/scripts/install index e94a4a1..b781a62 100755 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,7 @@ source _common.sh source ynh_mongo_db__2 -source ynh_java +source ynh_install_java source /usr/share/yunohost/helpers #================================================= @@ -77,7 +77,7 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available ports..." --weight=1 +ynh_script_progression --message="Finding available ports..." --weight=1 ### Use these lines if you have to open a port for the application ### `ynh_find_port` will find the first available port starting from the given port. diff --git a/scripts/remove b/scripts/remove index 78464db..e196716 100755 --- a/scripts/remove +++ b/scripts/remove @@ -8,7 +8,7 @@ source _common.sh source ynh_mongo_db__2 -source ynh_java +source ynh_install_java source /usr/share/yunohost/helpers #================================================= @@ -103,14 +103,20 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -ynh_secure_remove --file="/etc/sudoers.d/$app-sudoers" +if [ -n "$public_key" ] +then + ynh_secure_remove --file="/etc/sudoers.d/$app-sudoers" +fi #================================================= # REMOVE DEPENDENCIES #================================================= ynh_script_progression --message="Removing dependencies..." --weight=1 -# Remove metapackage and its dependencies, including java +# Remove java +ynh_remove_java + +# Remove apackage and its dependencies, including Java if needed ynh_remove_app_dependencies #================================================= diff --git a/scripts/restore b/scripts/restore index 340e6b6..a7fb393 100755 --- a/scripts/restore +++ b/scripts/restore @@ -9,7 +9,7 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source ../settings/scripts/ynh_mongo_db__2 -source ../settings/scripts/ynh_java +source ../settings/scripts/ynh_install_java source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index fab7b44..7bb06ee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,7 +8,7 @@ source _common.sh source ynh_mongo_db__2 -source ynh_java +source ynh_install_java source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/ynh_java b/scripts/ynh_install_java similarity index 88% rename from scripts/ynh_java rename to scripts/ynh_install_java index c8334f6..42002d4 100644 --- a/scripts/ynh_java +++ b/scripts/ynh_install_java @@ -114,6 +114,21 @@ ynh_install_java() { ynh_use_java } +# Remove the version of Java used by the app. +# +# As Java is installed using ynh_install_app_dependencies, it will be removed as well when you call ynh_remove_app_dependencies in your remove script +# +# usage: ynh_remove_java +ynh_remove_java () { + local java_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=java_version) + + # Remove the lines for this app + ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=java_version + ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=jdk_type + ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=java_engine + +} + # Extract the architecture used to run this script # sets ynh_architecture as arm64 or amd64 # From 99484f02037015232dd14d7749f4c1c372cc3368 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 31 Jan 2023 15:48:04 +0000 Subject: [PATCH 2/2] 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 13c9a1b..17171ea 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ This Yunohost app installs the server part (services + mongo database) needed to - As well any documents or images uploaded by users will be backed up -**Shipped version:** 0.2~ynh3 +**Shipped version:** 0.2~ynh4 **Demo:** https://dont-code.net/apps.html diff --git a/README_fr.md b/README_fr.md index 9e2a6d6..379ef76 100644 --- a/README_fr.md +++ b/README_fr.md @@ -31,7 +31,7 @@ This Yunohost app installs the server part (services + mongo database) needed to - As well any documents or images uploaded by users will be backed up -**Version incluse :** 0.2~ynh3 +**Version incluse :** 0.2~ynh4 **Démo :** https://dont-code.net/apps.html