From 33d3975acab02285f9be11a13f243ca4917f98d7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 31 Dec 2018 18:43:06 +0100 Subject: Using ucf to handle updates of configuration files (Closes: #904459). Signed-off-by: Daniel Baumann --- debian/control | 1 + debian/netdata.conf.md5sum | 1 + debian/netdata.install | 2 +- debian/netdata.postinst.in | 30 ++++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 debian/netdata.conf.md5sum diff --git a/debian/control b/debian/control index da8236d7e..e86ae394d 100644 --- a/debian/control +++ b/debian/control @@ -30,6 +30,7 @@ Depends: python3-six, python3-urllib3 (>= 1.22), python3-yaml, + ucf, ${misc:Depends}, ${shlibs:Depends}, Recommends: diff --git a/debian/netdata.conf.md5sum b/debian/netdata.conf.md5sum new file mode 100644 index 000000000..396030233 --- /dev/null +++ b/debian/netdata.conf.md5sum @@ -0,0 +1 @@ +fb0233fe09f9497a1fb7ec97c3d69771 netdata.conf diff --git a/debian/netdata.install b/debian/netdata.install index 23c5cfba7..0f0d59039 100644 --- a/debian/netdata.install +++ b/debian/netdata.install @@ -1,5 +1,5 @@ /usr/sbin -debian/netdata.conf /etc/netdata/ +debian/netdata.conf* /usr/share/netdata etc/netdata/ usr/lib/*/netdata/charts.d/*.sh usr/lib/*/netdata/conf.d diff --git a/debian/netdata.postinst.in b/debian/netdata.postinst.in index 49ed64955..9a86f70bd 100644 --- a/debian/netdata.postinst.in +++ b/debian/netdata.postinst.in @@ -6,6 +6,14 @@ CONFFILE="/etc/netdata/health_alarm_notify.conf" . /usr/share/debconf/confmodule +new_config= + +cleanup() { + if [ "$new_config" ]; then + rm -f "$new_config" + fi +} + case "$1" in configure) db_get netdata/send_email @@ -13,6 +21,28 @@ case "$1" in db_stop + trap cleanup EXIT + new_config="$(tempfile)" + + cp -a /usr/share/netdata/netdata.conf "$new_config" + if [ "$permit_root_login" != true ]; then +»·······»·······sed -i 's/^#*PermitRootLogin .*/PermitRootLogin yes/' \ +»·······»·······»·······"$new_config" +»·······fi +»·······if [ "$password_authentication" != true ]; then +»·······»·······sed -i 's/^#PasswordAuthentication .*/PasswordAuthentication no/' \ +»·······»·······»·······"$new_config" +»·······fi +»·······mkdir -p /etc/ssh +»·······ucf --three-way --debconf-ok \ +»·······»·······--sum-file /usr/share/openssh/sshd_config.md5sum \ +»·······»·······"$new_config" /etc/ssh/sshd_config +»·······ucfr openssh-server /etc/ssh/sshd_config + + + + + case "${SEND_EMAIL}" in true) SEND_EMAIL="YES" -- cgit v1.2.3