+# BuildRequires: rpmbuild(macros) >= 1.553
+
+# NB: make sure this command stays on one line
+%undos %{__sed} -i -e 's,\\r$,,'
+
+# Hook to register nagios object based plugins in Nagios NRPE daemon config.
+#
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+# -a NAME -- add command named NAME
+# -d NAME -- remove command named NAME
+# -f FILE -- specify plugin configuration FILE to extract command definition from
+#
+# Sample:
+# %triggerin -- nagios-nrpe
+# %nagios_nrpe -a %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
+#
+# %triggerun -- nagios-nrpe
+# %nagios_nrpe -d %{plugin} -f %{_sysconfdir}/%{plugin}.cfg
+#
+# Requirements:
+# BuildRequires: sed >= 4.0
+# BuildRequires: rpmbuild(macros) >= 1.552
+%nagios_nrpe(a:d:c:f:) {\
+ m=$(md5sum < /etc/nagios/nrpe.cfg); \
+ %{-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; \
+ 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; \
+ fi;} \
+ if [ "$m" != "$(md5sum < /etc/nagios/nrpe.cfg)" ]; then \
+ %service -q nrpe restart; \
+ fi; \
+}%{nil}
+
+# Import or update Cacti template.
+#
+# Author: Elan Ruusamäe <glen@pld-linux.org>
+#
+# Usage:
+# %cacti_import_template XMLFILE
+# XMLFILE -- XML template to import
+#
+# Sample:
+# %post
+# %cacti_import_template %{resourcedir}/cacti_host_template_varnish.xml
+#
+# Requires: cacti >= 0.8.7e-8
+# BuildRequires: rpmbuild(macros) >= 1.554