From 218805413f2cd00a6b532bfea6b4c141e44da84a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sat, 16 Sep 2023 09:41:20 +0200 Subject: [PATCH 01/16] Clean backup data upgrade --- scripts/upgrade | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 35af4c2..2c2a21e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,9 +34,8 @@ fi #================================================= ynh_script_progression --message="Backup of the DB in temporary file...." --weight=5 -if [ -f "$install_dir/data/association.sqlite" ];then -cp -a $install_dir/data/association.sqlite /tmp/ -fi +# copy data directory bacckup +cp -a $install_dir/data /tmp/data #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -85,10 +84,8 @@ fi ynh_add_config --template="config.local.php" --destination="$install_dir/config.local.php" ynh_add_config --template="config.local.yunohost.php" --destination="$install_dir/config.local.yunohost.php" -# Restore the sqlite DB -if [ -f "/tmp/association.sqlite" ];then -mv /tmp/association.sqlite $install_dir/data -fi +# Sync data directory backup +rsync -R /tmp/data/ $install_dir/data/ # Permissions on files and directories chmod -R o-rwx "$install_dir" @@ -115,6 +112,6 @@ sleep 5 # END OF SCRIPT #================================================= # remove directory duplicated -ynh_secure_remove --file="$install_dir/data/data" +ynh_secure_remove --file="/tmp/data" ynh_script_progression --message="Upgrade of $app completed" --last From c8d6fbdbe8e901ff2cd3661d291fb911ddca40bf Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sat, 16 Sep 2023 09:52:34 +0200 Subject: [PATCH 02/16] cleaning code upgrade --- scripts/upgrade | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2c2a21e..614bab4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,11 +30,11 @@ if [[ -z "${secret_key:-}" ]]; then fi #================================================= -# BACKUP SQLITE DATABASE +# BACKUP SQLITE DATABASE AND DATAS #================================================= ynh_script_progression --message="Backup of the DB in temporary file...." --weight=5 -# copy data directory bacckup +# copy data directory backup cp -a $install_dir/data /tmp/data #================================================= @@ -84,9 +84,19 @@ fi ynh_add_config --template="config.local.php" --destination="$install_dir/config.local.php" ynh_add_config --template="config.local.yunohost.php" --destination="$install_dir/config.local.yunohost.php" +#================================================= +# RESTORE BACKUP SQLITE DATABASE AND DATAS +#================================================= +ynh_script_progression --message="Restore datas..." --weight=5 + # Sync data directory backup rsync -R /tmp/data/ $install_dir/data/ +#================================================= +# FIX PERMISSIONS +#================================================= +ynh_script_progression --message="Fix permissions..." --weight=2 + # Permissions on files and directories chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -108,10 +118,11 @@ sleep 5 ynh_local_curl "/index.php" sleep 5 -#================================================= -# END OF SCRIPT -#================================================= # remove directory duplicated ynh_secure_remove --file="/tmp/data" +#================================================= +# END OF SCRIPT +#================================================= + ynh_script_progression --message="Upgrade of $app completed" --last From c22540cb1c84395b6ac79e3bc497d347d3c7d032 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sat, 16 Sep 2023 09:53:44 +0200 Subject: [PATCH 03/16] Update manifest.toml fix this version for upgrade --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 0264ed4..7fa5c73 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Paheko" description.en = "Software to manage association" description.fr = "Logiciel libre de gestion d'association" -version = "1.2.11~ynh4" +version = "1.2.11~ynh5" maintainers = ["rodinux"] From 38f13283f3a4524d79bb9f69505f6ccc6d1a2a4d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 16 Sep 2023 07:53:47 +0000 Subject: [PATCH 04/16] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e741c83..6ff18f5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Paheko (we chose the name Paheko, a word from the Māori language meaning "to co It is the tool of choice for managing an association, a sports club, an NGO, etc. It is designed to meet the needs of a small to medium-sized structure: management of members, accounting, website, note-taking in meetings, archiving and sharing of the association's operating documents, discussion between members, etc. etc.. -**Shipped version:** 1.2.11~ynh4 +**Shipped version:** 1.2.11~ynh5 **Demo:** https://paheko.cloud/essai/ diff --git a/README_fr.md b/README_fr.md index 4595c62..f0ee807 100644 --- a/README_fr.md +++ b/README_fr.md @@ -30,7 +30,7 @@ Paheko (Nous avons choisi le nom Paheko, un mot de la langue Māori qui signifie ![Logo Paheko](https://master.garradin.eu/garradin-devient-paheko/logo_v3_small-fs8.png) -**Version incluse :** 1.2.11~ynh4 +**Version incluse :** 1.2.11~ynh5 **Démo :** https://paheko.cloud/essai/ From 74cd032fef6d926bc3621895d89eb3985115aef0 Mon Sep 17 00:00:00 2001 From: rodinux Date: Mon, 18 Sep 2023 14:33:58 +0200 Subject: [PATCH 05/16] secure temporary directory for data --- scripts/upgrade | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 614bab4..840dfb3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,7 +35,8 @@ fi ynh_script_progression --message="Backup of the DB in temporary file...." --weight=5 # copy data directory backup -cp -a $install_dir/data /tmp/data +file=$(mktemp -d $app_dataXXX --suffix=BKP) +cp -a $install_dir/data /var/www/$file #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -90,7 +91,7 @@ ynh_add_config --template="config.local.yunohost.php" --destination="$install_di ynh_script_progression --message="Restore datas..." --weight=5 # Sync data directory backup -rsync -R /tmp/data/ $install_dir/data/ +rsync -R /var/www/$file/ $install_dir/data/ #================================================= # FIX PERMISSIONS @@ -119,7 +120,7 @@ ynh_local_curl "/index.php" sleep 5 # remove directory duplicated -ynh_secure_remove --file="/tmp/data" +ynh_secure_remove --file="/var/www/$file" #================================================= # END OF SCRIPT From 454a3de4ba0ef8791a1d23cd85935822ecfea9ac Mon Sep 17 00:00:00 2001 From: rodinux Date: Mon, 18 Sep 2023 20:30:41 +0200 Subject: [PATCH 06/16] fix secure temporally file for backup data folder --- scripts/upgrade | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 840dfb3..08ae68e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,8 +35,8 @@ fi ynh_script_progression --message="Backup of the DB in temporary file...." --weight=5 # copy data directory backup -file=$(mktemp -d $app_dataXXX --suffix=BKP) -cp -a $install_dir/data /var/www/$file +tmp_data_backup=$(mktemp -d) +rsync -a $install_dir/data/ $tmp_data_backup/ #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -91,7 +91,7 @@ ynh_add_config --template="config.local.yunohost.php" --destination="$install_di ynh_script_progression --message="Restore datas..." --weight=5 # Sync data directory backup -rsync -R /var/www/$file/ $install_dir/data/ +rsync -a $tmp_data_backup/ $install_dir/data/ #================================================= # FIX PERMISSIONS @@ -119,8 +119,8 @@ sleep 5 ynh_local_curl "/index.php" sleep 5 -# remove directory duplicated -ynh_secure_remove --file="/var/www/$file" +# remove data directory backup +ynh_secure_remove --file="$tmp_data_backup" #================================================= # END OF SCRIPT From 5fb2427c9315f0bb72c65872c86835709bdbe67c Mon Sep 17 00:00:00 2001 From: rodinux Date: Mon, 18 Sep 2023 20:44:46 +0200 Subject: [PATCH 07/16] keep only the file for config.local.user.php --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 08ae68e..4b99aab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -47,7 +47,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --keep="association.sqlite data config.local.user.php" --full_replace=1 + ynh_setup_source --dest_dir="$install_dir" --keep="config.local.user.php" --full_replace=1 fi chmod -R o-rwx "$install_dir" From 01d57e29832e49baa7bdb4632322ed59ac85c9df Mon Sep 17 00:00:00 2001 From: rodinux Date: Mon, 18 Sep 2023 22:09:52 +0200 Subject: [PATCH 08/16] try also keep the file config.local.user.php --- conf/config.local.php | 2 +- conf/config.local.yunohost.php | 2 +- scripts/install | 4 ++-- scripts/restore | 5 +++++ scripts/upgrade | 13 +++++++++---- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/conf/config.local.php b/conf/config.local.php index 0080731..11a00bf 100644 --- a/conf/config.local.php +++ b/conf/config.local.php @@ -6,4 +6,4 @@ * Pour ajouter vos configurations personnalisées, rendez-vous dans le fichier config.local.user.php */ require '__INSTALL_DIR__/config.local.yunohost.php'; -require '__INSTALL_DIR__/config.local.user.php'; +require '__INSTALL_DIR__/data/config.local.user.php'; diff --git a/conf/config.local.yunohost.php b/conf/config.local.yunohost.php index 41849cf..3cd4e76 100644 --- a/conf/config.local.yunohost.php +++ b/conf/config.local.yunohost.php @@ -5,7 +5,7 @@ * * Ce fichier sera mis à jour à chaque nouvelle version de Yunohost * - * Pour ajouter vos configurations personnalisées, rendez-vous dans le fichier config.local.user.php + * Pour ajouter vos configurations personnalisées, rendez-vous dans le fichier data/config.local.user.php * */ diff --git a/scripts/install b/scripts/install index d76907c..eaf582e 100644 --- a/scripts/install +++ b/scripts/install @@ -50,7 +50,7 @@ ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key # Install configuration files ynh_add_config --template="config.local.php" --destination="$install_dir/config.local.php" ynh_add_config --template="config.local.yunohost.php" --destination="$install_dir/config.local.yunohost.php" -ynh_add_config --template="config.local.user.php" --destination="$install_dir/config.local.user.php" +ynh_add_config --template="config.local.user.php" --destination="$install_dir/data/config.local.user.php" # Permissions on files and directories chmod -R o-rwx "$install_dir" @@ -61,7 +61,7 @@ find "$install_dir/data" -type d -exec chmod 770 {} + find "$install_dir/data" -type f -exec chmod 660 {} + chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" -chmod 660 "$install_dir/config.local.user.php" +chmod 660 "$install_dir/data/config.local.user.php" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index c1ab315..dc0c5de 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,7 +26,12 @@ find "$install_dir/data" -type d -exec chmod 770 {} + find "$install_dir/data" -type f -exec chmod 660 {} + chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" + +if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then chmod 660 "$install_dir/config.local.user.php" +else +chmod 660 "$install_dir/data/config.local.user.php" +fi #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 4b99aab..417f46d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,14 +30,19 @@ if [[ -z "${secret_key:-}" ]]; then fi #================================================= -# BACKUP SQLITE DATABASE AND DATAS +# BACKUP DATABASE, DATAS AND CONFIG LOCAL USER #================================================= ynh_script_progression --message="Backup of the DB in temporary file...." --weight=5 + # copy data directory backup tmp_data_backup=$(mktemp -d) rsync -a $install_dir/data/ $tmp_data_backup/ +if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then + mv $install_dir/config.local.user.php $tmp_data_backup/ +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -47,7 +52,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --keep="config.local.user.php" --full_replace=1 + ynh_setup_source --dest_dir="$install_dir" --full_replace=1 fi chmod -R o-rwx "$install_dir" @@ -78,7 +83,7 @@ ynh_script_progression --message="Updating a configuration file..." --weight=5 if ynh_compare_current_package_version --comparison lt --version 1.1.15~ynh1; then chmod 750 "$install_dir/config.local.user.php" - ynh_add_config --template="config.local.user.php" --destination="$install_dir/config.local.user.php" + ynh_add_config --template="config.local.user.php" --destination="$install_dir/data/config.local.user.php" fi # NOTE: Don't overwrite config.local.user.php @@ -107,7 +112,7 @@ find "$install_dir/data" -type d -exec chmod 770 {} + find "$install_dir/data" -type f -exec chmod 660 {} + chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" -chmod 660 "$install_dir/config.local.user.php" +chmod 660 "$install_dir/data/config.local.user.php" #================================================= # FINALISE UPGRADE From dc90c24f609f79c70404c335636ea8d937b5d8a4 Mon Sep 17 00:00:00 2001 From: rodinux Date: Tue, 19 Sep 2023 09:14:43 +0200 Subject: [PATCH 09/16] ready to merge --- conf/config.local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.local.php b/conf/config.local.php index 11a00bf..8fb3a75 100644 --- a/conf/config.local.php +++ b/conf/config.local.php @@ -3,7 +3,7 @@ /** * NE PAS MODIFIER CE FICHIER. Il est regénéré automatiquement à chaque mise à jour de Yunohost * - * Pour ajouter vos configurations personnalisées, rendez-vous dans le fichier config.local.user.php + * Pour ajouter vos configurations personnalisées, rendez-vous dans le fichier data/config.local.user.php */ require '__INSTALL_DIR__/config.local.yunohost.php'; require '__INSTALL_DIR__/data/config.local.user.php'; From 95e251271c2d4b7678bc30930c63447f3d1554d0 Mon Sep 17 00:00:00 2001 From: rodinux Date: Tue, 19 Sep 2023 10:03:52 +0200 Subject: [PATCH 10/16] correct varaible for YNH_APP_CURRENT_VERSION --- scripts/restore | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index dc0c5de..f1954e1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,7 +27,7 @@ find "$install_dir/data" -type f -exec chmod 660 {} + chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" -if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then +if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh1; then chmod 660 "$install_dir/config.local.user.php" else chmod 660 "$install_dir/data/config.local.user.php" diff --git a/scripts/upgrade b/scripts/upgrade index 417f46d..dcf2bf2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,7 +39,7 @@ ynh_script_progression --message="Backup of the DB in temporary file...." --weig tmp_data_backup=$(mktemp -d) rsync -a $install_dir/data/ $tmp_data_backup/ -if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then +if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh1; then mv $install_dir/config.local.user.php $tmp_data_backup/ fi From 01de0e7c06324c540f58a5c48af7290e8dfb7f8b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 19 Sep 2023 17:58:07 +0200 Subject: [PATCH 11/16] version for comparison --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index f1954e1..dc0c5de 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,7 +27,7 @@ find "$install_dir/data" -type f -exec chmod 660 {} + chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" -if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh1; then +if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then chmod 660 "$install_dir/config.local.user.php" else chmod 660 "$install_dir/data/config.local.user.php" From 17d68b59bba19705973fd8c30a0556c6d99fe92a Mon Sep 17 00:00:00 2001 From: rodinux Date: Tue, 19 Sep 2023 18:01:14 +0200 Subject: [PATCH 12/16] try fix comparison version existing --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index dcf2bf2..417f46d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,7 +39,7 @@ ynh_script_progression --message="Backup of the DB in temporary file...." --weig tmp_data_backup=$(mktemp -d) rsync -a $install_dir/data/ $tmp_data_backup/ -if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh1; then +if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then mv $install_dir/config.local.user.php $tmp_data_backup/ fi From b616fa00463110f52de3666d0363fab8b71f0670 Mon Sep 17 00:00:00 2001 From: rodinux Date: Tue, 19 Sep 2023 18:27:06 +0200 Subject: [PATCH 13/16] mv when needed config.local.user.php --- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/restore b/scripts/restore index dc0c5de..bf5d4cf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,8 +27,8 @@ find "$install_dir/data" -type f -exec chmod 660 {} + chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" -if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then -chmod 660 "$install_dir/config.local.user.php" +if [[ $install_dir/config.local.user.php -f ]]; then +chmod 660 $install_dir/config.local.user.php else chmod 660 "$install_dir/data/config.local.user.php" fi diff --git a/scripts/upgrade b/scripts/upgrade index 417f46d..761d225 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,8 +39,8 @@ ynh_script_progression --message="Backup of the DB in temporary file...." --weig tmp_data_backup=$(mktemp -d) rsync -a $install_dir/data/ $tmp_data_backup/ -if ynh_compare_current_package_version --comparison le --version 1.2.11~ynh4; then - mv $install_dir/config.local.user.php $tmp_data_backup/ +if [[ $install_dir/config.local.user.php -f ]]; then + cp -a $install_dir/config.local.user.php $tmp_data_backup/ fi #================================================= From 7e1f23973b29398311b2222c0bd0cb7686141478 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 19 Sep 2023 18:33:08 +0200 Subject: [PATCH 14/16] add quotes --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index bf5d4cf..95a920e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -28,7 +28,7 @@ chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" if [[ $install_dir/config.local.user.php -f ]]; then -chmod 660 $install_dir/config.local.user.php +chmod 660 "$install_dir/config.local.user.php" else chmod 660 "$install_dir/data/config.local.user.php" fi From db2c97fbccbcdaea586a8189d8f82a3b2f4d5df5 Mon Sep 17 00:00:00 2001 From: rodinux Date: Tue, 19 Sep 2023 19:45:33 +0200 Subject: [PATCH 15/16] mfix needed config.local.user.php change place --- scripts/restore | 4 +--- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/restore b/scripts/restore index 95a920e..be63aa6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,10 +27,8 @@ find "$install_dir/data" -type f -exec chmod 660 {} + chmod 440 "$install_dir/config.local.php" chmod 440 "$install_dir/config.local.yunohost.php" -if [[ $install_dir/config.local.user.php -f ]]; then +if [ -f "$install_dir/config.local.user.php" ]; then chmod 660 "$install_dir/config.local.user.php" -else -chmod 660 "$install_dir/data/config.local.user.php" fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 761d225..d5035cc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,7 +39,7 @@ ynh_script_progression --message="Backup of the DB in temporary file...." --weig tmp_data_backup=$(mktemp -d) rsync -a $install_dir/data/ $tmp_data_backup/ -if [[ $install_dir/config.local.user.php -f ]]; then +if [ -f "$install_dir/config.local.user.php" ]; then cp -a $install_dir/config.local.user.php $tmp_data_backup/ fi From f443760a510b468b2b92abfa307987e04afe59ad Mon Sep 17 00:00:00 2001 From: rodinux Date: Wed, 20 Sep 2023 00:03:36 +0200 Subject: [PATCH 16/16] remove old duplicated files unused --- scripts/upgrade | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index d5035cc..73600b3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -127,6 +127,11 @@ sleep 5 # remove data directory backup ynh_secure_remove --file="$tmp_data_backup" +# clean duplicate folder if exist +if [ -d "$install_dir/data/data" ] + ynh_secure_remove --file="$install_dir/data/data" +fi + #================================================= # END OF SCRIPT #=================================================