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
Josué Tille f92db1b78c
Full package improvement
- Update config from upstream
- Use Jinja for config file
- Dynamically generate config file depending of the auto detected system configuration
- Remove dependancy of mysql as it's not needed
- Automatically monitor mysql, postgresql, memcached, redis, php pool v>=8.0, fail2ban, mail, partition and network
- Add some config parameter in config panel to make easy to change values
- Configure alert system (can be enabled by config panel)
- Fix small issue linked to previous packaging v2
2024-04-04 00:35:04 +02:00

86 lines
2.7 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source experimental_helper.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 --message="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
#=================================================
# STANDARD MODIFICATIONS
#=================================================
ynh_script_progression --message="Installing packages..." --weight=1
# Download package and install it
install_monitorix_package
ynh_systemd_action --service_name="$app" --action=stop --log_path=systemd --timeout=15
mkdir -p /var/log/new_"${app}"
mv -t /var/log/new_"${app}" /var/log/monitorix*
mv /var/log/new_"${app}" /var/log/"${app}"
#=================================================
# SYSTEM CONFIGURATION
#=================================================ç
ynh_script_progression --message="Adding configurations related to $app..." --weight=1
ynh_add_jinja_config --template=monitorix.conf --destination="/etc/monitorix/monitorix.conf"
ynh_add_jinja_config --template=nginx_status.conf --destination "$nginx_status_conf"
ynh_add_nginx_config
ynh_add_systemd_config
yunohost service add "$app" --description=Monitorix --log=systemd
ynh_script_progression --message="Configuring databases access..."
configure_db
ynh_script_progression --message="Configuring php fpm access if needed..."
if "$phpfpm_installed"; then
config_php_fpm
fi
configure_hooks
configure_alerts_email
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_script_progression --message="Protecting directory..."
set_permission
ynh_use_logrotate --logfile "/var/log/$app"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start" --log_path 'systemd' --line_match ' - Ok, ready.'
save_vars_current_value
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last