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

98 lines
3 KiB
Text
Raw Normal View History

2017-01-05 23:37:07 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
2020-11-17 23:37:38 +01:00
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
2017-07-21 22:11:45 +02:00
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
ynh_abort_if_errors
ynh_script_progression --message="Validating installation parameters..."
2017-01-05 23:37:07 +01:00
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
2017-01-05 23:37:07 +01:00
ynh_webpath_register $app $domain $path_url
2017-01-05 23:37:07 +01:00
2022-11-02 23:07:44 +01:00
if [ -e "/var/lib/monitorix" ]; then
old_data_dir_path="/var/lib/monitorix$(date '+%Y%m%d.%H%M%S')"
ynh_print_warn "A data directory already exist. Data was renamed to $old_data_dir_path"
mv "/var/lib/monitorix" "$old_data_dir_path"
fi
# Find a port for built-in monitorix HTTP server
ynh_script_progression --message="Finding available ports..."
port=$(ynh_find_port --port 8080)
nginx_status_port=$(ynh_find_port --port $(($port +1)))
# store config in yunohost
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app $app --key http_port --value $port
ynh_app_setting_set --app $app --key nginx_status_port --value $nginx_status_port
#=================================================
# STANDARD MODIFICATIONS
#=================================================
2021-02-03 22:26:07 +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-03 22:26:07 +01:00
# Install package
ynh_script_progression --message="Installing dependencies..." --weight=7
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
ynh_script_progression --message="Installing sources files..." --weight=7
2017-10-31 23:08:23 +01:00
get_install_source
2023-01-22 03:09:34 +01:00
# Configure init script
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_add_systemd_config
2017-07-21 22:11:45 +02:00
# # Generate MySQL user
ynh_script_progression --message="Configuring MySQL database..."
2017-01-05 23:37:07 +01:00
dbuser=$app
dbpass=$(ynh_string_random 12)
ynh_app_setting_set --app $app --key mysqlpwd --value "$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
ynh_script_progression --message="Configuring nginx..." --weight=1
2017-07-21 22:11:45 +02:00
config_nginx
2017-01-05 23:37:07 +01:00
# Update monitorix configuration
ynh_script_progression --message="Configuring application..." --weight=3
2017-07-21 22:11:45 +02:00
config_monitorix
2017-01-05 23:37:07 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# Set access
ynh_script_progression --message="Protecting directory..."
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
2018-05-01 21:00:07 +02:00
# 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
2018-05-01 21:00:07 +02:00
# So this fix that
systemctl stop monitorix.service
2018-05-01 21:00:07 +02:00
sleep 1
pkill -f "monitorix-httpd listening on" || true
2023-01-22 03:09:34 +01:00
ynh_systemd_action -l ' - Ok, ready.' -p 'systemd'
ynh_script_progression --message="Installation of $app completed" --last