From 9d93d439db47ec70f051ac92702812f77e6e5bb5 Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 14:53:08 +0200 Subject: [PATCH 01/15] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 74892e8..b6178a5 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "misterl56@hotmail.com" }, "requirements": { - "yunohost": ">= 3.5.2" + "yunohost": ">= 4.1" }, "multi_instance": false, "services": [ From c719402ce2a69ac13a12e90e7e876487dae75a99 Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 14:54:37 +0200 Subject: [PATCH 02/15] 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 f1cb75a..2e78f97 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,6 @@ #================================================= # COMMON VARIABLES #================================================= -pkg_dependencies="php-geoip php7.0-cli" +pkg_dependencies="php-geoip php7.0-cli php7.0-foobar" app="emailpoubelle" lang="fr_FR.UTF-8 en_US.UTF-8 it_IT.UTF-8" From 893768d89ce9b6ba4b41e1d95f91ccbc41a2ab7c Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 14:55:24 +0200 Subject: [PATCH 03/15] Update install --- scripts/install | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/install b/scripts/install index e52c69f..8fcec4d 100644 --- a/scripts/install +++ b/scripts/install @@ -29,9 +29,6 @@ ynh_script_progression --message="Validating installation parameters..." --weigh final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - # Check web path availability ynh_webpath_available $domain $path_url # Register (book) web path From e828d216baa015b87ee3a3361a68a634cd02f974 Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 14:58:31 +0200 Subject: [PATCH 04/15] Update upgrade --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index ac92353..c510373 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,7 +16,6 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) admin=$(ynh_app_setting_get $app admin) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) From 559a42a923fac120be7eaf8bd65d278cb81cf79e Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:02:11 +0200 Subject: [PATCH 05/15] Update upgrade --- scripts/upgrade | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c510373..c475e9a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,8 +77,6 @@ ynh_abort_if_errors # CHECK THE PATH #================================================= # Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) - #================================================= #check for matlink's version - DEPRECATED - uninstall & reinstall From b582f5376070b2bbd574d090be3a38918d48658e Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:03:59 +0200 Subject: [PATCH 06/15] Update backup --- scripts/backup | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/backup b/scripts/backup index d640ec4..d901a31 100644 --- a/scripts/backup +++ b/scripts/backup @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -38,35 +38,35 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." +ynh_print_info --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." +ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Backing up the MySQL database..." +ynh_print_info --message="Backing up the MySQL database..." ynh_mysql_dump_db "$db_name" > db.sql #================================================= # BACKUP THE CRON FILE #================================================= -ynh_script_progression --message="Backing up cron configuration..." +ynh_print_info --message="Backing up cron configuration..." ynh_backup --src_path="/etc/cron.d/$app" #================================================= # BACKUP postfix conf #================================================= -ynh_script_progression --message="Backing up postfix conf configuration..." +ynh_print_info --message="Backing up postfix conf configuration..." ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" @@ -74,4 +74,4 @@ ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last From 2b505952e4f189e905b884fb761d387e96c6cece Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:07:50 +0200 Subject: [PATCH 07/15] Create change_url --- scripts/change_url | 134 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 scripts/change_url diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..495b7eb --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,134 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last From 3690e869e3c96459d33cbbeb8649832485993fdc Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:09:02 +0200 Subject: [PATCH 08/15] Update check_process --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 321fbee..4b0452e 100644 --- a/check_process +++ b/check_process @@ -18,7 +18,7 @@ multi_instance=0 incorrect_path=1 port_already_use=0 (XXXX) - change_url=0 + change_url=1 ;;; Levels Level 5=auto ;;; Options @@ -27,4 +27,4 @@ Notification=none ;;; Upgrade options ; commit=1d375c45011ad5ab92c038120c7275580479fbc6 name=2.0~ynh3 - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=0& \ No newline at end of file + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=0& From c905192ae27b67c23451856c61658d847fc5c2bb Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:17:41 +0200 Subject: [PATCH 09/15] Update upgrade --- scripts/upgrade | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index c475e9a..c61d3f6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,6 +72,15 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# Migrate legacy permissions to new system +#================================================= +if ynh_legacy_permissions_exists +then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi #================================================= # CHECK THE PATH From 55f09725ce4f91f39f1c13814230d2cea956a1e1 Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:19:18 +0200 Subject: [PATCH 10/15] Update install --- scripts/install | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 8fcec4d..71fb2d6 100644 --- a/scripts/install +++ b/scripts/install @@ -45,7 +45,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app db_name $db_user ynh_app_setting_set $app final_path $final_path @@ -141,10 +140,10 @@ ynh_add_nginx_config #================================================= # Make app public if necessary -if [ $is_public -eq 1 ] +if [ "$is_public" -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= From d42dd90c8b01cf9a47a38d215d7fa193a78a6e33 Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 17:41:30 +0200 Subject: [PATCH 11/15] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b6178a5..edc63c9 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "misterl56@hotmail.com" }, "requirements": { - "yunohost": ">= 4.1" + "yunohost": ">= 4.1.0" }, "multi_instance": false, "services": [ From 9ab4afa8f968e5b3318bdbbb467f22cbed1c2f57 Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 17:47:58 +0200 Subject: [PATCH 12/15] 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 2e78f97..10f92b4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,6 @@ #================================================= # COMMON VARIABLES #================================================= -pkg_dependencies="php-geoip php7.0-cli php7.0-foobar" +pkg_dependencies="php-geoip php7.3-cli" app="emailpoubelle" lang="fr_FR.UTF-8 en_US.UTF-8 it_IT.UTF-8" From a845cd44bf114a1032321350628f2f79dfca251f Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 17:54:29 +0200 Subject: [PATCH 13/15] Update manifest.json --- manifest.json | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/manifest.json b/manifest.json index edc63c9..349808d 100644 --- a/manifest.json +++ b/manifest.json @@ -28,29 +28,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for emailpoubelle", - "fr": "Choisissez un domaine pour emailpoubelle" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for emailpoubelle", - "fr": "Choisissez un chemin pour emailpoubelle" - }, "example": "/poubelle", "default": "/poubelle" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user for emailpoubelle", - "fr": "Choisissez un administrateur pour emailpoubelle" - }, "example": "homer", "help": { "en": "Admin user can access to the control panel, block and remove all redirection and reset any settings", @@ -60,19 +48,11 @@ { "name": "password", "type": "password", - "ask": { - "en": "Enter a password to access the admin panel", - "fr": "Entrer un mot de passe pour accéder au tableau d'administration" - }, "example": "AveryStrongPassword" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": false, "help": { "en": "The app can be accessed outside Yunohost and anyone will be able to create a trash email adress", From fe0e4f9da39d59b5ba4812b2c27dadd37ec13751 Mon Sep 17 00:00:00 2001 From: oufmilo <44617467+oufmilo@users.noreply.github.com> Date: Thu, 24 Jun 2021 17:57:56 +0200 Subject: [PATCH 14/15] Update upgrade --- scripts/upgrade | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c61d3f6..b7bb4bc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,13 +38,13 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi +#if [ "$is_public" = "Yes" ]; then +# ynh_app_setting_set --app=$app --key=is_public --value=1 +# is_public=1 +#elif [ "$is_public" = "No" ]; then +# ynh_app_setting_set --app=$app --key=is_public --value=0 +# is_public=0 +#fi # If db_name doesn't exist, create it if [ -z "$db_name" ]; then From a16dba74376abcb6a7e046c0a67b83b520e29213 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 25 Jun 2021 09:34:52 +0200 Subject: [PATCH 15/15] Update backup --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index d901a31..e2fb506 100644 --- a/scripts/backup +++ b/scripts/backup @@ -74,4 +74,4 @@ ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."