#!/bin/bash source _common.sh source /usr/share/yunohost/helpers load_vars ensure_vars_set #================================================= # Check datadir empty #================================================= if [ -n "$(ls -A "$data_dir")" ]; then old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')" ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path" mkdir -p "$old_data_dir_path" mv -t "$old_data_dir_path" "$data_dir"/* app_data_dirs="$(echo /home/yunohost.app/*)" fi mkdir -p /var/log/"$app" ynh_systemctl --service="$app" --action=stop --log_path=systemd --timeout=15 #================================================= # SYSTEM CONFIGURATION #=================================================รง ynh_script_progression "Adding configurations related to $app..." mkdir -p /etc/monitorix ynh_config_add --jinja --template=monitorix.conf --destination="/etc/monitorix/monitorix.conf" ynh_config_add --jinja --template=nginx_status.conf --destination="$nginx_status_conf" ynh_config_add_nginx ynh_config_add_systemd yunohost service add "$app" --description=Monitorix --log=systemd ynh_script_progression "Configuring databases access..." configure_db ynh_script_progression "Configuring php fpm access if needed..." if "$phpfpm_installed"; then config_php_fpm fi configure_hooks configure_alerts_email #================================================= ynh_script_progression "Installing packages..." # Download package and install it install_monitorix_package #================================================= ynh_script_progression "Protecting directory..." set_permission ynh_config_add_logrotate "/var/log/$app" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression "Starting $app's systemd service..." ynh_systemctl --service="$app" --action="start" --log_path='systemd' --wait_until=' - Ok, ready.' # when we change the value of 'listen [::1]:xxx;' nginx don't reload correctly the config, so force to restart to ensure that the new config are loaded ynh_systemctl --service=nginx.service --action=restart save_vars_current_value #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Installation of $app completed"