1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/joomla_ynh.git synced 2024-09-03 19:26:34 +02:00

Backup config file before upgrade and restore it

This commit is contained in:
jarod5001 2022-06-07 10:23:05 +01:00 committed by GitHub
parent ba1e9a0b98
commit 6e55e9cac0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,6 +47,17 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# BACKUP CONFIGURATION FILE
#=================================================
ynh_script_progression --message="Backing up configuration file..."
# Create a temporary directory
tmpdir="$(ynh_smart_mktemp min_size=3)"
# Backup the config file in the temp dir
cp -a "$final_path/configuration.php" "$tmpdir/configuration.php"
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -116,11 +127,15 @@ ynh_add_fpm_config
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# UPDATE A CONFIG FILE # RESTORE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Restoring configuration file..."
ynh_add_config --template="../conf/configuration.php" --destination="$final_path/configuration.php" #ynh_add_config --template="../conf/configuration.php" --destination="$final_path/configuration.php"
# Restore config file
mv -f "$tmpdir/configuration.php" "$final_path/configuration.php"
ynh_secure_remove --file="$tmpdir"
chmod 400 "$final_path/configuration.php" chmod 400 "$final_path/configuration.php"
chown $app:$app "$final_path/configuration.php" chown $app:$app "$final_path/configuration.php"