From 41e5701b1083c6bfed74376cefee5db7d9d62c5f Mon Sep 17 00:00:00 2001 From: Daniel Fahey Date: Thu, 16 Nov 2023 14:06:03 +0000 Subject: [PATCH] Update app settings from admin user during upgrade --- scripts/upgrade | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 9e81856..7cb7b33 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,6 +45,25 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" +#================================================= +# UPDATE APP SETTINGS +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + # Delete deprecated `firstname`/`lastname` 'null' settings. See upstream https://github.com/YunoHost/yunohost/pull/1516 + ynh_app_setting_delete --app=$app --key=email_firstname + ynh_app_setting_delete --app=$app --key=email_lastname + + # Retrieve admin user settings + email_fullname="$(ynh_user_get_info --username=$admin --key=fullname)" + email="$(ynh_user_get_info --username=$admin --key=mail)" # include as admin's email address is also subject to change + + # Set + ynh_app_setting_set --app=$app --key=email_fullname --value="$email_fullname" + ynh_app_setting_set --app=$app --key=email --value=$email +fi + #================================================= # UPDATE A CONFIG FILE #=================================================