2017-04-21 12:54:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-02-03 01:04:22 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-04-21 12:54:39 +02:00
|
|
|
|
2022-06-16 01:28:41 +02:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2019-02-03 01:04:22 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
2017-04-21 12:54:39 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2019-02-21 12:49:49 +01:00
|
|
|
#=================================================
|
2021-06-20 23:23:08 +02:00
|
|
|
# RESTORE THE APP MAIN DIR
|
2019-02-21 12:49:49 +01:00
|
|
|
#=================================================
|
2021-06-20 23:23:08 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..."
|
|
|
|
|
2023-05-31 20:58:29 +02:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2019-02-21 12:49:49 +01:00
|
|
|
|
2023-05-31 20:58:29 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2019-02-21 12:49:49 +01:00
|
|
|
|
2022-06-16 01:28:41 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2020-04-19 05:16:46 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE POSTGRESQL DATABASE
|
|
|
|
#=================================================
|
2023-05-31 21:08:32 +02:00
|
|
|
ynh_script_progression --message="Restoring the PostregSQL database..."
|
2020-05-28 21:36:47 +02:00
|
|
|
|
2023-06-01 08:37:45 +02:00
|
|
|
#ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
|
|
|
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
2020-04-19 05:16:46 +02:00
|
|
|
|
2019-02-03 01:04:22 +01:00
|
|
|
#=================================================
|
2023-06-01 08:37:45 +02:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2019-02-03 01:04:22 +01:00
|
|
|
#=================================================
|
2023-06-01 08:37:45 +02:00
|
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2019-02-03 01:04:22 +01:00
|
|
|
|
2020-04-19 05:16:46 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
2020-12-08 17:24:16 +01:00
|
|
|
systemctl enable $app.service --quiet
|
2019-02-03 01:04:22 +01:00
|
|
|
|
2022-06-16 01:28:41 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
|
2020-12-08 17:39:43 +01:00
|
|
|
yunohost service add $app --log="/var/log/$app.log" --log="/var/www/$app/log/production.log"
|
2019-02-03 01:04:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2023-06-01 08:37:45 +02:00
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
2019-02-03 01:04:22 +01:00
|
|
|
#=================================================
|
2023-06-01 08:37:45 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at"
|
2019-02-03 01:04:22 +01:00
|
|
|
|
2020-04-19 05:16:46 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-02-21 12:49:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-05-30 15:30:23 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app"
|