From 1a4f04275fb680c0125acbdb54984e7ae49b1b7c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 6 Feb 2022 02:01:51 +0100 Subject: [PATCH] Implementing prosody --- scripts/install | 6 +++++- scripts/remove | 25 +++++++++++++++++++++++++ scripts/restore | 6 +++++- scripts/upgrade | 8 +++++--- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 4badc73..37eff8e 100644 --- a/scripts/install +++ b/scripts/install @@ -93,9 +93,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" + yunohost app install prosody --force +else + yunohost app upgrade prosody --force fi +ynh_app_setting_set --app=$app --key=require_prosody --value="1" + #================================================= # CREATE DEDICATED USER #================================================= diff --git a/scripts/remove b/scripts/remove index fc5a63d..b88efa1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -110,6 +110,31 @@ ynh_script_progression --message="Removing dependencies..." ynh_remove_nodejs ynh_remove_app_dependencies +# Remove Prosody +ynh_app_setting_delete --app=$app --key=require_prosody + +# List apps requiring Prosody +installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') +required_by="" +installed_app_required_by="" +for installed_app in $installed_apps +do + installed_app_required_by=$(ynh_app_setting_get --app=$installed_app --key="require_prosody") + if [[ $installed_app_required_by ]] + then + required_by="${installed_app_required_by}" + fi + installed_app_required_by="" +done + +# If Prosody is no more required +if [[ ! $required_by ]] +then + # Remove Prosody + ynh_print_info --message="Removing of Prosody" + yunohost app remove prosody --purge +fi + #================================================= # CLOSE A PORT #================================================= diff --git a/scripts/restore b/scripts/restore index ea26709..cbca928 100644 --- a/scripts/restore +++ b/scripts/restore @@ -104,9 +104,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" + yunohost app install prosody --force +else + yunohost app upgrade prosody --force fi +ynh_app_setting_set --app=$app --key=require_prosody --value="1" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b5e6c97..f96472a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -218,11 +218,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" -elfi - yunohost app upgrade + yunohost app install prosody --force +else + yunohost app upgrade prosody --force fi +ynh_app_setting_set --app=$app --key=require_prosody --value="1" + #================================================= # SPECIFIC UPGRADE #=================================================