[packages/rpm-build-macros] 1.685: add nrpe.d support to %nagios_nrpe macro

glen glen at pld-linux.org
Tue Jan 28 21:04:35 CET 2014


commit 210174e26ba32ba897c720a4e01953ff1d7a2cb8
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Tue Jan 28 20:02:37 2014 +0000

    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}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-macros.git/commitdiff/210174e26ba32ba897c720a4e01953ff1d7a2cb8



More information about the pld-cvs-commit mailing list