From d79d1a2c24c68a4e171206e4d1a55d146485a98f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 02:25:33 +0200 Subject: [PATCH 1/7] spacing --- scripts/upgrade | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ba7bb706..8eef5ffa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -156,8 +156,6 @@ pushd "$final_path" php7.2 artisan horizon:purge popd - - ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/.env" From 96d964838ce4c758ba3472673db575ceb525da75 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 02:25:54 +0200 Subject: [PATCH 2/7] activate APP_KEY --- conf/.env | 2 +- scripts/install | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/.env b/conf/.env index ccd91fe0..378734cb 100644 --- a/conf/.env +++ b/conf/.env @@ -1,6 +1,6 @@ APP_NAME=__APP__ APP_ENV=production -APP_KEY= +APP_KEY=__APP_KEY__ APP_DEBUG=true APP_URL=https://__DOMAIN__ diff --git a/scripts/install b/scripts/install index 4c263969..63381d08 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC +app_key=$(ynh_string_random --length=32) app=$YNH_APP_INSTANCE_NAME @@ -44,6 +45,7 @@ ynh_webpath_register "$app" "$domain" "$path_url" ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set "$app" app_key "$app_key" #================================================= # STANDARD MODIFICATIONS @@ -129,6 +131,7 @@ config="$final_path/.env" 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" From 1b21d9cf05e94e0229b212645388390bc070a3d8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 13:40:19 +0200 Subject: [PATCH 3/7] Fix ynh_string_random --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 63381d08..0d789cd6 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -app_key=$(ynh_string_random --length=32) +app_key=$(ynh_string_random 32) app=$YNH_APP_INSTANCE_NAME From f41e3bf3387f02c559acba3cb56d66c772d480e6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 19:57:28 +0200 Subject: [PATCH 4/7] upgrade .env configuration file during upgrade --- scripts/upgrade | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 775e04db..3f5ba5ca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ is_public=$(ynh_app_setting_get "$app" is_public) final_path=$(ynh_app_setting_get "$app" final_path) language=$(ynh_app_setting_get "$app" language) db_name=$(ynh_app_setting_get "$app" db_name) +db_user=$db_name #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -134,6 +135,20 @@ chown -R "$app": "$final_path" ynh_install_composer --workdir="$final_path" +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +config="$final_path/.env" +cp -f ../conf/.env "$config" + +ynh_replace_string "__APP__" "$app" "$config" +ynh_replace_string "__DOMAIN__" "$domain" "$config" +ynh_replace_string "__PATH__" "$path_url" "$config" +ynh_replace_string "__DB_NAME__" "$db_name" "$config" +ynh_replace_string "__DB_USER__" "$db_user" "$config" +ynh_replace_string "__DB_PWD__" "$db_pwd" "$config" + #================================================= # DEPLOYMENT #================================================= @@ -149,11 +164,16 @@ pushd "$final_path" php7.2 artisan horizon:purge popd +#================================================= +# STORE THE CHECKSUM OF THE CONFIG FILE +#================================================= +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$config" -ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" +ynh_backup_if_checksum_is_different "$config" # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "$final_path/.env" +ynh_store_file_checksum "$config" #================================================= # GENERIC FINALIZATION From 871a1afad2fec7a462df8751f272487e2070da5d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 22:01:12 +0200 Subject: [PATCH 5/7] fix db_pwd missing --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 3f5ba5ca..0f38819e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ final_path=$(ynh_app_setting_get "$app" final_path) 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) #================================================= # ENSURE DOWNWARD COMPATIBILITY From 71beeacef078dcb5b5d2dc9405c9fdb96627bfbb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 03:40:31 +0200 Subject: [PATCH 6/7] 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" From c37d7903bb9ac0b9c26f31f6c2be87035acaaafb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 12:38:58 +0200 Subject: [PATCH 7/7] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index ef4cd63b..b01bab6b 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.8.6~ynh2", + "version": "0.8.6~ynh3", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": {