django-for-runners_ynh/scripts/restore

98 lines
3.4 KiB
Text
Raw Normal View History

2020-12-12 19:37:20 +01: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
2020-12-12 19:37:20 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
2022-09-18 19:00:39 +02:00
ynh_script_progression --message="Restoring $app main directory..."
2020-12-12 19:37:20 +01:00
ynh_restore_file --origin_path="$install_dir"
ynh_restore_file --origin_path="$data_dir"
2020-12-12 19:37:20 +01:00
ynh_script_progression --message="Set file permissions..."
myynh_fix_file_permissions
2020-12-12 19:37:20 +01:00
2021-10-10 14:35:06 +02:00
#=================================================
2022-09-18 19:00:39 +02:00
# PYTHON VIRTUALENV
2021-10-10 14:35:06 +02:00
# Maybe the backup contains a other Python version
#=================================================
ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45
2022-04-15 16:38:10 +02:00
myynh_setup_python_venv
2021-10-10 14:35:06 +02:00
2020-12-12 19:37:20 +01:00
#=================================================
# RESTORE THE PostgreSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=5
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd $app configuration..."
2020-12-12 19:37:20 +01: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
2020-12-12 19:37:20 +01:00
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Setup logging..."
2020-12-12 19:37:20 +01:00
myynh_setup_log_file
2020-12-12 19:37:20 +01: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
2020-12-12 19:37:20 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# START PYINVENTORY
#=================================================
2022-09-18 17:49:33 +02:00
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5
2020-12-12 19:37:20 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path="$log_file"
2020-12-12 19:37:20 +01:00
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name="nginx" --action="reload"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last