From d79d1a2c24c68a4e171206e4d1a55d146485a98f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 02:25:33 +0200 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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 f73ff8dc528e29035f3f7cb6812f746bd87dce31 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 20:31:13 +0200 Subject: [PATCH 05/10] Adding few automations --- .travis.yml | 7 +++++++ pull_request_template.md | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .travis.yml create mode 100644 pull_request_template.md diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..6133a245 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python + +before_install: + - git clone https://github.com/YunoHost/package_linter /tmp/package_linter + +script: +- /tmp/package_linter/package_linter.py ./ \ No newline at end of file diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 00000000..d7433702 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,23 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Validation +--- +- [ ] **Code review** +- [ ] **Approval (LGTM)** +*Code review and approval have to be from a member of @YunoHost/apps group* +- **CI succeeded** : +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/) +*Please replace '-BRANCH-' in this link by the name of the branch used.* +*If the PR is from a forked repository. Please provide public results from package_check.* +When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 871a1afad2fec7a462df8751f272487e2070da5d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 22:01:12 +0200 Subject: [PATCH 06/10] 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 07/10] 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 08/10] 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": { From db7aea98494ef705fc33959e18a06dae2c6def5c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 15 Apr 2019 21:02:55 +0200 Subject: [PATCH 09/10] move to CI dev --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index d7433702..f850ebe0 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -17,7 +17,7 @@ - [ ] **Approval (LGTM)** *Code review and approval have to be from a member of @YunoHost/apps group* - **CI succeeded** : -[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/) +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/) *Please replace '-BRANCH-' in this link by the name of the branch used.* *If the PR is from a forked repository. Please provide public results from package_check.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From c4f56db3216493f524da1dda5d4c94e31ba65f4b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Apr 2019 22:47:36 +0200 Subject: [PATCH 10/10] Update _common.sh --- scripts/_common.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 926b5524..c084b21c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -96,6 +96,9 @@ ynh_install_php () { ynh_add_app_dependencies --package="php${phpversion}-fpm" ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package" + # Set php7.0 back as the default version for php-cli. + update-alternatives --set php /usr/bin/php7.0 + # Remove this extra repository after packages are installed ynh_remove_extra_repo --name=extra_php_version