2023-10-16 21:07:03 +02:00
#!/bin/bash
# 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
2023-12-13 18:57:01 +01:00
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
2024-08-31 03:05:40 +02:00
ynh_script_progression "Reinstalling dependencies..."
2023-12-13 18:57:01 +01:00
2024-08-31 03:05:40 +02:00
ynh_nodejs_install
2023-12-13 18:57:01 +01:00
2023-10-16 21:07:03 +02:00
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
2024-08-31 03:05:40 +02:00
ynh_script_progression "Restoring the app main directory..."
2023-10-16 21:07:03 +02:00
2024-08-31 03:05:40 +02:00
ynh_restore "$install_dir"
2023-10-16 21:07:03 +02:00
2024-08-31 03:05:40 +02:00
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
2023-10-16 21:07:03 +02:00
#=================================================
2023-11-06 20:10:52 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2023-10-16 21:07:03 +02:00
#=================================================
2024-08-31 03:05:40 +02:00
ynh_script_progression "Restoring system configurations related to $app..."
2023-11-03 13:10:12 +01:00
2024-08-31 03:05:40 +02:00
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
2023-10-16 21:07:03 +02:00
2024-08-31 03:05:40 +02:00
ynh_restore "/etc/systemd/system/$app.service"
2023-10-16 21:07:03 +02:00
systemctl enable $app.service --quiet
2023-11-06 20:40:52 +01:00
yunohost service add $app --description="Terraforming-Mars Service" --log="/var/log/$app/$app.log"
2023-10-16 21:07:03 +02:00
2023-10-17 20:50:05 +02:00
mkdir -p "/var/log/$app"
2023-11-06 20:10:52 +01:00
touch "/var/log/$app/$app.log"
2024-08-31 03:05:40 +02:00
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "/var/log/$app"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R u=rwX,g=rX,o= "/var/log/$app"
2023-10-16 21:07:03 +02:00
2024-08-31 03:05:40 +02:00
ynh_restore "/etc/logrotate.d/$app"
2023-10-17 20:50:05 +02:00
#=================================================
2023-11-06 20:10:52 +01:00
# RESTORE THE POSTGRESQL DATABASE
2023-10-17 20:50:05 +02:00
#=================================================
2024-08-31 03:05:40 +02:00
ynh_script_progression "Restoring the PostgreSQL database..."
2023-10-17 20:50:05 +02:00
2024-08-31 03:05:40 +02:00
ynh_psql_db_shell < "./db.sql""
2023-10-16 21:07:03 +02:00
#=================================================
2023-11-06 20:10:52 +01:00
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
2023-10-16 21:07:03 +02:00
#=================================================
2024-08-31 03:05:40 +02:00
ynh_script_progression "Reloading NGINX web server and $app's service..."
2023-11-06 20:10:52 +01:00
2024-08-31 03:05:40 +02:00
ynh_systemctl --service=$app --action="start"
2023-10-16 21:07:03 +02:00
2024-08-31 03:05:40 +02:00
ynh_systemctl --service=nginx --action=reload
2023-10-16 21:07:03 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2024-08-31 03:05:40 +02:00
ynh_script_progression "Restoration completed for $app"