1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/django-fmd_ynh.git synced 2024-09-03 18:26:27 +02:00
django-fmd_ynh/scripts/restore

98 lines
3.4 KiB
Text
Raw Normal View History

2022-07-11 20:34:24 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# 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-07-11 20:34:24 +02:00
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring $app main directory..."
2022-07-11 20:34:24 +02:00
2024-01-18 21:02:26 +01:00
ynh_restore_file --origin_path="$install_dir"
ynh_restore_file --origin_path="$data_dir"
2022-07-11 20:34:24 +02:00
ynh_script_progression --message="Set file permissions..."
myynh_fix_file_permissions
2022-07-11 20:34:24 +02:00
#=================================================
# PYTHON VIRTUALENV
# Maybe the backup contains a other Python version
2022-07-11 20:34:24 +02:00
#=================================================
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
2022-07-11 20:34:24 +02:00
myynh_setup_python_venv
2022-07-11 20:34:24 +02:00
#=================================================
# RESTORE THE PostgreSQL DATABASE
2022-07-11 20:34:24 +02:00
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
2022-07-11 20:34:24 +02:00
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
2022-07-11 20:34:24 +02:00
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd $app configuration..."
2022-07-11 20:34:24 +02:00
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Setup logging..."
2022-07-11 20:34:24 +02:00
myynh_setup_log_file
2022-07-11 20:34:24 +02:00
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-07-11 20:34:24 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# START PYINVENTORY
2022-07-11 20:34:24 +02:00
#=================================================
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
2022-07-11 20:34:24 +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-07-11 20:34:24 +02:00
ynh_systemd_action --service_name="nginx" --action="reload"
2022-07-11 20:34:24 +02:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last