2017-04-01 18:16:18 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-03-03 18:04:55 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-04-01 18:16:18 +02:00
|
|
|
|
2022-01-27 02:40:24 +01:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2019-03-03 18:04:55 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
2017-04-01 18:16:18 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2021-05-08 23:38:59 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the app main directory..."
|
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2021-05-08 23:38:59 +02:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2022-06-16 19:19:38 +02:00
|
|
|
|
2019-03-03 18:04:55 +01:00
|
|
|
#=================================================
|
2020-04-20 04:16:40 +02:00
|
|
|
# RESTORE THE POSTGRESQL DATABASE
|
|
|
|
#=================================================
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Restoring the PostregSQL database..."
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2020-06-03 21:07:49 +02:00
|
|
|
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2022-01-27 02:40:24 +01:00
|
|
|
#=================================================
|
2023-04-21 19:11:39 +02:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
2022-01-27 02:40:24 +01:00
|
|
|
#=================================================
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2022-01-27 02:40:24 +01:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2022-01-27 02:40:24 +01:00
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
2019-03-03 18:04:55 +01:00
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
2020-12-13 21:16:52 +01:00
|
|
|
systemctl enable $app.service --quiet
|
2019-03-03 18:04:55 +01:00
|
|
|
|
2022-01-27 02:40:24 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
|
2023-04-21 19:11:39 +02:00
|
|
|
yunohost service add $app --description="Lufi service" --log="$install_dir/log/production.log"
|
2020-04-20 04:16:40 +02:00
|
|
|
|
2019-03-03 18:04:55 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2023-04-21 19:11:39 +02:00
|
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
2019-03-03 18:04:55 +01:00
|
|
|
#=================================================
|
2023-04-21 19:11:39 +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="$install_dir/log/production.log" --line_match="Creating process id file"
|
2019-03-03 18:04:55 +01:00
|
|
|
|
2020-04-20 04:16:40 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-03-03 18:04:55 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-05-30 16:34:01 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app"
|