#!/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 ynh_script_progression --message="Validating installation parameters..." # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url=$(ynh_normalize_url_path --path_url $YNH_APP_ARG_PATH) # Check domain/path availability test $(ynh_webpath_available --domain $domain --path_url $path_url) == 'True' || ynh_die --message "$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 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 #================================================= # Install package ynh_script_progression --message="Installing dependencies..." --weight=7 install_dependances # Download package and install it ynh_script_progression --message="Installing sources files..." --weight=7 get_install_source # # Generate MySQL user ynh_script_progression --message="Configuring MySQL database..." dbuser=$app dbpass=$(ynh_string_random 12) ynh_app_setting_set --app $app --key mysqlpwd --value "$dbpass" ynh_mysql_create_user $dbuser $dbpass # Config nginx ynh_script_progression --message="Configuring nginx..." --weight=1 config_nginx # Update monitorix configuration ynh_script_progression --message="Configuring application..." --weight=3 config_monitorix #================================================= # GENERIC FINALIZATION #================================================= # Set access ynh_script_progression --message="Protecting directory..." set_permission # register yunohost service yunohost service add monitorix # 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="Installation of $app completed" --last