Introduced systemd unit file, thanks to Jóhann B. Guðmundsson <johannbg@gmail.com>

Resoloves: rhbz#721354
- Provided SysV initscripts in sysvinit subpackages
- Used PrivateTmp
  Resolves: rhbz#782502
This commit is contained in:
Jaroslav Škarvada 2012-02-02 11:06:27 +01:00
parent a764d9907c
commit d66e6e70e0
4 changed files with 179 additions and 15 deletions

11
clamd.exim.service Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Clamd Exim An Interface Between MTA And Content Checkers
After=network.target
[Service]
Type=forking
PIDFile=/run/clamd.exim/clamd.pid
ExecStart=/usr/sbin/clamd -c /etc/clamd.d/exim.conf
[Install]
WantedBy=multi-user.target

37
exim-gen-cert Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
. /etc/sysconfig/network
gen_cert() {
if [ ! -f /etc/pki/tls/certs/exim.pem ] ; then
umask 077
FQDN=`hostname`
if [ "x${FQDN}" = "x" ]; then
FQDN=localhost.localdomain
fi
echo -n $"Generating exim certificate: "
cat << EOF | openssl req -new -x509 -days 365 -nodes \
-out /etc/pki/tls/certs/exim.pem \
-keyout /etc/pki/tls/private/exim.pem &>/dev/null
--
SomeState
SomeCity
SomeOrganization
SomeOrganizationalUnit
${FQDN}
root@${FQDN}
EOF
if [ $? -eq 0 ]; then
success
chown exim.exim /etc/pki/tls/{private,certs}/exim.pem
chmod 600 /etc/pki/tls/{private,certs}/exim.pem
else
failure
fi
echo
fi
}
gen_cert
exit 0

14
exim.service Normal file
View File

@ -0,0 +1,14 @@
[Unit]
Description=Exim Mail Transport Agent
After=network.target
Conflicts=sendmail.service postfix.service
[Service]
PrivateTmp=true
Environment=QUEUE=1h
EnvironmentFile=-/etc/sysconfig/exim
ExecStartPre=-/usr/libexec/exim-gen-cert
ExecStart=/usr/sbin/exim -bd -q${QUEUE}
[Install]
WantedBy=multi-user.target

130
exim.spec
View File

