From de249fb16b5707f3a22cbb32f083d0d259396e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 6 Jul 2022 06:43:15 +0200 Subject: [PATCH] Upgrade (#68) (#69) * Apply example_ynh * Fix melange-de-versions https://forum.yunohost.org/t/melange-de-versions-de-moodle-detectees/19985 * Update manifest.json * Auto-update README Co-authored-by: yunohost-bot Co-authored-by: yalh76 Co-authored-by: yunohost-bot --- README.md | 2 +- README_fr.md | 2 +- manifest.json | 2 +- scripts/change_url | 4 ++++ scripts/restore | 3 +-- scripts/upgrade | 18 ++++++++++++++++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7bfb6ef..d85ec37 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Moodle is widely used around the world by universities, schools, companies and all manner of organisations and individuals. -**Shipped version:** 4.0.1~ynh2 +**Shipped version:** 4.0.1~ynh3 **Demo:** https://sandbox.moodledemo.net/ diff --git a/README_fr.md b/README_fr.md index c0aa963..43fd44d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -20,7 +20,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Moodle est largement utilisé dans le monde entier par les universités, les écoles, les entreprises et toutes sortes d'organisations et d'individus. -**Version incluse :** 4.0.1~ynh2 +**Version incluse :** 4.0.1~ynh3 **Démo :** https://sandbox.moodledemo.net/ diff --git a/manifest.json b/manifest.json index d412fb9..67e91f9 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Online learning platform", "fr": "Plateforme d'apprentissage en ligne" }, - "version": "4.0.1~ynh2", + "version": "4.0.1~ynh3", "url": "https://moodle.org/", "upstream": { "license": "GPL-3.0-or-later", diff --git a/scripts/change_url b/scripts/change_url index c4d9d1b..99e8e31 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -108,12 +108,16 @@ domain=${new_domain%/} path=${new_path%/} dir="__DIR__" +ynh_backup_if_checksum_is_different --file="$final_path/config.php" + if [ "$new_path" == "/" ]; then ynh_add_config --template="../conf/config-domain.php" --destination="$final_path/config.php" else ynh_add_config --template="../conf/config-path.php" --destination="$final_path/config.php" fi +ynh_store_file_checksum --file="$final_path/config.php" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/restore b/scripts/restore index 3c61a99..931c5ee 100644 --- a/scripts/restore +++ b/scripts/restore @@ -20,7 +20,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -59,7 +59,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" -# Restore permissions on app files chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 0a88f8e..2bfcf9e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -109,9 +109,23 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=6 + # Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the config file in the temp dir + cp -a "$final_path/config.php" "$tmpdir/config.php" + + # 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" --keep="$final_path/config.php" - #php${phpversion} $final_path/admin/cli/upgrade.php + ynh_setup_source --dest_dir="$final_path" + + # Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/config.php" "$final_path/config.php" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi chmod 750 "$final_path"