From a5149807453b93fe164ed086c15de18a8eb999a7 Mon Sep 17 00:00:00 2001 From: Dante Date: Mon, 11 Dec 2023 12:27:40 +0000 Subject: [PATCH] Fix restore script, order of restoring steps matters --- scripts/restore | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/restore b/scripts/restore index 5260e45..b2dea92 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,7 +31,7 @@ ynh_restore_file --origin_path="$install_dir" chmod 750 "$install_dir" chmod -R 750 "$install_dir" -chown -R $app:$app "$install_dir" +chown -R "$app:$app" "$install_dir" #================================================= # SPECIFIC RESTORATION @@ -40,26 +40,27 @@ chown -R $app:$app "$install_dir" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8 -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name - -#================================================= -# REGISTER SYNAPSE APP-SERVICE -#================================================= -ynh_script_progression --message="Registering Synapse app-service" --weight=1 - -$install_dir/bin/python3 -m mautrix_telegram -g -c $install_dir/config.yaml -r "etc/matrix-$synapse_instance/app-service/$app.yaml" -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || echo "Synapse can't restart with the appservice configuration" +ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= +# This section has to be always above REGISTER SYNAPSE APP-SERVICE section in order to restore successfully ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" mkdir -p "/var/log/$app" chmod -R 600 "/var/log/$app" chmod 700 "/var/log/$app" -chown -R $app:$app /var/log/$app +chown -R "$app:$app" "/var/log/$app" + +#================================================= +# REGISTER SYNAPSE APP-SERVICE +#================================================= +ynh_script_progression --message="Registering Synapse app-service" --weight=1 + +$install_dir/bin/python3 -m mautrix_telegram -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml" +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || echo "Synapse can't restart with the appservice configuration" #================================================= # RESTORE SYSTEMD