From 586b1f63cc09ab3d1c70dbfec099351a9c54528c Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Mon, 11 Sep 2017 22:07:03 +0200 Subject: [PATCH] Configure web_logs based on YunoHost domains: - add existing domains at installation - add hooks to process added/removed domains --- hooks/post_domain_add | 12 ++++++++++++ hooks/post_domain_remove | 10 ++++++++++ scripts/_common.sh | 14 ++++++++++++++ scripts/install | 3 +++ scripts/upgrade | 5 +++++ 5 files changed, 44 insertions(+) create mode 100644 hooks/post_domain_add create mode 100644 hooks/post_domain_remove diff --git a/hooks/post_domain_add b/hooks/post_domain_add new file mode 100644 index 0000000..8716a9f --- /dev/null +++ b/hooks/post_domain_add @@ -0,0 +1,12 @@ +#!/bin/bash + +# Retrieve arguments +domain=$1 +domain_label=${domain//\./_} # Replace "." by "_" for the domain label +# Add a web_log entry for this new domain +cat >> /opt/netdata/etc/netdata/python.d/web_log.conf <> /opt/netdata/etc/netdata/python.d/web_log.conf + for domain in $(yunohost domain list --output-as plain); do + domain_label=${domain//\./_} # Replace "." by "_" for the domain label + cat >> /opt/netdata/etc/netdata/python.d/web_log.conf <${tmp} pushd $NETDATA_TMPDIR ./netdata-installer.sh --install /opt --dont-wait >&3 2>&3 || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" +# If YunoHost web logs have never been set in netdata configuration, set them +if [ -z "$(grep "YUNOHOST" /opt/netdata/etc/netdata/python.d/web_log.conf)" ] ; then + netdata_add_yunohost_web_logs +fi + configure_netdata # Store the app.src file