mirror of
https://github.com/YunoHost-Apps/fittrackee_ynh.git
synced 2024-09-03 18:36:16 +02:00
82 lines
2.8 KiB
Bash
82 lines
2.8 KiB
Bash
#!/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
|
|
|
|
db_name=$(ynh_app_setting_get --key=db_name)
|
|
|
|
#=================================================
|
|
# STANDARD RESTORATION STEPS
|
|
#=================================================
|
|
# RESTORE LOGROTATE
|
|
#=================================================
|
|
ynh_script_progression "Configuring logrotate to manage application logfiles"
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_config_add_logrotate
|
|
touch /var/log/$app/$app.log
|
|
touch /var/log/$app/${app}_workers.log
|
|
chown -R $app:www-data /var/log/$app/
|
|
|
|
#=================================================
|
|
# 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 POSTGRESQL DATABASE
|
|
#=================================================
|
|
ynh_script_progression "Restoring the PostgreSQL database..."
|
|
|
|
ynh_psql_db_shell < "./db.sql"
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression "Restoring the app main directory..."
|
|
|
|
ynh_restore "$install_dir"
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression "Restoring $app's systemd service..."
|
|
|
|
ynh_restore "/etc/systemd/system/${app}.service"
|
|
ynh_restore "/etc/systemd/system/${app}_workers.service"
|
|
|
|
systemctl enable "${app}.service" --quiet
|
|
systemctl enable "${app}_workers.service" --quiet
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression "Integrating service in YunoHost..."
|
|
|
|
yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.log"
|
|
yunohost service add "${app}_workers" --description="Fittrackee task queue service" --log="var/log/$app/${app}_workers.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Starting $app's systemd service..."
|
|
|
|
ynh_systemctl --service="${app}" --action="start"
|
|
|
|
ynh_systemctl --service="${app}_workers" --action="start"
|
|
|
|
#=================================================
|
|
# 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"
|