File sendmailanalyzer.spec of Package sendmailanalyzer
#
# spec file for package sendmailanalyzer
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: sendmailanalyzer
Version: 9.4
Release: 0
Summary: A free Sendmail/Postfix log analyzer
License: GPL-3.0-or-later
Group: System/Monitoring
URL: https://sareport.darold.net/index.html
Source: http://sourceforge.net/projects/sa-report/files/sa-report/%{version}/%{name}-%{version}.tar.gz
Source1: %{name}.init
Source2: %{name}.httpd.conf
Source3: %{name}.service
Source4: sa_cache.3
Source5: sa_cache.pod
Source6: create_manfile.pl
Source7: README.SUSE
Source8: %{name}.cron.d
BuildRequires: perl
BuildRequires: sed
BuildRequires: systemd
BuildRequires: perl(MIME::Base64)
BuildRequires: perl(MIME::QuotedPrint)
Requires: perl = %{perl_version}
Requires: perl(MIME::Base64)
Requires: perl(MIME::QuotedPrint)
Requires: cron
# FIXME: use proper Requires(pre/post/preun/...)
PreReq: %insserv_prereq
BuildArch: noarch
%{?systemd_requires}
%description
SendmailAnalyzer as is name suggest is a free Sendmail/Postfix log analyzer.
It process maillog files and generate dynamic statistics in HTML and graphical
output. The reports are generated in real time so that it let you know at any
moment what is going on your mail servers. It use time (hour, day, month and
year views) and cross-linked navigation for easy use.
SendmailAnalyzer is easy to install and highly configurable to match the
dozen of Sendmail possible configurations. It also support report for all the
major milter or sendmail filters like SpamAssassin, MailScanner, Clamav,
Amavis, RBL check, J-ChkMail, etc. SendmailAnalyzer is really helpful for
IT reporting.
Collected data are stored in flat files that are automatically archived or
delete to keep disk space. All reports before the current day are cached to
save system resources and are displayed in less than 1 second.
%package www
Summary: Webserver Part for SendmailAnalyzer
Group: System/Monitoring
Requires: %{name} = %{version}
Requires: apache2-mod_perl
# FIXME: use proper Requires(pre/post/preun/...)
PreReq: apache2
%description www
This package includes the needed files to see the SendmailAnalyzer
reports via an apache webserver with your browser.
%prep
%setup -q
install -m644 %{SOURCE7} .
%build
sed -i 's/\(sendmailanalyzer.conf\).orig/\1/' Makefile.PL
perl Makefile.PL \
INSTALLDIRS="vendor" \
QUIET=1 \
LOGFILE=%{_localstatedir}/log/mail \
BINDIR=%{_sbindir} \
CONFDIR=%{_sysconfdir} \
PIDDIR=%{_localstatedir}/run \
BASEDIR=%{_localstatedir}/lib/%{name} \
HTMLDIR=/srv/www/%{name} \
MANDIR=%{_mandir}/man3 \
DOCDIR=%{_docdir}/%{name} \
DESTDIR=%{buildroot}
%make_build OPTIMIZE="%{optflags}"
%check
%make_build test
%install
%make_install
rm -rf %{buildroot}%{perl_archlib}/perllocal.pod %{buildroot}%{perl_vendorarch}/auto/%{name}/.packlist
if [ ! -d %{buildroot}/%{_localstatedir}/lib/%{name} ] ; then
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
fi
# install init and service files
install -Dm0755 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init.d/%{name}
ln -sf %{_sysconfdir}/init.d/%{name} %{buildroot}/%{_sbindir}/rc%{name}
%if 0%{?suse_version} >= 01210
install -Dm644 %{SOURCE3} %{buildroot}/%{_unitdir}/%{name}.service
%endif
# install apache configuration
mkdir -p %{buildroot}/%{_sysconfdir}/apache2/conf.d
sed -e "s|__webdir__|/srv/www/%{name}|g" %{SOURCE2} > %{buildroot}/%{_sysconfdir}/apache2/conf.d/%{name}.conf
# install missing manpage
install -m644 %{SOURCE4} %{buildroot}%{_mandir}/man3/sa_cache.3
# install cron
install -Dm644 %{SOURCE8} %{buildroot}%{_sysconfdir}/cron.d/%{name}
# remove sa_cache and sendmailanalyzer from /usr/bin, because it is and sould only in /usr/_sbindir
rm -f %{buildroot}%{_bindir}/sa_cache
rm -f %{buildroot}%{_bindir}/%{name}
rmdir %{buildroot}%{_bindir}
%pre www
if [ "$1" = "1" ]; then
# enable perl in apache config
if [ -x %{_sbindir}/a2enmod ]; then
if grep -q perl %{_sysconfdir}/sysconfig/apache2 1>&2 2>/dev/null; then
%{_sbindir}/a2enmod perl >/dev/null || :
fi
fi
if [ -x %{_sbindir}/a2enflag ]; then
if grep -q SAREPORT %{_sysconfdir}/sysconfig/apache2 1>&2 2>/dev/null; then
%{_sbindir}/a2enflag SAREPORT >/dev/null || :
fi
fi
fi
%post www
%restart_on_update apache2
%postun www
%restart_on_update apache2
%if 0%{?suse_version} >= 1210
%pre
%service_add_pre %{name}.service
%post
%service_add_post %{name}.service
%{fillup_and_insserv -f %{name}}
%preun
%service_del_preun %{name}.service
%stop_on_removal %{name}
%postun
%service_del_postun %{name}.service
%restart_on_update %{name}
%insserv_cleanup
%else
%post
%{fillup_and_insserv -f %{name}}
%preun
%stop_on_removal %{name}
%postun
%restart_on_update %{name}
%insserv_cleanup
%endif
%files
%license LICENSE
%doc ChangeLog README*
%{_mandir}/man3/*.3%{?ext_man}
%{_docdir}/%{name}/sendmailanalyzer.conf.sample
%config(noreplace) %{_sysconfdir}/%{name}.conf
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%dir /srv/www/%{name}
%dir %{_localstatedir}/lib/%{name}
%dir %{_sysconfdir}/cron.d
%{_sbindir}/sa_cache
%{_sbindir}/%{name}
%{_sbindir}/rc%{name}
%{_sysconfdir}/init.d/%{name}
%if 0%{?suse_version} >= 01210
%{_unitdir}/%{name}.service
%endif
%files www
%license LICENSE
%config(noreplace) %{_sysconfdir}/apache2/conf.d/%{name}.conf
/srv/www/%{name}/*
%changelog