From e2fd53ce0f7b243b12e94e43971758ed15cbbfd8 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Sun, 17 Dec 2023 16:52:22 +0100 Subject: [PATCH] make config_panel consistent to prevent issues --- conf/.env.production | 4 ++-- config_panel.toml | 4 ++-- manifest.toml | 4 ++-- scripts/change_url | 3 --- scripts/install | 4 ++-- scripts/upgrade | 20 ++++++++++++++++++-- tests.toml | 3 ++- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/conf/.env.production b/conf/.env.production index bf31765..7d4cb0f 100644 --- a/conf/.env.production +++ b/conf/.env.production @@ -36,6 +36,6 @@ STATICMAP_SUBDOMAINS='' # Weather # available weather API providers: darksky, visualcrossing -WEATHER_API_PROVIDER=__WEATHER_PROVIDER__ -WEATHER_API_KEY=__WEATHER_KEY__ +WEATHER_API_PROVIDER=__WEATHER_API_PROVIDER__ +WEATHER_API_KEY=__WEATHER_API_KEY__ diff --git a/config_panel.toml b/config_panel.toml index 738ab0a..e42af69 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -26,7 +26,7 @@ services = ["__APP__", "__APP___workers"] help.fr = "Change le répertoire de données où sont stockés tous les fichiers .gpx téléversés et les photos de profil" bind = "UPLOAD_FOLDER:/var/www/__APP__/.env" - [main.config.weather_provider] + [main.config.weather_api_provider] ask.en = "Change weather provider" ask.fr = "Changer le fournisseur météo" type = "select" @@ -36,7 +36,7 @@ services = ["__APP__", "__APP___workers"] help.fr = "Changer votre fournisseur météo en choisissant un de ceux qui vous sont proposés" bind = "WEATHER_API_PROVIDER:/var/www/__APP__/.env" - [main.config.WEATHER_API_KEY] + [main.config.weather_api_key] ask.en = "Change weather api key" ask.fr = "Changer la clé api pour la météo" type = "string" diff --git a/manifest.toml b/manifest.toml index 6fcd57e..d2af7c5 100644 --- a/manifest.toml +++ b/manifest.toml @@ -47,7 +47,7 @@ ram.runtime = "50M" help.fr = "Choisissez un mot de passe pour l’utilisateur admin ici." type = "password" - [install.weather_provider] + [install.weather_api_provider] ask.en = "(Optional) Choose your weather provider between Darksky and Visual Crossing" ask.fr = "(Optionnel) Choisissez votre fournisseur météo entre Darksky et Visual Crossing" help.en = "Since Fittrackee 0.7.15, only Visual Crossing is supported" @@ -57,7 +57,7 @@ ram.runtime = "50M" default = "visualcrossing" optional = true - [install.weather_key] + [install.weather_api_key] ask.en = "(Optional) Insert here the api key from the chosen weather provider" ask.fr = "(Optionnel) Insérez ici la clé API du fournisseur de météo choisi" type = "string" diff --git a/scripts/change_url b/scripts/change_url index fedb9ea..63342db 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,9 +16,6 @@ source /usr/share/yunohost/helpers admin=$(ynh_user_get_info --username=$admin --key=username) admin_mail=$(ynh_user_get_info --username=$admin --key=mail) -weather_provider=$(ynh_app_setting_get --app=$app --key=$weather_provider) -weather_key=$(ynh_app_setting_get --app=$app --key=$weather_key) - #================================================= # STANDARD UPGRADE STEPS #================================================= diff --git a/scripts/install b/scripts/install index 62248ef..834cfd3 100755 --- a/scripts/install +++ b/scripts/install @@ -11,8 +11,8 @@ source /usr/share/yunohost/helpers admin=$(ynh_user_get_info --username=$admin --key=username) admin_mail=$(ynh_user_get_info --username=$admin --key=mail) -ynh_app_setting_set --app=$app --key=weather_provider --value=$weather_provider -ynh_app_setting_set --app=$app --key=weather_key --value=$weather_key +ynh_app_setting_set --app=$app --key=weather_api_provider --value=$weather_api_provider +ynh_app_setting_set --app=$app --key=weather_api_key --value=$weather_api_key #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8b3f4de..48abda0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,8 +16,24 @@ source /usr/share/yunohost/helpers admin=$(ynh_user_get_info --username=$admin --key=username) admin_mail=$(ynh_user_get_info --username=$admin --key=mail) -weather_provider=$(ynh_app_setting_get --app=$app --key=$weather_provider) -weather_key=$(ynh_app_setting_get --app=$app --key=$weather_key) +ynh_app_setting_set --app=$app --key=weather_api_provider --value=$weather_api_provider +ynh_app_setting_set --app=$app --key=weather_api_key --value=$weather_api_key + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +if [ -z "${weather_api_provider:-}" ]; then + weather_api_provider=$weather_provider + ynh_app_setting_set --app=$app --key=weather_api_provider --value=$weather_api_provider +fi + +if [ -z "${weather_api_key:-}" ]; then + weather_api_key=$weather_key + ynh_app_setting_set --app=$app --key=weather_api_key --value=$weather_api_key +fi + #================================================= # CHECK VERSION diff --git a/tests.toml b/tests.toml index bc1e91f..ec891a5 100644 --- a/tests.toml +++ b/tests.toml @@ -21,4 +21,5 @@ test_format = 1.0 test_upgrade_from.e49294c.name = "0.7.22" test_upgrade_from.a446e8c.name = "0.7.23" test_upgrade_from.316dea4.name = "0.7.24" - test_upgrade_from.d682f12.name = "0.7.25~ynh3" \ No newline at end of file + test_upgrade_from.d682f12.name = "0.7.25~ynh3" + test_upgrade_from.e48197d.name = "0.7.26" \ No newline at end of file