From 71beeacef078dcb5b5d2dc9405c9fdb96627bfbb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 03:40:31 +0200 Subject: [PATCH] fix app_key --- scripts/install | 3 ++- scripts/upgrade | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 50dc8c04..d60e5fa4 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -app_key=$(ynh_string_random 32) +app_key=$(ynh_string_random 32 | base64) +app_key="base64:$app_key" app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/upgrade b/scripts/upgrade index 801530bc..87b3e2f8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ language=$(ynh_app_setting_get "$app" language) db_name=$(ynh_app_setting_get "$app" db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get "$app" db_pwd) +app_key=$(ynh_app_setting_get "$app" app_key) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -52,6 +53,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set "$app" final_path "$final_path" fi +# If app_key doesn't exist, retrieve it +if [ -z "$app_key" ]; then + app_key=$(grep -oP "APP_KEY=\Kbase64.*" "$final_path/.env") + ynh_app_setting_set "$app" app_key "$app_key" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -141,9 +148,10 @@ ynh_install_composer --workdir="$final_path" #================================================= config="$final_path/.env" -cp -f ../conf/.env "$config" +cp ../conf/.env "$config" ynh_replace_string "__APP__" "$app" "$config" +ynh_replace_string "__APP_KEY__" "$app_key" "$config" ynh_replace_string "__DOMAIN__" "$domain" "$config" ynh_replace_string "__PATH__" "$path_url" "$config" ynh_replace_string "__DB_NAME__" "$db_name" "$config"