2017-01-05 23:37:07 +01:00
#!/bin/bash
2018-01-31 16:07:43 +01:00
#=================================================
# GENERIC START
#=================================================
2023-12-09 00:35:51 +01:00
# IMPORT GENERIC HELPERS
#=================================================
2018-01-31 16:07:43 +01:00
2023-12-09 00:35:51 +01:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2020-11-17 23:37:38 +01:00
source ../settings/scripts/_common.sh
2024-04-04 00:28:32 +02:00
source ../settings/scripts/experimental_helper.sh
2017-07-21 22:11:45 +02:00
source /usr/share/yunohost/helpers
2024-04-04 00:28:32 +02:00
load_vars
2017-01-05 23:37:07 +01:00
2018-01-31 16:07:43 +01:00
#=================================================
2023-12-09 00:35:51 +01:00
# RESTORE THE DEPENDENCIES
2018-01-31 16:07:43 +01:00
#=================================================
2023-12-09 00:35:51 +01:00
ynh_script_progression --message="Restoring the dependencies..." --weight=1
2018-01-31 16:07:43 +01:00
2023-12-09 00:35:51 +01:00
install_monitorix_package
2024-04-04 00:28:32 +02:00
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd --timeout=15
mkdir -p /var/log/new_"${app}"
mv -t /var/log/new_"${app}" /var/log/monitorix*
mv /var/log/new_"${app}" /var/log/"${app}"
2023-12-09 00:35:51 +01:00
2024-04-04 00:28:32 +02:00
ynh_script_progression --message="Configuring databases access..."
configure_db
2023-12-09 00:35:51 +01:00
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
2024-04-04 00:28:32 +02:00
ynh_script_progression --message="Restoring files" --weight=1
2017-10-31 23:08:23 +01:00
2024-04-04 00:28:32 +02:00
ynh_restore
mkdir -p /var/log/$app
2023-12-09 00:35:51 +01:00
systemctl enable $app.service --quiet
2017-01-05 23:37:07 +01:00
2024-04-04 00:28:32 +02:00
ynh_script_progression --message="Configuring php fpm access if needed..."
if "$phpfpm_installed"; then
config_php_fpm
fi
2023-12-09 00:35:51 +01:00
2024-04-04 00:28:32 +02:00
yunohost service add $app --description="Monitorix" --log="systemd"
2023-01-22 03:09:34 +01:00
2018-01-31 16:07:43 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2019-06-07 23:09:30 +02:00
ynh_script_progression --message="Protecting directory..."
2023-12-09 00:35:51 +01:00
2018-01-29 18:57:10 +01:00
set_permission
2024-04-26 21:41:46 +02:00
ynh_use_logrotate --logfile="/var/log/$app"
2024-04-04 00:28:32 +02:00
2023-12-09 00:35:51 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
2024-04-26 21:41:46 +02:00
ynh_systemd_action --service_name="$app" --action=start --log_path='systemd' --line_match=' - Ok, ready.'
2024-04-04 22:42:20 +02:00
# when we change the value of 'listen [::1]:xxx;' nginx don't reload correctly the config, so force to restart to ensure that the new config are loaded
ynh_systemd_action --service_name=nginx.service --action=restart
2023-12-09 00:35:51 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2017-08-16 14:46:25 +02:00
2023-12-09 00:35:51 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2019-06-07 23:09:30 +02:00
ynh_script_progression --message="Restoration completed for $app" --last