]>
Commit | Line | Data |
---|---|---|
ac1ff40f ER |
1 | %define plugin check_iptables |
2 | Summary: Nagios plugin to check count of iptables rules | |
3 | Name: nagios-plugin-%{plugin} | |
164127df ER |
4 | Version: 0.2 |
5 | Release: 1 | |
ac1ff40f ER |
6 | License: GPL v2 |
7 | Group: Networking | |
77b38ba9 | 8 | Source0: %{plugin}.sh |
ac1ff40f | 9 | Source1: %{plugin}.cfg |
7150e1ba ER |
10 | BuildRequires: rpmbuild(macros) >= 1.685 |
11 | Requires: grep | |
ac1ff40f ER |
12 | Requires: iptables |
13 | Requires: nagios-common | |
f4edd149 | 14 | Requires: nagios-plugins-libs |
7150e1ba | 15 | Requires: sed >= 4.0 |
ac1ff40f ER |
16 | Requires: sudo |
17 | BuildArch: noarch | |
18 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
19 | ||
20 | %define _sysconfdir /etc/nagios/plugins | |
7150e1ba | 21 | %define nrpeddir /etc/nagios/nrpe.d |
ac1ff40f ER |
22 | %define plugindir %{_prefix}/lib/nagios/plugins |
23 | ||
24 | %description | |
25 | Nagios plugin to check count of iptables rules. | |
26 | ||
27 | %prep | |
28 | %setup -qcT | |
29 | cp -p %{SOURCE0} %{plugin} | |
30 | ||
31 | %install | |
32 | rm -rf $RPM_BUILD_ROOT | |
7150e1ba | 33 | install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{nrpeddir},%{plugindir}} |
ac1ff40f ER |
34 | install -p %{plugin} $RPM_BUILD_ROOT%{plugindir}/%{plugin} |
35 | sed -e 's,@plugindir@,%{plugindir},' %{SOURCE1} > $RPM_BUILD_ROOT%{_sysconfdir}/%{plugin}.cfg | |
7150e1ba | 36 | touch $RPM_BUILD_ROOT%{nrpeddir}/%{plugin}.cfg |
ac1ff40f ER |
37 | |
38 | %clean | |
39 | rm -rf $RPM_BUILD_ROOT | |
40 | ||
41 | %post | |
42 | if [ "$1" = 1 ]; then | |
43 | # setup sudo rules on first install | |
44 | %{plugindir}/%{plugin} -S || : | |
45 | fi | |
46 | ||
47 | %postun | |
48 | if [ "$1" = 0 ]; then | |
49 | # remove all sudo rules related to us | |
50 | %{__sed} -i -e '/CHECK_IPTABLES/d' /etc/sudoers | |
51 | fi | |
52 | ||
53 | %triggerin -- nagios-nrpe | |
54 | %nagios_nrpe -a %{plugin} -f %{_sysconfdir}/%{plugin}.cfg | |
55 | ||
56 | %triggerun -- nagios-nrpe | |
57 | %nagios_nrpe -d %{plugin} -f %{_sysconfdir}/%{plugin}.cfg | |
58 | ||
59 | %files | |
60 | %defattr(644,root,root,755) | |
61 | %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.cfg | |
7150e1ba | 62 | %ghost %{nrpeddir}/%{plugin}.cfg |
ac1ff40f | 63 | %attr(755,root,root) %{plugindir}/%{plugin} |