From 239be6aba6cd7db4d1611139e07715fe60d46c41 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Sun, 7 Feb 2021 23:12:41 +0530 Subject: [PATCH 1/5] Fixed https://github.com/YunoHost-Apps/firefly-iii/issues/28https://github.com/YunoHost-Apps/firefly-iii/issues/31 --- conf/cron | 2 ++ manifest.json | 2 +- scripts/backup | 6 ++++++ scripts/install | 11 +++++++++++ scripts/remove | 10 ++++++++++ scripts/restore | 7 +++++++ scripts/upgrade | 21 ++++++++++++++------- 7 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 conf/cron diff --git a/conf/cron b/conf/cron new file mode 100644 index 0000000..69dc851 --- /dev/null +++ b/conf/cron @@ -0,0 +1,2 @@ +# cron job for __APP__ +0 3 * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/artisan firefly-iii:cron diff --git a/manifest.json b/manifest.json index 578c278..308137f 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Self-hosted financial manager.", "fr": "Gestionnaire de finances personnelles." }, - "version": "5.4.6~ynh1", + "version": "5.4.6~ynh2", "url": "https://firefly-iii.org/", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/backup b/scripts/backup index 836e218..4650867 100755 --- a/scripts/backup +++ b/scripts/backup @@ -60,6 +60,12 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" +#================================================= +# BACKUP A CRON FILE +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # BACKUP THE MYSQL DATABASE #================================================= diff --git a/scripts/install b/scripts/install index 63426ba..8067537 100755 --- a/scripts/install +++ b/scripts/install @@ -171,6 +171,17 @@ ynh_script_progression --message="Securing files and directories..." chown -R $app:$app $final_path chmod -R 775 ${final_path}/storage +#================================================= +# SETUP A CRON +#================================================= +ynh_script_progression --message="Setuping a cron..." + +cp ../conf/cron /etc/cron.d/$app + +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="/etc/cron.d/$app" + #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/remove b/scripts/remove index 62ae859..0f5539b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -63,6 +63,16 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE THE CRON FILE +#================================================= +ynh_script_progression --message="Removing the cron file..." + +# Remove a cron file +ynh_secure_remove --file="/etc/cron.d/$app" + #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 5984393..91d0b4b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -102,6 +102,13 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +#================================================= +# RESTORE THE CRON FILE +#================================================= +ynh_script_progression --message="Restoring the cron file..." + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2cf47d0..01dc19a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -201,18 +201,14 @@ ynh_script_progression --message="Deploying..." pushd "$final_path" - php$phpversion artisan migrate:refresh --seed + rm -rf bootstrap/cache/* + php$phpversion artisan cache:clear + php$phpversion artisan migrate --seed php$phpversion artisan firefly-iii:upgrade-database php$phpversion artisan passport:install php$phpversion artisan cache:clear - #rm -rf "$final_path/bootstrap/cache/*" - #php$phpversion artisan cache:clear - #php$phpversion artisan migrate --seed - #php$phpversion artisan firefly-iii:upgrade-database - #php$phpversion artisan passport:install - #php$phpversion artisan cache:clear popd #================================================= @@ -234,6 +230,17 @@ ynh_script_progression --message="Securing files and directories..." chown -R $app: $final_path chmod -R 775 ${final_path}/storage +#================================================= +# SETUP A CRON +#================================================= +ynh_script_progression --message="Setuping a cron..." + +cp ../conf/cron /etc/cron.d/$app + +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="/etc/cron.d/$app" + #================================================= # SETUP SSOWAT #================================================= From c50b52a7fefc9cbfbb4897660685b18978fa6308 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Sun, 7 Feb 2021 23:18:45 +0530 Subject: [PATCH 2/5] Added hash in checks --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 43d9545..4252eb8 100644 --- a/check_process +++ b/check_process @@ -17,7 +17,7 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=66140e9d21f8d9e07074b5bded213265b06819d5 + upgrade=1 from_commit=231c5e281e9cafabd35d4a6ef3c27fec6f3c470f backup_restore=1 multi_instance=1 port_already_use=0 From 2c296abea42b3d3375296283dce8e085e9256c1a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 8 Feb 2021 07:48:49 +0100 Subject: [PATCH 3/5] Small fixes --- check_process | 5 ----- manifest.json | 2 +- pull_request_template.md | 4 +--- scripts/install | 11 ++++++----- scripts/upgrade | 22 ++++++++-------------- 5 files changed, 16 insertions(+), 28 deletions(-) diff --git a/check_process b/check_process index 43d9545..eea481a 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,6 @@ # See here for more informations # https://github.com/YunoHost/package_check#syntax-check_process-file -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) @@ -22,9 +20,6 @@ multi_instance=1 port_already_use=0 change_url=0 -;;; Levels - # If the level 5 (Package linter) is forced to 1. Please add justifications here. - Level 5=auto ;;; Options Email=anmol@datamol.org Notification=change diff --git a/manifest.json b/manifest.json index 578c278..43f94c9 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "url": "https://datamol.org" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.0.0" }, "multi_instance": true, "services": [ diff --git a/pull_request_template.md b/pull_request_template.md index c96d9fa..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/firefly-iii_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/firefly-iii_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/install b/scripts/install index 63426ba..1e15eb1 100755 --- a/scripts/install +++ b/scripts/install @@ -168,8 +168,8 @@ popd ynh_script_progression --message="Securing files and directories..." # Set right permissions -chown -R $app:$app $final_path -chmod -R 775 ${final_path}/storage +chown -R $app: $final_path +chmod -R 775 $final_path/storage #================================================= # SETUP LOGROTATE @@ -182,13 +182,14 @@ ynh_use_logrotate #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b6a6613..5ddfd8b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -60,6 +60,13 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -150,7 +157,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Updating PHP dependencies..." -chown -R "$app": "$final_path" +chown -R $app: "$final_path" ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$final_path" @@ -183,7 +190,6 @@ ynh_replace_string --match_string="changeme@example.com" --replace_string="$app@ # ynh_replace_string --match_string="userprincipalname" --replace_string="uid" --target_file="$config" ynh_replace_string --match_string="localhost" --replace_string="$domain$path_url" --target_file="$config" - # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" @@ -227,18 +233,6 @@ ynh_script_progression --message="Securing files and directories..." chown -R $app: $final_path chmod -R 775 ${final_path}/storage -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi - #================================================= # RELOAD NGINX #================================================= From 84836ff3d3110ac04486d856d93b174209220bb1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 8 Feb 2021 07:50:55 +0100 Subject: [PATCH 4/5] Update upgrade --- scripts/upgrade | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 18651eb..c8eb570 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -229,6 +229,17 @@ ynh_script_progression --message="Securing files and directories..." chown -R $app: $final_path chmod -R 775 ${final_path}/storage +#================================================= +# SETUP A CRON +#================================================= +ynh_script_progression --message="Setuping a cron..." + +cp ../conf/cron /etc/cron.d/$app + +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="/etc/cron.d/$app" + #================================================= # RELOAD NGINX #================================================= From 6b12c64126b26978cc9daba80d796c05e2e0e2a4 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 8 Feb 2021 08:58:17 +0100 Subject: [PATCH 5/5] Cleaning up --- scripts/change_url | 6 ------ scripts/install | 5 +---- scripts/upgrade | 16 +++++----------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f8d06ff..9afe639 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -101,12 +101,6 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index 1095955..6c75f8b 100755 --- a/scripts/install +++ b/scripts/install @@ -26,8 +26,7 @@ path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC random_key=$(ynh_string_random --length=32) - -email=$(ynh_user_get_info $admin 'mail') +email=$(ynh_user_get_info --username=$admin --key=mail) app=$YNH_APP_INSTANCE_NAME @@ -198,8 +197,6 @@ ynh_script_progression --message="Configuring permissions..." # Make app public if necessary if [ $is_public -eq 1 ] then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi diff --git a/scripts/upgrade b/scripts/upgrade index c8eb570..ccac2ed 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,7 +25,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) random_key=$(ynh_app_setting_get --app=$app --key=random_key) -email=$(ynh_user_get_info $admin 'mail') +email=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # CHECK VERSION @@ -104,18 +104,15 @@ then cp -a "$final_path/storage/export/" "$tmpdir/storage/export/" ynh_secure_remove --file="$final_path" - # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" # Restore the config file cp -a "$tmpdir/storage/upload/" "$final_path/storage/upload/" cp -a "$tmpdir/storage/export/" "$final_path/storage/export/" - cp -a "$tmpdir/.env" "$final_path/.env" + cp -a "$tmpdir/.env" "$final_path/.env" # Remove temporary directory ynh_secure_remove --file="$tmpdir" - - fi #================================================= @@ -157,7 +154,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Updating PHP dependencies..." -chown -R $app: "$final_path" +chown -R $app: $final_path ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$final_path" @@ -199,15 +196,12 @@ ynh_store_file_checksum --file="$config" ynh_script_progression --message="Deploying..." pushd "$final_path" - - rm -rf bootstrap/cache/* + ynh_secure_remove --file="bootstrap/cache/*" php$phpversion artisan cache:clear php$phpversion artisan migrate --seed php$phpversion artisan firefly-iii:upgrade-database php$phpversion artisan passport:install php$phpversion artisan cache:clear - - popd #================================================= @@ -227,7 +221,7 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path -chmod -R 775 ${final_path}/storage +chmod -R 775 $final_path/storage #================================================= # SETUP A CRON