tag 888815 patch thanks Hi,
I've attached a patch that I've successfully deployed on our machines. It tries to follow as close as possible the style/indenting of the sourounding packaging. Probably the wording of the debconf template can be improved. Regards, Daniel
commit fcfa5f73cf2f6e24da5f5719c0dc4d47e8c54d38 gpg: Signature made Tue 27 Feb 2018 10:31:52 AM CET gpg: using RSA key F2B645DF11964018E7693B9F4613D5C794A6A9B2 gpg: Good signature from "Daniel Baumann <daniel.baum...@progress-linux.org>" [ultimate] Primary key fingerprint: F2B6 45DF 1196 4018 E769 3B9F 4613 D5C7 94A6 A9B2 Author: Daniel Baumann <daniel.baum...@progress-linux.org> Date: Sun Feb 25 14:05:21 2018 +0100 Adding debconf support to configure email notifications (Closes: #888815). Signed-off-by: Daniel Baumann <daniel.baum...@progress-linux.org> diff --git a/debian/netdata.config b/debian/netdata.config new file mode 100644 index 0000000..4a4b6be --- /dev/null +++ b/debian/netdata.config @@ -0,0 +1,18 @@ +#!/bin/bash + +CONFFILE="/etc/netdata/health_alarm_notify.conf" + +. /usr/share/debconf/confmodule + +if [ -e "${CONFFILE}" ]; then + # contains bashisms + . ${CONFFILE} || true + + db_set netdata/send_email "${SEND_EMAIL}" +fi + +db_settitle netdata/title +db_input low netdata/send_email || true +db_go + +db_stop diff --git a/debian/netdata.postinst.in b/debian/netdata.postinst.in index 48989f1..71cac68 100644 --- a/debian/netdata.postinst.in +++ b/debian/netdata.postinst.in @@ -2,8 +2,34 @@ set -e +CONFFILE="/etc/netdata/health_alarm_notify.conf" + +. /usr/share/debconf/confmodule + case "$1" in configure) + db_get netdata/send_email + SEND_EMAIL="${RET:-true}" # boolean + + db_stop + + case "${SEND_EMAIL}" in + true) + SEND_EMAIL="YES" + ;; + + *) + SEND_EMAIL="NO" + ;; + esac + + if [ -e "${CONFFILE}" ]; then + sed -e "s|^ *SEND_EMAIL=.*|SEND_EMAIL=\"${SEND_EMAIL}\"|" \ + < "${CONFFILE}" > "${CONFFILE}.tmp" + + mv -f "${CONFFILE}.tmp" "${CONFFILE}" + fi + if [ -z "$2" ]; then if ! getent group netdata >/dev/null; then addgroup --quiet --system netdata diff --git a/debian/netdata.templates b/debian/netdata.templates new file mode 100644 index 0000000..b21b81e --- /dev/null +++ b/debian/netdata.templates @@ -0,0 +1,14 @@ +Template: netdata/title +Type: title +_Description: netdata: Configuration + +Template: netdata/send_email +Type: boolean +Default: true +_Description: send emails: + netdata sends emails for warnings and alerts to root@localhost for + monitoring purposes. Potentially this can trigger a lot of emails. + . + Please choose to enable or disable sending emails. + . + If unsure, allow it to send emails (default). diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in new file mode 100644 index 0000000..e403902 --- /dev/null +++ b/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] netdata.templates diff --git a/debian/po/templates.pot b/debian/po/templates.pot new file mode 100644 index 0000000..5bc0508 --- /dev/null +++ b/debian/po/templates.pot @@ -0,0 +1,50 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the netdata package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: netdata\n" +"Report-Msgid-Bugs-To: netd...@packages.debian.org\n" +"POT-Creation-Date: 2018-02-27 10:30+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <l...@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: title +#. Description +#: ../netdata.templates:1001 +msgid "netdata: Configuration" +msgstr "" + +#. Type: boolean +#. Description +#: ../netdata.templates:2001 +msgid "send emails:" +msgstr "" + +#. Type: boolean +#. Description +#: ../netdata.templates:2001 +msgid "" +"netdata sends emails for warnings and alerts to root@localhost for " +"monitoring purposes. Potentially this can trigger a lot of emails." +msgstr "" + +#. Type: boolean +#. Description +#: ../netdata.templates:2001 +msgid "Please choose to enable or disable sending emails." +msgstr "" + +#. Type: boolean +#. Description +#: ../netdata.templates:2001 +msgid "If unsure, allow it to send emails (default)." +msgstr ""