2017-01-05 23:37:07 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-17 23:37:38 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ../settings/scripts/experimental_helper.sh
|
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-01-31 21:26:13 +01:00
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
2017-01-31 21:26:13 +01:00
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Loading settings..."
|
|
|
|
|
2017-01-05 23:37:07 +01:00
|
|
|
# Retrieve old app settings
|
2019-06-07 23:09:30 +02:00
|
|
|
domain=$(ynh_app_setting_get --app $app --key domain)
|
|
|
|
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
|
2021-02-17 23:12:09 +01:00
|
|
|
# Creating the folder
|
|
|
|
mkdir -p /var/lib/monitorix/www/imgs
|
2021-02-18 19:07:39 +01:00
|
|
|
mkdir -p /etc/monitorix/conf.d/
|
|
|
|
touch /etc/monitorix/conf.d/00-debian.conf
|
2021-02-17 23:12:09 +01:00
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
# Install package
|
|
|
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
2017-07-21 22:11:45 +02:00
|
|
|
install_dependances
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2017-10-31 23:08:23 +01:00
|
|
|
# Download package and install it
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Installing sources files..." --weight=7
|
2017-10-31 23:08:23 +01:00
|
|
|
get_install_source
|
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# Create user for database
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Configuring MySQL database..."
|
2017-01-05 23:37:07 +01:00
|
|
|
dbuser=$app
|
2019-06-07 23:09:30 +02:00
|
|
|
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
2017-07-21 22:11:45 +02:00
|
|
|
ynh_mysql_create_user $dbuser $dbpass
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# Restore all config and data
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Restoring files..." --weight=10
|
|
|
|
ynh_secure_remove --file=/etc/monitorix # we remove the directory because if it is not empty the ynh_restore cmd fail
|
|
|
|
ynh_secure_remove --file=/var/lib/monitorix
|
2017-07-21 22:11:45 +02:00
|
|
|
ynh_restore
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
|
2018-01-29 18:57:10 +01:00
|
|
|
# Set access
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Protecting directory..."
|
2018-01-29 18:57:10 +01:00
|
|
|
set_permission
|
|
|
|
|
2020-11-17 23:37:38 +01:00
|
|
|
# register yunohost service
|
|
|
|
yunohost service add monitorix
|
|
|
|
|
2017-08-16 14:46:25 +02:00
|
|
|
# Reload nginx
|
|
|
|
systemctl reload nginx.service
|
|
|
|
|
2018-05-01 21:00:07 +02:00
|
|
|
# Reload monitorix
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Starting monitorix services..." --weight=3
|
2018-05-07 23:08:03 +02:00
|
|
|
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
|
2018-05-01 21:00:07 +02:00
|
|
|
# So this fix that
|
2018-05-07 23:08:03 +02:00
|
|
|
systemctl stop monitorix.service
|
2018-05-01 21:00:07 +02:00
|
|
|
sleep 1
|
2018-05-07 23:08:03 +02:00
|
|
|
pkill -f "monitorix-httpd listening on" || true
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
|
|
|
|
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|