2017-01-05 23:37:07 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2017-01-05 23:37:07 +01:00
|
|
|
# Import common cmd
|
2018-01-31 16:07:43 +01:00
|
|
|
source ./experimental_helper.sh
|
2017-01-05 23:37:07 +01:00
|
|
|
source ./_common.sh
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2017-07-21 22:11:45 +02:00
|
|
|
path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
2017-01-05 23:37:07 +01:00
|
|
|
|
|
|
|
# Check domain/path availability
|
2017-07-21 22:11:45 +02:00
|
|
|
test $(ynh_webpath_available $domain $path) == 'True' || ynh_die "$domain$path is not available, please use an other domain or path."
|
|
|
|
ynh_webpath_register $app $domain $path
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
# Find a port for built-in monitorix HTTP server
|
|
|
|
http_port=$(ynh_find_port 8080)
|
|
|
|
nginx_status_port=$(ynh_find_port $(($http_port +1)))
|
|
|
|
|
|
|
|
ynh_app_setting_set $app http_port $http_port
|
|
|
|
ynh_app_setting_set $app nginx_status_port $nginx_status_port
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
|
2017-01-05 23:37:07 +01:00
|
|
|
# Install package
|
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
|
|
|
|
get_install_source
|
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
# # Generate MySQL user
|
2017-01-05 23:37:07 +01:00
|
|
|
dbuser=$app
|
|
|
|
dbpass=$(ynh_string_random 12)
|
|
|
|
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
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
|
|
|
# Config nginx
|
|
|
|
config_nginx
|
2017-01-05 23:37:07 +01:00
|
|
|
|
|
|
|
# Update monitorix configuration
|
2017-07-21 22:11:45 +02:00
|
|
|
config_monitorix
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2018-01-29 18:57:10 +01:00
|
|
|
# Set access
|
|
|
|
set_permission
|
|
|
|
|
2017-05-26 15:02:19 +02:00
|
|
|
# register yunohost service
|
2017-07-21 22:11:45 +02:00
|
|
|
yunohost service add monitorix
|
2017-05-26 15:02:19 +02:00
|
|
|
|
2017-01-05 23:37:07 +01:00
|
|
|
# Reload services
|
2017-07-21 22:11:45 +02:00
|
|
|
systemctl restart monitorix.service
|