From 767cfb42b4c855537ee81560313bc931c5242f78 Mon Sep 17 00:00:00 2001 From: Melchisedech Date: Wed, 23 Feb 2022 00:35:54 +0100 Subject: [PATCH 1/4] Restore the .db file after upgrade --- scripts/upgrade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c891f38..01c81e9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -150,8 +150,9 @@ ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE #================================================= -# ... +# TAKE BACK THE OLD digiwords.db file #================================================= +ynh_restore_file -o "/var/www/digiwords/inc/digiwords.db" #================================================= # GENERIC FINALIZATION From 15a4a99871e0e4ce1343b279f493e8abb733a5b8 Mon Sep 17 00:00:00 2001 From: Melchisedech Date: Wed, 23 Feb 2022 23:24:53 +0100 Subject: [PATCH 2/4] Restoring old database after upgrade --- scripts/upgrade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 01c81e9..3887df4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,7 +152,8 @@ ynh_add_fpm_config #================================================= # TAKE BACK THE OLD digiwords.db file #================================================= -ynh_restore_file -o "/var/www/digiwords/inc/digiwords.db" +ynh_script_progression --message="Restoring database..." --time --weight=1 +ynh_restore_file -o "$final_pat/inc/digiwords.db" #================================================= # GENERIC FINALIZATION From ee2ab3888c7a1d14a753a2b81f7b8fbf703410be Mon Sep 17 00:00:00 2001 From: Melchisedech Date: Thu, 24 Feb 2022 00:56:19 +0100 Subject: [PATCH 3/4] Typo in upgrade script --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 3887df4..3610b7a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -153,7 +153,7 @@ ynh_add_fpm_config # TAKE BACK THE OLD digiwords.db file #================================================= ynh_script_progression --message="Restoring database..." --time --weight=1 -ynh_restore_file -o "$final_pat/inc/digiwords.db" +ynh_restore_file -o "$final_path/inc/digiwords.db" #================================================= # GENERIC FINALIZATION From e7a40c3cd0a4b38ef2c2104841fbaf7b1240fca3 Mon Sep 17 00:00:00 2001 From: Melchisedech Date: Thu, 24 Feb 2022 22:26:03 +0100 Subject: [PATCH 4/4] Another try to preserve database when upgrading Following the advises in https://forum.yunohost.org/t/error-in-the-upgrade-script-of-digiwords-fails-ci-tests/18975?u=melchisedech --- scripts/upgrade | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 3610b7a..bc2f4a6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -109,9 +109,24 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --time --weight=1 + + # Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the inc/digiwords.db file to the temp dir + cp -ar "$final_path/inc/digiwords.db" "$tmpdir/digiwords.db" + + # Remove the app directory securely + ynh_secure_remove --file=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" + + # Copy digiwords.db back to the final_path + cp -ar "$tmpdir/digiwords.db" "$final_path/inc/digiwords.db" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi # FIXME: this should be managed by the core in the future @@ -150,10 +165,6 @@ ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE #================================================= -# TAKE BACK THE OLD digiwords.db file -#================================================= -ynh_script_progression --message="Restoring database..." --time --weight=1 -ynh_restore_file -o "$final_path/inc/digiwords.db" #================================================= # GENERIC FINALIZATION