diff --git a/scripts/_common.sh b/scripts/_common.sh index 8433f78..7c32599 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,10 +3,17 @@ # Common variables # -pkg_dependencies="zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl jq nodejs python-mysqldb libipmimonitoring-dev acl" +pkg_dependencies="zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl jq nodejs python-mysqldb libipmimonitoring-dev acl python-psycopg2" # Configure NetData configure_netdata() { + + # Add a web_log entry for every YunoHost domain + netdata_add_yunohost_web_logs + + # If PostgreSQL is installed, add a PostgreSQL entry using instance password + netdata_add_yunohost_postgres_configuration + # Create netdata user to monitor MySQL (if needed) is_mysql_user_existing=$(ynh_mysql_execute_as_root "select user from mysql.user where user = 'netdata';") if [ -z "$is_mysql_user_existing" ] ; then @@ -29,21 +36,39 @@ configure_netdata() { systemctl restart netdata # Store the uninstaller for the removal script - mv ./netdata-uninstaller.sh /opt/netdata/etc/netdata + [ -f ./netdata-uninstaller.sh ] && mv ./netdata-uninstaller.sh /opt/netdata/etc/netdata } # Add a web_log entry for every YunoHost domain netdata_add_yunohost_web_logs () { - echo "# ------------YUNOHOST DOMAINS---------------" >> /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 <> $web_log_file + for domain in $(yunohost domain list --output-as plain); do + domain_label=${domain//\./_} # Replace "." by "_" for the domain label + cat >> $web_log_file <> /opt/netdata/etc/netdata/python.d/postgres.conf <&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