From c1a5b26d86e72e34d2384b2e6d3576f2e2965737 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Tue, 22 Aug 2023 17:32:13 +0200 Subject: [PATCH] fix data config not kept between updates --- scripts/change_url | 3 +++ scripts/install | 5 ++++- scripts/upgrade | 9 ++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c646e62..6d7e713 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,8 +32,11 @@ ynh_change_url_nginx_config #================================================= ynh_backup_if_checksum_is_different --file="$install_dir/config/appsettings.json" +key=$(ynh_app_setting_get --app="$app" --key=key) domain="$new_domain" +ynh_app_setting_set --app="$app" --key=domain --value="$domain" url_path=${new_path#/} +ynh_app_setting_set --app="$app" --key=url_path --value="$url_path" ynh_add_config --template="../conf/appsettings.json.example" --destination="$install_dir/config/appsettings.json" diff --git a/scripts/install b/scripts/install index e012aa5..857975b 100755 --- a/scripts/install +++ b/scripts/install @@ -39,8 +39,11 @@ yunohost service add "$app" --description="Cross platform reading server" --log= #================================================= ynh_script_progression --message="Modifying a config file..." --weight=1 -key=$(ynh_string_random --length=24) +key=$(ynh_string_random --length=70) +ynh_app_setting_set --app="$app" --key=key --value="$key" url_path=${path#/} +ynh_app_setting_set --app="$app" --key=url_path --value="$url_path" + ynh_add_config --template="../conf/appsettings.json.example" --destination="$install_dir/config/appsettings.json" chmod 600 "$install_dir/config/appsettings.json" diff --git a/scripts/upgrade b/scripts/upgrade index 3ee5675..40b2919 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,7 +45,14 @@ chmod +x "$install_dir"/Kavita #================================================= ynh_script_progression --message="Modifying a config file..." --weight=1 -key=$(ynh_string_random --length=24) +key=$(ynh_app_setting_get --app="$app" --key=storage_s3_bucket) + +if [ -z "$key" ] || [ "$key" == "super secret unguessable key that is longer because we require it" ] +then + key=$(ynh_string_random --length=70) + ynh_app_setting_set --app="$app" --key=key --value="$key" +fi + url_path=${path#/} ynh_add_config --template="../conf/appsettings.json.example" --destination="$install_dir/config/appsettings.json"