[packages/rpm-pld-macros] Pick command_line by command_name in %nagios_nrpe
arekm
arekm at pld-linux.org
Sun Sep 6 02:28:44 CEST 2026
commit 6b3506f7aa5f0da140319bb6f4ba523abc242529
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sun Sep 6 01:56:37 2026 +0200
Pick command_line by command_name in %nagios_nrpe
It copied every command_line in the file under the name given by -a, so a
config holding two commands registered both of them under each name:
$ %nagios_nrpe -a check_poldek -f check_poldek.cfg
command[check_poldek]=.../check_poldek $ARG1$
command[check_poldek]=.../check_poldek --alert-on security $ARG1$
The sed now reads only the define command block whose command_name matches.
macros.nagios | 4 +++-
rpm-pld-macros.spec | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/rpm-pld-macros.spec b/rpm-pld-macros.spec
index d5b2c69..8b85395 100644
--- a/rpm-pld-macros.spec
+++ b/rpm-pld-macros.spec
@@ -1,4 +1,4 @@
-%define rpm_macros_rev 2.070
+%define rpm_macros_rev 2.071
%define find_lang_rev 1.42
# split into individual X_prov_ver if there is a reason to desync
%define prov_ver 4.15
diff --git a/macros.nagios b/macros.nagios
index 24e312d..1a9db5b 100644
--- a/macros.nagios
+++ b/macros.nagios
@@ -7,6 +7,8 @@
# -d NAME -- remove command named NAME
# -f FILE -- specify plugin configuration FILE to extract command definition from
#
+# NAME picks the "define command" block to read, so one FILE may hold several.
+#
# Sample:
# %triggerin -- nagios-nrpe
# %nagios_nrpe -a %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
@@ -28,7 +30,7 @@
%{-a:# on -a and config exists \
if [ -f /etc/nagios/nrpe.cfg ]; then \
if [ ! -f $file ] || ! %{__grep} -q '^command\[%{-a*}\]' $file; then \
- %{__sed} -ne 's/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p' %{-f*} >> $file; \
+ %{__sed} -ne '/^[ \t]*command_name[ \t]\+%{-a*}[ \t]*$/,/\}/{s/^[ \t]*command_line[ \t]\+\(.\+\)/command[%{-a*}]=\1/p}' %{-f*} >> $file; \
fi; \
fi;} \
%{-d:# on package remove, -d and config exists \
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/rpm-pld-macros.git/commitdiff/6b3506f7aa5f0da140319bb6f4ba523abc242529
More information about the pld-cvs-commit
mailing list