mirror of
https://github.com/YunoHost-Apps/monitorix_ynh.git
synced 2024-09-03 19:46:06 +02:00
75 lines
2.3 KiB
Bash
Executable file
75 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
|
|
# Import common cmd
|
|
source ../settings/scripts/experimental_helper.sh
|
|
source ../settings/scripts/_common.sh
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Stop script if errors
|
|
ynh_abort_if_errors
|
|
|
|
ynh_script_progression --message="Loading settings..."
|
|
|
|
# Retrieve old app settings
|
|
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))
|
|
|
|
#=================================================
|
|
# STANDARD RESTORATION STEPS
|
|
#=================================================
|
|
|
|
# Creating the folder
|
|
mkdir -p /var/lib/monitorix/www/imgs
|
|
mkdir -p /etc/monitorix/conf.d/
|
|
touch /etc/monitorix/conf.d/00-debian.conf
|
|
|
|
# Install package
|
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
|
install_dependances
|
|
|
|
# Download package and install it
|
|
ynh_script_progression --message="Installing sources files..." --weight=7
|
|
get_install_source
|
|
|
|
# Create user for database
|
|
ynh_script_progression --message="Configuring MySQL database..."
|
|
dbuser=$app
|
|
dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
|
ynh_mysql_create_user $dbuser $dbpass
|
|
|
|
# Restore all config and data
|
|
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
|
|
ynh_restore
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
|
|
# Set access
|
|
ynh_script_progression --message="Protecting directory..."
|
|
set_permission
|
|
|
|
# register yunohost service
|
|
yunohost service add monitorix
|
|
|
|
# Reload nginx
|
|
systemctl reload nginx.service
|
|
|
|
# Reload monitorix
|
|
ynh_script_progression --message="Starting monitorix services..." --weight=3
|
|
# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
|
|
# So this fix that
|
|
systemctl stop monitorix.service
|
|
sleep 1
|
|
pkill -f "monitorix-httpd listening on" || true
|
|
ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|