@ -9,17 +9,20 @@
%define buildclam 1 %define buildclam 1
%endif %endif
%global sysv2systemdnvr 4.76-6
Summary: The exim mail transfer agent Summary: The exim mail transfer agent
Name: exim Name: exim
Version: 4.76 Version: 4.76
Release: 5%{?dist} Release: 6%{?dist}
License: GPLv2+ License: GPLv2+
Url: http://www.exim.org/ Url: http://www.exim.org/
Group: System Environment/Daemons Group: System Environment/Daemons
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Provides: MTA smtpd smtpdaemon server(smtp) Provides: MTA smtpd smtpdaemon server(smtp)
Requires(post): /sbin/chkconfig /sbin/service %{_sbindir}/alternatives Requires(post): /sbin/chkconfig /sbin/service %{_sbindir}/alternatives systemd-units systemd-sysv
Requires(preun): /sbin/chkconfig /sbin/service %{_sbindir}/alternatives Requires(preun): %{_sbindir}/alternatives systemd-units
Requires(postun): %{_sbindir}/alternatives systemd-units
Requires(pre): %{_sbindir}/groupadd, %{_sbindir}/useradd Requires(pre): %{_sbindir}/groupadd, %{_sbindir}/useradd
%if 0%{?buildclam} %if 0%{?buildclam}
BuildRequires: clamav-devel BuildRequires: clamav-devel
@ -37,6 +40,9 @@ Source20: exim-greylist.conf.inc
Source21: mk-greylist-db.sql Source21: mk-greylist-db.sql
Source22: greylist-tidy.sh Source22: greylist-tidy.sh
Source23: trusted-configs Source23: trusted-configs
Source24: exim.service
Source25: exim-gen-cert
Source26: clamd.exim.service
Patch4: exim-rhl.patch Patch4: exim-rhl.patch
Patch6: exim-4.73-config.patch Patch6: exim-4.73-config.patch
@ -64,6 +70,7 @@ BuildRequires: pcre-devel sqlite-devel tcp_wrappers-devel cyrus-sasl-devel
BuildRequires: openldap-devel openssl-devel mysql-devel postgresql-devel BuildRequires: openldap-devel openssl-devel mysql-devel postgresql-devel
BuildRequires: libXaw-devel libXmu-devel libXext-devel libX11-devel libSM-devel BuildRequires: libXaw-devel libXmu-devel libXext-devel libX11-devel libSM-devel
BuildRequires: libICE-devel libXpm-devel libXt-devel perl(ExtUtils::Embed) BuildRequires: libICE-devel libXpm-devel libXt-devel perl(ExtUtils::Embed)
BuildRequires: systemd-units
%description %description
Exim is a message transfer agent (MTA) developed at the University of Exim is a message transfer agent (MTA) developed at the University of
@ -75,6 +82,17 @@ routed, and there are extensive facilities for checking incoming
mail. Exim can be installed in place of sendmail, although the mail. Exim can be installed in place of sendmail, although the
configuration of exim is quite different to that of sendmail. configuration of exim is quite different to that of sendmail.
%package sysvinit
Summary: SysV initscript for Exim
Group: System Environment/Daemons
BuildArch: noarch
Requires: %{name} = %{version}-%{release}
Requires(preun): chkconfig
Requires(post): chkconfig
%description sysvinit
This package contains the SysV initscript for Exim.
%package mysql %package mysql
Summary: MySQL lookup support for Exim Summary: MySQL lookup support for Exim
Group: System Environment/Daemons Group: System Environment/Daemons
@ -111,6 +129,7 @@ The exim-sa package is an old method for allowing SpamAssassin to be run on
incoming mail at SMTP time. It is deprecated in favour of the built-in ACL incoming mail at SMTP time. It is deprecated in favour of the built-in ACL
support for content scanning. support for content scanning.
%if 0%{?buildclam}
%package clamav %package clamav
Summary: Clam Antivirus scanner dæmon configuration for use with Exim Summary: Clam Antivirus scanner dæmon configuration for use with Exim
Group: System Environment/Daemons Group: System Environment/Daemons
@ -136,6 +155,18 @@ For further details of Exim content scanning, see chapter 41 of the Exim
specification: specification:
http://www.exim.org/exim-html-%{version}/doc/html/spec_html/ch41.html http://www.exim.org/exim-html-%{version}/doc/html/spec_html/ch41.html
%package clamav-sysvinit
Summary: SysV initscript for Clam Antivirus scanner for Exim
Group: System Environment/Daemons
BuildArch: noarch
Requires: exim-clamav = %{version}-%{release}
Requires(preun): chkconfig
Requires(post): chkconfig
%description clamav-sysvinit
This package contains the SysV initscript.
%endif
%package greylist %package greylist
Summary: Example configuration for greylisting using Exim Summary: Example configuration for greylisting using Exim
Group: System Environment/Daemons Group: System Environment/Daemons
@ -270,6 +301,13 @@ install -m 644 %SOURCE3 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/exim
mkdir -p $RPM_BUILD_ROOT%{_initrddir} mkdir -p $RPM_BUILD_ROOT%{_initrddir}
install %SOURCE2 $RPM_BUILD_ROOT%{_initrddir}/exim install %SOURCE2 $RPM_BUILD_ROOT%{_initrddir}/exim
# Systemd
mkdir -p %{buildroot}%{_unitdir}
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
install -m644 %{SOURCE24} %{buildroot}%{_unitdir}
install -m755 %{SOURCE25} %{buildroot}%{_libexecdir}
install -m644 %{SOURCE26} %{buildroot}%{_unitdir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
install -m 0644 %SOURCE4 $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/exim install -m 0644 %SOURCE4 $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/exim
@ -347,7 +385,7 @@ fi
exit 0 exit 0
%post %post
/sbin/chkconfig --add exim [ $1 -eq 1 ] && /bin/systemctl daemon-reload >/dev/null 2>&1 || :
%{_sbindir}/alternatives --install %{_sbindir}/sendmail mta %{_sbindir}/sendmail.exim 10 \ %{_sbindir}/alternatives --install %{_sbindir}/sendmail mta %{_sbindir}/sendmail.exim 10 \
--slave %{_bindir}/mailq mta-mailq %{_bindir}/mailq.exim \ --slave %{_bindir}/mailq mta-mailq %{_bindir}/mailq.exim \
@ -362,20 +400,42 @@ exit 0
%preun %preun
if [ $1 = 0 ]; then if [ $1 = 0 ]; then
/sbin/service exim stop > /dev/null 2>&1 /bin/systemctl --no-reload exim.service > /dev/null 2>&1 || :
/sbin/chkconfig --del exim /bin/systemctl stop exim.service > /dev/null 2>&1 || :
%{_sbindir}/alternatives --remove mta %{_sbindir}/sendmail.exim %{_sbindir}/alternatives --remove mta %{_sbindir}/sendmail.exim
fi fi
%postun %postun
if [ "$1" -ge "1" ]; then /bin/systemctl daemon-reload >/dev/null 2>&1 || :
/sbin/service exim condrestart > /dev/null 2>&1 if [ $1 -ge 1 ]; then
/bin/systemctl try-restart exim.service >/dev/null 2>&1 || :
mta=`readlink /etc/alternatives/mta` mta=`readlink /etc/alternatives/mta`
if [ "$mta" == "%{_sbindir}/sendmail.exim" ]; then if [ "$mta" == "%{_sbindir}/sendmail.exim" ]; then
/usr/sbin/alternatives --set mta %{_sbindir}/sendmail.exim /usr/sbin/alternatives --set mta %{_sbindir}/sendmail.exim
fi fi
fi fi
%triggerun -- exim < %{sysv2systemdnvr}
%{_bindir}/systemd-sysv-convert --save exim >/dev/null 2>&1 ||:
/bin/systemctl enable exim.service >/dev/null 2>&1
/sbin/chkconfig --del exim >/dev/null 2>&1 || :
/bin/systemctl try-restart exim.service >/dev/null 2>&1 || :
%triggerpostun -n exim-sysvinit -- exim < %{sysv2systemdnvr}
/sbin/chkconfig --add exim >/dev/null 2>&1 || :
%post sysvinit
/sbin/chkconfig --add exim >/dev/null 2>&1 ||:
%preun sysvinit
if [ "$1" = 0 ]; then
%{_initrddir}/exim stop >/dev/null 2>&1 ||:
/sbin/chkconfig --del exim >/dev/null 2>&1 ||:
fi
%postun sysvinit
[ "$1" -ge "1" ] && %{_initrddir}/exim condrestart >/dev/null 2>&1 ||:
%post greylist %post greylist
if [ ! -r %{_var}/spool/exim/db/greylist.db ]; then if [ ! -r %{_var}/spool/exim/db/greylist.db ]; then
sqlite3 %{_var}/spool/exim/db/greylist.db < %{_sysconfdir}/exim/mk-greylist-db.sql sqlite3 %{_var}/spool/exim/db/greylist.db < %{_sysconfdir}/exim/mk-greylist-db.sql
@ -425,7 +485,8 @@ fi
%config(noreplace) %{_sysconfdir}/exim/exim.conf %config(noreplace) %{_sysconfdir}/exim/exim.conf
%config(noreplace) %{_sysconfdir}/exim/trusted-configs %config(noreplace) %{_sysconfdir}/exim/trusted-configs
%config(noreplace) %{_sysconfdir}/sysconfig/exim %config(noreplace) %{_sysconfdir}/sysconfig/exim
%{_sysconfdir}/rc.d/init.d/exim %{_unitdir}/exim.service
%{_libexecdir}/exim-gen-cert
%config(noreplace) %{_sysconfdir}/logrotate.d/exim %config(noreplace) %{_sysconfdir}/logrotate.d/exim
%config(noreplace) %{_sysconfdir}/pam.d/exim %config(noreplace) %{_sysconfdir}/pam.d/exim
%{_sysconfdir}/cron.daily/exim-tidydb %{_sysconfdir}/cron.daily/exim-tidydb
@ -446,6 +507,10 @@ fi
%ghost %{_sysconfdir}/pam.d/smtp %ghost %{_sysconfdir}/pam.d/smtp
%ghost %{_mandir}/man1/mailq.1.gz %ghost %{_mandir}/man1/mailq.1.gz
%files sysvinit
%defattr(-,root,root,-)
%{_initrddir}/exim
%files mysql %files mysql
%defattr(-,root,root,-) %defattr(-,root,root,-)
%{_libdir}/exim/%{version}-%{release}/lookups/mysql.so %{_libdir}/exim/%{version}-%{release}/lookups/mysql.so
@ -472,24 +537,54 @@ fi
%post clamav %post clamav
/bin/touch %{_var}/log/clamd.exim /bin/touch %{_var}/log/clamd.exim
/bin/chown exim.exim %{_var}/log/clamd.exim /bin/chown exim.exim %{_var}/log/clamd.exim
/sbin/chkconfig --add clamd.exim if [ $1 -eq 1 ] ; then
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%preun clamav %preun clamav
test "$1" != 0 || %{_initrddir}/clamd.exim stop &>/dev/null || : if [ $1 = 0 ]; then
test "$1" != 0 || /sbin/chkconfig --del clamd.exim /bin/systemctl --no-reload clamd.exim.service > /dev/null 2>&1 || :
/bin/systemctl stop clamd.exim.service > /dev/null 2>&1 || :
fi
%postun clamav %postun clamav
test "$1" = 0 || %{_initrddir}/clamd.exim condrestart >/dev/null || : /bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
/bin/systemctl try-restart clamd.exim.service >/dev/null 2>&1 || :
fi
%triggerun -- clamav < %{sysv2systemdnvr}
%{_bindir}/systemd-sysv-convert --save clamd.exim >/dev/null 2>&1 ||:
/bin/systemctl enable clamd.exim.service >/dev/null 2>&1
/sbin/chkconfig --del clamd.exim >/dev/null 2>&1 || :
/bin/systemctl try-restart clamd.exim.service >/dev/null 2>&1 || :
%triggerpostun -n exim-clamav-sysvinit -- exim < %{sysv2systemdnvr}
/sbin/chkconfig --add clamd.exim >/dev/null 2>&1 ||:
%post clamav-sysvinit
/sbin/chkconfig --add clamd.exim >/dev/null 2>&1 ||:
%preun clamav-sysvinit
test "$1" != 0 || %{_initrddir}/clamd.exim stop >/dev/null 2>&1 || :
test "$1" != 0 || /sbin/chkconfig --del clamd.exim >/dev/null 2>&1 || :
%postun clamav-sysvinit
test "$1" = 0 || %{_initrddir}/clamd.exim condrestart >/dev/null 2>&1 || :
%files clamav %files clamav
%defattr(-,root,root,-) %defattr(-,root,root,-)
%{_sbindir}/clamd.exim %{_sbindir}/clamd.exim
%attr(0755,root,root) %config %{_initrddir}/clamd.exim %{_unitdir}/clamd.exim.service
%config(noreplace) %verify(not mtime) %{_sysconfdir}/clamd.d/exim.conf %config(noreplace) %verify(not mtime) %{_sysconfdir}/clamd.d/exim.conf
%config(noreplace) %verify(not mtime) %{_sysconfdir}/sysconfig/clamd.exim %config(noreplace) %verify(not mtime) %{_sysconfdir}/sysconfig/clamd.exim
%config(noreplace) %verify(not mtime) %{_sysconfdir}/logrotate.d/clamd.exim %config(noreplace) %verify(not mtime) %{_sysconfdir}/logrotate.d/clamd.exim
%attr(0750,exim,exim) %dir %{_var}/run/clamd.exim %attr(0750,exim,exim) %dir %{_var}/run/clamd.exim
%ghost %attr(0644,exim,exim) %{_var}/log/clamd.exim %ghost %attr(0644,exim,exim) %{_var}/log/clamd.exim
%files clamav-sysvinit
%defattr(-,root,root,-)
%attr(0755,root,root) %config %{_initrddir}/clamd.exim
%endif %endif
%files greylist %files greylist
@ -500,6 +595,13 @@ test "$1" = 0 || %{_initrddir}/clamd.exim condrestart >/dev/null || :
%{_sysconfdir}/cron.daily/greylist-tidy.sh %{_sysconfdir}/cron.daily/greylist-tidy.sh
%changelog %changelog
* Mon Jan 30 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 4.76-6
- Introduced systemd unit file, thanks to Jóhann B. Guðmundsson <johannbg@gmail.com>
Resoloves: rhbz#721354
- Provided SysV initscripts in sysvinit subpackages
- Used PrivateTmp
Resolves: rhbz#782502
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.76-5 * Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.76-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild