2024-08-27 20:51:05 +02:00
|
|
|
#!/bin/bash
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
2022-04-02 17:44:57 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2022-04-02 17:44:57 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_script_progression --message="Restoring $app main directory..."
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-03-28 22:18:52 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_restore_file --origin_path="$data_dir"
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_script_progression --message="Set file permissions..."
|
|
|
|
myynh_fix_file_permissions
|
2022-04-02 17:44:57 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
# PYTHON VIRTUALENV
|
|
|
|
# Maybe the backup contains a other Python version
|
2022-04-02 17:44:57 +02:00
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
myynh_setup_python_venv
|
2022-04-02 17:44:57 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
# RESTORE THE PostgreSQL DATABASE
|
2022-04-02 17:44:57 +02:00
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
2022-04-02 17:44:57 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
# RESTORE SYSTEMD
|
2022-04-02 17:44:57 +02:00
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_script_progression --message="Restoring the systemd $app configuration..."
|
2022-04-02 17:44:57 +02:00
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
2024-08-27 20:51:05 +02:00
|
|
|
systemctl enable $app.service --quiet
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
|
|
|
|
|
|
yunohost service add --description $app $app
|
2022-04-02 17:44:57 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
# RESTORE THE LOGROTATE CONFIGURATION
|
2022-04-02 17:44:57 +02:00
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_script_progression --message="Setup logging..."
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
myynh_setup_log_file
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Set file permissions..."
|
|
|
|
myynh_fix_file_permissions
|
2022-04-02 17:44:57 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# START PYINVENTORY
|
2022-04-02 17:44:57 +02:00
|
|
|
#=================================================
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="$log_file"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading nginx web server..."
|
2022-04-02 17:44:57 +02:00
|
|
|
|
2024-08-27 20:51:05 +02:00
|
|
|
ynh_systemd_action --service_name="nginx" --action="reload"
|
2022-04-02 17:44:57 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|