#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_psql_test_if_first_run ynh_psql_setup_db --db_user="$db_user_app" --db_name="$db_name_app" --db_pwd="$db_pwd_app" ynh_psql_execute_file_as_root --file="./db_app.sql" --database="$db_name_app" ynh_psql_setup_db --db_user="$db_user_web" --db_name="$db_name_web" --db_pwd="$db_pwd_web" ynh_psql_execute_file_as_root --file="./db_web.sql" --database="$db_name_web" #================================================= # RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring $app's configuration files..." ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_mailman3" yunohost tools regen-conf postfix ynh_systemd_action --service_name=postfix --action="restart" ynh_secure_remove --file="/etc/$app/mailman.cfg" ynh_restore_file --origin_path="/etc/$app/mailman.cfg" ynh_secure_remove --file="/etc/$app/mailman-hyperkitty.cfg" ynh_restore_file --origin_path="/etc/$app/mailman-hyperkitty.cfg" ynh_secure_remove --file="/etc/$app/mailman-web.py" ynh_restore_file --origin_path="/etc/$app/mailman-web.py" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" systemctl enable "$app.service" --quiet systemctl enable "$app-web.service" --quiet yunohost service add "$app" --description="Mailman3 daemon" --log="/var/log/$app/mailman.log" yunohost service add "$app-web" --description="Mailman3 web daemon" --log="/var/log/$app/web/mailman-web.log" #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_systemd_action --service_name="$app" --action=restart ynh_systemd_action --service_name="$app-web" --action=restart ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app"