1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pyinventory_ynh.git synced 2024-09-03 20:16:09 +02:00
pyinventory_ynh/scripts/restore

87 lines
2.8 KiB
Bash
Executable file

#!/bin/bash
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression "Restoring the NGINX web server configuration..."
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring $app main directory..."
ynh_restore "$install_dir"
ynh_restore "$data_dir"
ynh_script_progression "Set file permissions..."
myynh_fix_file_permissions
#=================================================
# PYTHON VIRTUALENV
# Maybe the backup contains a other Python version
#=================================================
ynh_script_progression "Create and setup Python virtualenv..."
myynh_setup_python_venv
#=================================================
# RESTORE THE PostgreSQL DATABASE
#=================================================
ynh_script_progression "Restoring the PostgreSQL database..."
ynh_psql_db_shell < ./db.sql
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression "Restoring the systemd $app configuration..."
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add $app
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression "Setup logging..."
myynh_setup_log_file
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression "Set file permissions..."
myynh_fix_file_permissions
#=================================================
# START PYINVENTORY
#=================================================
ynh_script_progression "Starting systemd service '$app'..."
ynh_systemctl --service=$app --action="start" --log_path="$log_file"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression "Reloading nginx web server..."
ynh_systemctl --service="nginx" --action="reload"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Restoration completed for $app"