1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/monitorix_ynh.git synced 2024-09-03 19:46:06 +02:00
monitorix_ynh/scripts/install

74 lines
No EOL
2 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
# Check domain/path availability
test $(ynh_webpath_available $domain $path_url) == 'True' || ynh_die "$domain$path_url is not available, please use an other domain or path."
ynh_webpath_register $app $domain $path_url
# Find a port for built-in monitorix HTTP server
port=$(ynh_find_port 8080)
nginx_status_port=$(ynh_find_port $(($port +1)))
ynh_app_setting_set $app http_port $port
ynh_app_setting_set $app nginx_status_port $nginx_status_port
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# Install package
install_dependances
# Download package and install it
get_install_source
# # Generate MySQL user
dbuser=$app
dbpass=$(ynh_string_random 12)
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_mysql_create_user $dbuser $dbpass
# Config nginx
config_nginx
# Update monitorix configuration
config_monitorix
# Add hook
mkdir -p /usr/share/yunohost/hooks/post_iptable_rules
cp ../conf/post_iptable_rules_hook /usr/share/yunohost/hooks/post_iptable_rules/50-$app
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set access
set_permission
# register yunohost service
yunohost service add monitorix
# Reload monitorix
# 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
sudo systemctl stop monitorix.service
sleep 1
pkill -f "monitorix-httpd listening on" || true
ynh_check_starting ' - Ok, ready.' '/var/log/monitorix'