From a5bba52e1af8a8846680d0f63499ecb2df46a15e Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 13:44:55 +0200 Subject: [PATCH 1/9] upgrade script to allox old version upgrade, upgrade pull_request_template (new package check process, add local curl to finalise upgrade --- conf/0.8.5.src | 6 +++++ conf/0.9.8.src | 6 +++++ manifest.json | 2 +- pull_request_template.md | 5 ----- scripts/upgrade | 47 ++++++++++++++++++++++++++++++++++++---- 5 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 conf/0.8.5.src create mode 100644 conf/0.9.8.src diff --git a/conf/0.8.5.src b/conf/0.8.5.src new file mode 100644 index 0000000..0bd9166 --- /dev/null +++ b/conf/0.8.5.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.8.5.tar.bz2 +SOURCE_SUM=6cd90b806b35386e4d5be98e2db26ca3dbbd32a74538bedefcd9fbad0bfc8d5a +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.bz2 +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= diff --git a/conf/0.9.8.src b/conf/0.9.8.src new file mode 100644 index 0000000..01152be --- /dev/null +++ b/conf/0.9.8.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.8.1.tar.bz2 +SOURCE_SUM=7cc64b51c9721c2dd7ee510f245bcfc4693ee07f74581ad74003906eb4716ef1 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.bz2 +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index 0545d5b..2460e78 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Software to manage association", "fr": "Logiciel libre de gestion d'association" }, - "version": "1.0.7~ynh1", + "version": "1.0.7~ynh2", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/pull_request_template.md b/pull_request_template.md index b8b0a14..040e119 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -11,8 +11,3 @@ - [ ] Upgrade from last version tested. - [ ] Can be reviewed and tested. -## 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/garradin_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/garradin_ynh%20PR-NUM-%20(USERNAME)/) diff --git a/scripts/upgrade b/scripts/upgrade index cb15d46..acd69fb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,11 +24,14 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= -if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1; then - ynh_print_info --message="Sorry your version is outdated and need first an update to version 0.9.8.1 with the branch 0.9.8, proceed like that: 'sudo yunohost app upgrade garradin -u https://github.com/YunoHost-Apps/garradin_ynh/tree/0.9.8 --debug' and open your admin page to finalize before next update" - ynh_die "Sorry your version is outdated and need first an update to version 0.9.8.1 with the branch 0.9.8, proceed like that: 'sudo yunohost app upgrade garradin -u https://github.com/YunoHost-Apps/garradin_ynh/tree/0.9.8 --debug' and open your admin page to finalize before next update" +if ynh_compare_current_package_version --comparison lt --version 0.8.5~ynh1; then + upgrade_type="0.8.5" else - upgrade_type=$(ynh_check_app_version_changed) + if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1; then + upgrade_type="0.9.8" + else + upgrade_type=$(ynh_check_app_version_changed) + fi fi #================================================= @@ -72,11 +75,47 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# UPGRADE TO 0.8.5 if necessary +#================================================= + +if [ "$upgrade_type" == "0.8.5" ] +then + ynh_script_progression --message="Upgrading upgrade to 0.8.5" --weight=5 + # Download, check integrity, uncompress and patch the source from 0.8.5.src + ynh_setup_source --dest_dir="$final_path" --source_id="0.8.5" + ynh_add_nginx_config + ynh_add_fpm_config --package="$extra_php_dependencies" + phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + ynh_systemd_action --service_name=nginx --action=reload + #finalyse upgrade + ynh_local_curl "/admin/index.php" + upgrade_type="0.9.8" +fi + +#================================================= +# UPGRADE TO 0.9.8 if necessary +#================================================= + +if [ "$upgrade_type" == "0.9.8" ] +then + ynh_script_progression --message="Upgrading upgrade to 0.9.8" --weight=5 + # Download, check integrity, uncompress and patch the source from 0.9.8.src + ynh_setup_source --dest_dir="$final_path" --source_id="0.9.8" + ynh_add_nginx_config + ynh_add_fpm_config --package="$extra_php_dependencies" + phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + ynh_systemd_action --service_name=nginx --action=reload + #finalyse upgrade + ynh_local_curl "/admin/index.php" + upgrade_type="UPGRADE_APP" +fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=5 + if [ "$upgrade_type" == "UPGRADE_APP" ] then # Download, check integrity, uncompress and patch the source from app.src From eda6b9f3563055fdae338a3d985a563c996eabb3 Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 13:59:27 +0200 Subject: [PATCH 2/9] add local curl at the end of upgrade --- scripts/upgrade | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index acd69fb..e8dddab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -200,6 +200,14 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# Finalise Upgrade +#================================================= + +ynh_script_progression --message="Finalise upgrade" --weight=1 + +ynh_local_curl "/admin/index.php" + #================================================= # END OF SCRIPT #================================================= From 8fe0ba1e7a4d2812447c41221b4dbdfa13319e8b Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 14:19:34 +0200 Subject: [PATCH 3/9] fix bug upgrade old version --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e8dddab..7a4daee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -89,7 +89,7 @@ then phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) ynh_systemd_action --service_name=nginx --action=reload #finalyse upgrade - ynh_local_curl "/admin/index.php" + ynh_local_curl "/admin/upgrade.php" upgrade_type="0.9.8" fi @@ -107,7 +107,7 @@ then phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) ynh_systemd_action --service_name=nginx --action=reload #finalyse upgrade - ynh_local_curl "/admin/index.php" + ynh_local_curl "/admin/upgrade.php" upgrade_type="UPGRADE_APP" fi #================================================= From 24c8cfa286d0b2ea6111058e840d01c92cec26ca Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 14:32:00 +0200 Subject: [PATCH 4/9] fix bug upgrade old version --- scripts/upgrade | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 7a4daee..7896937 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,6 +84,9 @@ then ynh_script_progression --message="Upgrading upgrade to 0.8.5" --weight=5 # Download, check integrity, uncompress and patch the source from 0.8.5.src ynh_setup_source --dest_dir="$final_path" --source_id="0.8.5" + # Set permissions on app files + chown $app:$app $final_path -R + chmod 755 $final_path -R ynh_add_nginx_config ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) @@ -102,6 +105,9 @@ then ynh_script_progression --message="Upgrading upgrade to 0.9.8" --weight=5 # Download, check integrity, uncompress and patch the source from 0.9.8.src ynh_setup_source --dest_dir="$final_path" --source_id="0.9.8" + # Set permissions on app files + chown $app:$app $final_path -R + chmod 755 $final_path -R ynh_add_nginx_config ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) From 3e7b1707b497a8a092fc6c5a81acb59898184110 Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 15:12:22 +0200 Subject: [PATCH 5/9] fix bug upgrade old version --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 7896937..4c37216 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -92,7 +92,7 @@ then phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) ynh_systemd_action --service_name=nginx --action=reload #finalyse upgrade - ynh_local_curl "/admin/upgrade.php" + ynh_local_curl "index.php" upgrade_type="0.9.8" fi @@ -113,7 +113,7 @@ then phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) ynh_systemd_action --service_name=nginx --action=reload #finalyse upgrade - ynh_local_curl "/admin/upgrade.php" + ynh_local_curl "/index.php" upgrade_type="UPGRADE_APP" fi #================================================= From 8e8b49f7578f1a272e1094815d9af4391b911e88 Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 15:33:13 +0200 Subject: [PATCH 6/9] fix bug upgrade old version --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 4c37216..e7bcd58 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -114,6 +114,8 @@ then ynh_systemd_action --service_name=nginx --action=reload #finalyse upgrade ynh_local_curl "/index.php" + sleep 5 + ynh_local_curl "/index.php" upgrade_type="UPGRADE_APP" fi #================================================= From 535d7cce646330e1b86d8aa883b3a7bf258a61c8 Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 15:53:48 +0200 Subject: [PATCH 7/9] fix bug upgrade old version --- scripts/upgrade | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e7bcd58..3feee95 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,16 +24,14 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= -if ynh_compare_current_package_version --comparison lt --version 0.8.5~ynh1; then - upgrade_type="0.8.5" + +if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1; then + upgrade_type="0.9.8" else - if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1; then - upgrade_type="0.9.8" - else - upgrade_type=$(ynh_check_app_version_changed) - fi + upgrade_type=$(ynh_check_app_version_changed) fi + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -75,26 +73,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# UPGRADE TO 0.8.5 if necessary -#================================================= - -if [ "$upgrade_type" == "0.8.5" ] -then - ynh_script_progression --message="Upgrading upgrade to 0.8.5" --weight=5 - # Download, check integrity, uncompress and patch the source from 0.8.5.src - ynh_setup_source --dest_dir="$final_path" --source_id="0.8.5" - # Set permissions on app files - chown $app:$app $final_path -R - chmod 755 $final_path -R - ynh_add_nginx_config - ynh_add_fpm_config --package="$extra_php_dependencies" - phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - ynh_systemd_action --service_name=nginx --action=reload - #finalyse upgrade - ynh_local_curl "index.php" - upgrade_type="0.9.8" -fi #================================================= # UPGRADE TO 0.9.8 if necessary @@ -118,6 +96,7 @@ then ynh_local_curl "/index.php" upgrade_type="UPGRADE_APP" fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= From 43fe3f6e1c8875fa837f876eb4ccd6bef8e1ee5c Mon Sep 17 00:00:00 2001 From: BenoitCier Date: Wed, 31 Mar 2021 16:51:59 +0200 Subject: [PATCH 8/9] fix bug upgrade old version --- scripts/upgrade | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 3feee95..6435c1d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,11 +84,42 @@ then # Download, check integrity, uncompress and patch the source from 0.9.8.src ynh_setup_source --dest_dir="$final_path" --source_id="0.9.8" # Set permissions on app files - chown $app:$app $final_path -R - chmod 755 $final_path -R + ynh_system_user_create --username=$app ynh_add_nginx_config ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + ynh_script_progression --message="restore data..." --weight=10 + + backup_bdd=/tmp/association.sqlite + backup_squelettes=/tmp/squelettes + + if [ -d "$backup_squelettes" ] + then + cp -ar $backup_squelettes $final_path/www/squelettes + ynh_secure_remove $backup_squelettes + fi + + if [ -e "$backup_bdd" ] + then + cp -a $backup_bdd $final_path/association.sqlite + ynh_secure_remove $backup_bdd + fi + + key=$(ynh_string_random --length=50) + cp -a $final_path/config.dist.php $final_path/config.local.php + ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" + if [ "$path_url" == "/" ]; then + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" + else + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" + fi + chown $app:$app $final_path -R + chmod 755 $final_path -R + # Create the visitors permission if needed + if ! ynh_permission_exists --permission "visitors"; then + ynh_permission_create --permission "visitors" + fi + ynh_systemd_action --service_name=nginx --action=reload #finalyse upgrade ynh_local_curl "/index.php" From 3612e5e0c981edc3ae57385fe444af4575275d7b Mon Sep 17 00:00:00 2001 From: BenoitCier <73591305+BenoitCier@users.noreply.github.com> Date: Wed, 31 Mar 2021 17:00:56 +0200 Subject: [PATCH 9/9] Delete 0.8.5.src not implemented --- conf/0.8.5.src | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 conf/0.8.5.src diff --git a/conf/0.8.5.src b/conf/0.8.5.src deleted file mode 100644 index 0bd9166..0000000 --- a/conf/0.8.5.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.8.5.tar.bz2 -SOURCE_SUM=6cd90b806b35386e4d5be98e2db26ca3dbbd32a74538bedefcd9fbad0bfc8d5a -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.bz2 -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=