From 210174e26ba32ba897c720a4e01953ff1d7a2cb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Tue, 28 Jan 2014 20:02:37 +0000 Subject: [PATCH] 1.685: add nrpe.d support to %nagios_nrpe macro --- rpm-build-macros.spec | 2 +- rpm.macros | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rpm-build-macros.spec b/rpm-build-macros.spec index 9b36367..930df97 100644 --- a/rpm-build-macros.spec +++ b/rpm-build-macros.spec @@ -5,7 +5,7 @@ %if "%{pld_release}" == "ac" %define with_rpm4 1 %endif -%define rpm_macros_rev 1.684 +%define rpm_macros_rev 1.685 %define find_lang_rev 1.36 Summary: PLD Linux RPM build macros Summary(pl.UTF-8): Makra do budowania pakietów RPM dla Linuksa PLD diff --git a/rpm.macros b/rpm.macros index 303c0c3..82c3763 100644 --- a/rpm.macros +++ b/rpm.macros @@ -2170,20 +2170,25 @@ else: \ # Requirements: # Requires: grep # Requires: sed >= 4.0 -# BuildRequires: rpmbuild(macros) >= 1.552 +# BuildRequires: rpmbuild(macros) >= 1.685 %nagios_nrpe(a:d:c:f:) {\ - m=$(md5sum < /etc/nagios/nrpe.cfg); \ + if %{__grep} -q '^include_dir=/etc/nagios/nrpe.d' /etc/nagios/nrpe.cfg && [ -d /etc/nagios/nrpe.d ]; then \ + file=/etc/nagios/nrpe.d/%{-a*}%{-d*}.cfg; \ + else \ + file=/etc/nagios/nrpe.cfg; \ + fi; \ + m=$(test -f $file && md5sum < $file); \ %{-a:# on -a and config exists \ if [ -f /etc/nagios/nrpe.cfg ]; then \ - if ! %{__grep} -q '^command\[%{-a*}\]' /etc/nagios/nrpe.cfg; then \ - %{__sed} -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> /etc/nagios/nrpe.cfg; \ + if [ ! -f $file ] || ! %{__grep} -q '^command\[%{-a*}\]' $file; then \ + %{__sed} -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> $file; \ fi; \ fi;} \ %{-d:# on package remove, -d and config exists \ - if [ "$1" = "0" -a -f /etc/nagios/nrpe.cfg ]; then \ - %{__sed} -i -e '/^[ \t]*command\[%{-d*}\]/d' /etc/nagios/nrpe.cfg; \ + if [ "$1" = "0" -a -f $file ]; then \ + %{__sed} -i -e '/^[ \t]*command\[%{-d*}\]/d' $file; \ fi;} \ - if [ "$m" != "$(md5sum < /etc/nagios/nrpe.cfg)" ]; then \ + if [ "$m" != "$(md5sum < $file)" ]; then \ %service -q nrpe restart; \ fi; \ }%{nil} -- 2.44.0