2018-01-31 16:07:43 +01:00
|
|
|
#=================================================
|
|
|
|
# SET ALL CONSTANTS
|
|
|
|
#=================================================
|
2017-07-21 22:11:45 +02:00
|
|
|
|
2018-01-31 16:07:43 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2023-01-22 15:32:36 +01:00
|
|
|
systemd_user=root
|
2018-01-31 16:07:43 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DEFINE ALL COMMON FONCTIONS
|
|
|
|
#=================================================
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
install_dependances() {
|
2022-12-18 15:37:37 +01:00
|
|
|
ynh_install_app_dependencies rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libdbd-mysql-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl pflogsumm libxml-libxml-perl
|
2017-01-05 23:37:07 +01:00
|
|
|
}
|
|
|
|
|
2017-10-31 23:08:23 +01:00
|
|
|
get_install_source() {
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_setup_source --dest_dir /tmp
|
2017-01-05 23:37:07 +01:00
|
|
|
|
2017-10-31 23:08:23 +01:00
|
|
|
ynh_package_update
|
2023-03-20 16:03:34 +01:00
|
|
|
dpkg --force-confdef --force-confold -i /tmp/monitorix.deb
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_secure_remove --file=/etc/monitorix/conf.d/00-debian.conf
|
2017-10-31 23:08:23 +01:00
|
|
|
ynh_package_install -f
|
2017-01-31 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
2017-07-21 22:11:45 +02:00
|
|
|
config_nginx() {
|
2018-05-07 23:08:03 +02:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
# Add special hostname for monitorix status
|
|
|
|
nginx_status_conf="/etc/nginx/conf.d/monitorix_status.conf"
|
|
|
|
cp ../conf/nginx_status.conf $nginx_status_conf
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_replace_string --match_string __PORT__ --replace_string $nginx_status_port --target_file $nginx_status_conf
|
2018-05-07 23:08:03 +02:00
|
|
|
|
|
|
|
systemctl reload nginx
|
2017-07-21 22:11:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
config_monitorix() {
|
2020-05-13 15:19:34 +02:00
|
|
|
jail_list=$(fail2ban-client status | grep 'Jail list:' | sed 's/.*Jail list://' | sed 's/,//g')
|
|
|
|
additional_jail=""
|
|
|
|
for jail in $jail_list; do
|
|
|
|
if ! [[ "$jail" =~ (recidive|pam-generic|yunohost|postfix|postfix-sasl|dovecot|nginx-http-auth|sshd|sshd-ddos) ]]; then
|
|
|
|
if [ -z "$additional_jail" ]; then
|
|
|
|
additional_jail="[$jail]"
|
|
|
|
else
|
|
|
|
additional_jail+=", [$jail]"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-05-07 23:08:03 +02:00
|
|
|
monitorix_conf=/etc/monitorix/monitorix.conf
|
2023-01-22 15:32:36 +01:00
|
|
|
cp ../conf/monitorix.conf $monitorix_conf
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_replace_string --match_string __SERVICE_PORT__ --replace_string $port --target_file $monitorix_conf
|
|
|
|
ynh_replace_string --match_string __YNH_DOMAIN__ --replace_string $domain --target_file $monitorix_conf
|
|
|
|
ynh_replace_string --match_string __NGINX_STATUS_PORT__ --replace_string $nginx_status_port --target_file $monitorix_conf
|
|
|
|
ynh_replace_string --match_string __YNH_WWW_PATH__/ --replace_string "${path_url%/}/" --target_file $monitorix_conf
|
|
|
|
ynh_replace_string --match_string __YNH_WWW_PATH__ --replace_string $path_url --target_file $monitorix_conf
|
|
|
|
ynh_replace_string --match_string __MYSQL_USER__ --replace_string $dbuser --target_file $monitorix_conf
|
|
|
|
ynh_replace_string --match_string __MYSQL_PASSWORD__ --replace_string $dbpass --target_file $monitorix_conf
|
2020-05-20 21:53:19 +02:00
|
|
|
ynh_replace_string --match_string __F2B_ADDITIONAL_JAIL__ --replace_string "$additional_jail" --target_file $monitorix_conf
|
2018-01-29 18:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
set_permission() {
|
|
|
|
chown www-data:root -R /etc/monitorix
|
|
|
|
chmod u=rX,g=rwX,o= -R /etc/monitorix
|
|
|
|
chown www-data:root -R /var/lib/monitorix
|
|
|
|
chmod u=rwX,g=rwX,o= -R /var/lib/monitorix
|
2019-04-07 08:38:08 +02:00
|
|
|
}
|