]>
Commit | Line | Data |
---|---|---|
f05ac46b | 1 | %define template mail_statistics |
f05ac46b | 2 | Summary: Mail logs Graphing with Cacti |
886f2a9e ER |
3 | Name: cacti-template-%{template} |
4 | Version: 0.1 | |
f05ac46b | 5 | Release: 0.6 |
886f2a9e ER |
6 | License: GPL v2 |
7 | Group: Applications/WWW | |
8 | Source0: http://forums.cacti.net/download/file.php?id=4091#/postfix_mailserver.tar.gz | |
9 | # Source0-md5: 3cd539df3669c72b0679f18cbf74f164 | |
10 | URL: http://forums.cacti.net/about6657.html | |
f05ac46b ER |
11 | Patch0: cachetime.patch |
12 | Patch1: more-matches.patch | |
886f2a9e ER |
13 | BuildRequires: rpm-perlprov >= 4.1-13 |
14 | BuildRequires: rpmbuild(macros) >= 1.554 | |
15 | Requires: cacti | |
16 | BuildArch: noarch | |
17 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
18 | ||
19 | %define cactidir /usr/share/cacti | |
20 | %define resourcedir %{cactidir}/resource | |
21 | %define scriptsdir %{cactidir}/scripts | |
22 | %define snmpdconfdir /etc/snmp | |
23 | %define _libdir %{_prefix}/lib | |
b110e13e | 24 | %define dbfile /var/spool/postfix/mailstats.db |
f05ac46b | 25 | %define agentscript %{_libdir}/snmpd-agent-cacti-mail_statistics |
886f2a9e ER |
26 | # This is officially registered: http://www.oid-info.com/get/1.3.6.1.4.1.16606 |
27 | %define snmpoid .1.3.6.1.4.1.16606.2 | |
28 | ||
29 | %description | |
30 | Postifix monitoring with Cacti. | |
31 | ||
f05ac46b ER |
32 | %package -n net-snmp-agent-mail_statistics |
33 | Summary: SNMPd agent to provide mail stats | |
886f2a9e ER |
34 | Group: Networking/Daemons |
35 | Requires: net-snmp | |
36 | ||
f05ac46b ER |
37 | %description -n net-snmp-agent-mail_statistics |
38 | SNMPd agent to provide mail stats for Cacti. | |
886f2a9e ER |
39 | |
40 | %prep | |
41 | %setup -qc | |
f05ac46b ER |
42 | %patch0 -p1 |
43 | %patch1 -p1 | |
886f2a9e ER |
44 | |
45 | %install | |
46 | rm -rf $RPM_BUILD_ROOT | |
47 | install -d $RPM_BUILD_ROOT{%{resourcedir},%{scriptsdir},%{snmpdconfdir},%{_libdir}} | |
48 | cp -a *.xml $RPM_BUILD_ROOT%{resourcedir} | |
b110e13e ER |
49 | install -p fetch_mail_statistics.pl $RPM_BUILD_ROOT%{agentscript} |
50 | # ghost the dbfile | |
51 | install -d $RPM_BUILD_ROOT$(dirname %{dbfile}) | |
52 | touch $RPM_BUILD_ROOT%{dbfile} | |
886f2a9e ER |
53 | |
54 | %clean | |
55 | rm -rf $RPM_BUILD_ROOT | |
56 | ||
57 | %post | |
58 | %cacti_import_template %{resourcedir}/cacti_host_template_postfix_mailserver.xml | |
59 | ||
f05ac46b | 60 | %post -n net-snmp-agent-mail_statistics |
886f2a9e | 61 | if ! grep -qF %{snmpoid} %{snmpdconfdir}/snmpd.local.conf; then |
a4a4b1ee | 62 | echo "pass %{snmpoid} cacti_postfix %{agentscript} /var/log/maillog %{dbfile} %{snmpoid}" >> %{snmpdconfdir}/snmpd.local.conf |
886f2a9e ER |
63 | %service -q snmpd reload |
64 | fi | |
65 | ||
f05ac46b | 66 | %preun -n net-snmp-agent-mail_statistics |
886f2a9e ER |
67 | if [ "$1" = 0 ]; then |
68 | if [ -f %{snmpdconfdir}/snmpd.local.conf ]; then | |
a4a4b1ee | 69 | %{__sed} -i -e "/pass %(echo %{snmpoid} | sed -e 's,\.,\\.,g')/d" %{snmpdconfdir}/snmpd.local.conf |
886f2a9e ER |
70 | %service -q snmpd reload |
71 | fi | |
72 | fi | |
73 | ||
74 | %files | |
75 | %defattr(644,root,root,755) | |
76 | %{resourcedir}/*.xml | |
77 | ||
f05ac46b | 78 | %files -n net-snmp-agent-mail_statistics |
886f2a9e | 79 | %defattr(644,root,root,755) |
b110e13e ER |
80 | %attr(755,root,root) %{agentscript} |
81 | %ghost %attr(700,root,root) %{dbfile} |