From 9c0f0cf708a5cbd6c90c076b79e15a3f17660e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 17 Jan 2024 16:21:15 +0100 Subject: [PATCH] Fix missing color at upgrade --- scripts/install | 2 +- scripts/upgrade | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index cd786a7..28473e5 100755 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers # Password is required to regen the files... ynh_app_setting_set --app="$app" --key=password --value="$password" -password_sha1=$(python -c 'import hashlib; import sys; a=str(sys.argv[1]); print(hashlib.sha512(a.encode("UTF-8")).hexdigest())' $password) +password_sha1=$(python -c 'import hashlib; import sys; a=str(sys.argv[1]); print(hashlib.sha512(a.encode("UTF-8")).hexdigest())' "$password") # Validate, fix and set default value for color color="$(_validate_color)" diff --git a/scripts/upgrade b/scripts/upgrade index 2cecaa5..f968276 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,11 +24,20 @@ if [[ -z "${password:-}" ]]; then ynh_app_setting_set --app="$app" --key=password --value="$password" fi +if [[ -z "${color:-}" ]]; then + color=$(grep -A1 'For YunoHost config' "$install_dir/templates/minimaxing/minimaxing.css" | grep -oP '^/\* @fg: #\K.*(?=;)') + if [[ -z "$password" ]]; then + command="yunohost app setting $app color -v 'YOUR BASE COLOR'" + ynh_die --message="Could not retrieve base color from config. Please run '$command' then retry the upgrade." + fi + ynh_app_setting_set --app="$app" --key=password --value="$password" +fi + #================================================= # INITIALIZE AND STORE SETTINGS #================================================= -password_sha1=$(python -c 'import hashlib; import sys; a=str(sys.argv[1]); print(hashlib.sha512(a.encode("UTF-8")).hexdigest())' $password) +password_sha1=$(python -c 'import hashlib; import sys; a=str(sys.argv[1]); print(hashlib.sha512(a.encode("UTF-8")).hexdigest())' "$password") # Validate, fix and set default value for color color="$(_validate_color)"