mirror of
https://github.com/YunoHost-Apps/monitorix_ynh.git
synced 2024-09-03 19:46:06 +02:00
70 lines
2.5 KiB
Bash
Executable file
70 lines
2.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
source ../settings/scripts/_common.sh
|
|
source ../settings/scripts/experimental_helper.sh
|
|
source /usr/share/yunohost/helpers
|
|
load_vars
|
|
|
|
#=================================================
|
|
# RESTORE THE DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the dependencies..." --weight=1
|
|
|
|
install_monitorix_package
|
|
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}"
|
|
|
|
ynh_script_progression --message="Configuring databases access..."
|
|
configure_db
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring files" --weight=1
|
|
|
|
ynh_restore
|
|
mkdir -p /var/log/$app
|
|
systemctl enable $app.service --quiet
|
|
|
|
ynh_script_progression --message="Configuring php fpm access if needed..."
|
|
if "$phpfpm_installed"; then
|
|
config_php_fpm
|
|
fi
|
|
|
|
yunohost service add $app --description="Monitorix" --log="systemd"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
ynh_script_progression --message="Protecting directory..."
|
|
|
|
set_permission
|
|
|
|
ynh_use_logrotate --logfile "/var/log/$app"
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
ynh_systemd_action --service_name="$app" --action=start --log_path 'systemd' --line_match ' - Ok, ready.'
|
|
# 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
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|