Introduce systemd unit file, drop SysV support
This commit is contained in:
parent
2d1261b5a8
commit
fb3e4b9e3a
164
sendmail.init
164
sendmail.init
@ -1,164 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# sendmail This shell script takes care of starting and stopping
|
|
||||||
# sendmail.
|
|
||||||
#
|
|
||||||
# chkconfig: 2345 80 30
|
|
||||||
# description: Sendmail is a Mail Transport Agent, which is the program \
|
|
||||||
# that moves mail from one machine to another.
|
|
||||||
# processname: sendmail
|
|
||||||
# config: /etc/mail/sendmail.cf
|
|
||||||
# pidfile: /var/run/sendmail.pid
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: sendmail smtpdaemon $mail-transfer-agent
|
|
||||||
# Required-Start: $local_fs $network
|
|
||||||
# Required-Stop: $local_fs $network
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: start and stop sendmail
|
|
||||||
# Description: sendmail is a Mail Transport Agent (MTA)
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
# Source function library.
|
|
||||||
. /etc/rc.d/init.d/functions
|
|
||||||
|
|
||||||
# Source networking configuration.
|
|
||||||
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
|
|
||||||
|
|
||||||
# Source sendmail configureation.
|
|
||||||
if [ -f /etc/sysconfig/sendmail ]; then
|
|
||||||
. /etc/sysconfig/sendmail
|
|
||||||
else
|
|
||||||
DAEMON=no
|
|
||||||
QUEUE=1h
|
|
||||||
fi
|
|
||||||
[ -z "$SMQUEUE" ] && SMQUEUE="$QUEUE"
|
|
||||||
[ -z "$SMQUEUE" ] && SMQUEUE=1h
|
|
||||||
|
|
||||||
# Check that we're a privileged user
|
|
||||||
[ `id -u` = 0 ] || exit 4
|
|
||||||
|
|
||||||
# Check that networking is up.
|
|
||||||
[ "${NETWORKING}" = "no" ] && exit 1
|
|
||||||
|
|
||||||
[ -x /usr/sbin/sendmail ] || exit 5
|
|
||||||
|
|
||||||
prog="sendmail"
|
|
||||||
|
|
||||||
updateconf() {
|
|
||||||
/etc/mail/make > /dev/null 2>&1
|
|
||||||
if [ $? -eq 15 ]; then
|
|
||||||
echo -n $"Package sendmail-cf is required to update configuration."
|
|
||||||
warning
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
/etc/mail/make aliases > /dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
# Start daemons.
|
|
||||||
ret=0
|
|
||||||
updateconf
|
|
||||||
echo -n $"Starting $prog: "
|
|
||||||
daemon /usr/sbin/sendmail $([ "x$DAEMON" = xyes ] && echo -bd) \
|
|
||||||
$([ -n "$QUEUE" ] && echo -q$QUEUE) $SENDMAIL_OPTARG
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
|
|
||||||
let ret+=$RETVAL
|
|
||||||
|
|
||||||
if [ ! -f /var/run/sm-client.pid ]; then
|
|
||||||
echo -n $"Starting sm-client: "
|
|
||||||
touch /var/run/sm-client.pid
|
|
||||||
chown smmsp:smmsp /var/run/sm-client.pid
|
|
||||||
if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
|
|
||||||
/sbin/restorecon /var/run/sm-client.pid
|
|
||||||
fi
|
|
||||||
daemon --check sm-client /usr/sbin/sendmail -L sm-msp-queue -Ac \
|
|
||||||
-q$SMQUEUE $SENDMAIL_OPTARG
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client
|
|
||||||
let ret+=$RETVAL
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ $ret -eq 0 ] && return 0 || return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
reload() {
|
|
||||||
updateconf
|
|
||||||
echo -n $"Reloading $prog: "
|
|
||||||
killproc sendmail -HUP
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
if [ $RETVAL -eq 0 -a -f /var/run/sm-client.pid ]; then
|
|
||||||
echo -n $"reloading sm-client: "
|
|
||||||
killproc sm-client -HUP
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
return $RETVAL
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
# Stop daemons.
|
|
||||||
if [ -f /var/run/sm-client.pid ]; then
|
|
||||||
echo -n $"Shutting down sm-client: "
|
|
||||||
killproc sm-client
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
[ $RETVAL -eq 0 ] && rm -f /var/run/sm-client.pid
|
|
||||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client
|
|
||||||
fi
|
|
||||||
echo -n $"Shutting down $prog: "
|
|
||||||
killproc sendmail
|
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
|
|
||||||
return $RETVAL
|
|
||||||
}
|
|
||||||
|
|
||||||
status -p /var/run/sendmail.pid >/dev/null || status -p /var/run/sm-client.pid >/dev/null
|
|
||||||
running=$?
|
|
||||||
|
|
||||||
# See how we were called.
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
[ $running -eq 0 ] && exit 0
|
|
||||||
start
|
|
||||||
RETVAL=$?
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
[ $running -eq 0 ] || exit 0
|
|
||||||
stop
|
|
||||||
RETVAL=$?
|
|
||||||
;;
|
|
||||||
reload)
|
|
||||||
[ $running -eq 0 ] || exit 7
|
|
||||||
reload
|
|
||||||
RETVAL=$?
|
|
||||||
;;
|
|
||||||
restart|force-reload)
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
RETVAL=$?
|
|
||||||
;;
|
|
||||||
condrestart|try-restart)
|
|
||||||
[ $running -eq 0 ] || exit 0
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
RETVAL=$?
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
echo -n sendmail; status -p /var/run/sendmail.pid -l sendmail
|
|
||||||
RETVAL=$?
|
|
||||||
echo -n sm-client; status -p /var/run/sm-client.pid -l sm-client
|
|
||||||
[ $RETVAL -eq 0 ] && RETVAL=$?
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
|
|
||||||
RETVAL=2
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit $RETVAL
|
|
16
sendmail.service
Normal file
16
sendmail.service
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Sendmail Mail Transport Agent.
|
||||||
|
After=syslog.target network.target
|
||||||
|
Conflicts=postfix.service exim.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=-/etc/sysconfig/sendmail
|
||||||
|
ExecStartPre=-/etc/mail/make
|
||||||
|
ExecStartPre=-/etc/mail/make aliases
|
||||||
|
ExecStart=/usr/sbin/sendmail $DAEMON $QUEUE $SENDMAIL_OPTARG
|
||||||
|
ExecReload=-/etc/mail/make
|
||||||
|
ExecReload=-/etc/mail/make aliases
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -14,13 +14,13 @@
|
|||||||
Summary: A widely used Mail Transport Agent (MTA)
|
Summary: A widely used Mail Transport Agent (MTA)
|
||||||
Name: sendmail
|
Name: sendmail
|
||||||
Version: 8.14.5
|
Version: 8.14.5
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
License: Sendmail
|
License: Sendmail
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
URL: http://www.sendmail.org/
|
URL: http://www.sendmail.org/
|
||||||
Source0: ftp://ftp.sendmail.org/pub/sendmail/sendmail.%{version}.tar.gz
|
Source0: ftp://ftp.sendmail.org/pub/sendmail/sendmail.%{version}.tar.gz
|
||||||
# init script
|
# Systemd Service file
|
||||||
Source1: sendmail.init
|
Source1: sendmail.service
|
||||||
# NetworkManager dispatch script
|
# NetworkManager dispatch script
|
||||||
Source2: sendmail.nm-dispatcher
|
Source2: sendmail.nm-dispatcher
|
||||||
# script to generate db and cf files
|
# script to generate db and cf files
|
||||||
@ -31,6 +31,8 @@ Source4: sendmail.sysconfig
|
|||||||
Source5: sendmail.etc-mail-Makefile
|
Source5: sendmail.etc-mail-Makefile
|
||||||
# default sendmail.mc
|
# default sendmail.mc
|
||||||
Source6: sendmail-redhat.mc
|
Source6: sendmail-redhat.mc
|
||||||
|
# Systemd Service file
|
||||||
|
Source7: sm-client.service
|
||||||
# pam config
|
# pam config
|
||||||
Source8: sendmail.pam
|
Source8: sendmail.pam
|
||||||
# sasl2 config
|
# sasl2 config
|
||||||
@ -91,11 +93,12 @@ BuildRequires: hesiod-devel
|
|||||||
BuildRequires: groff
|
BuildRequires: groff
|
||||||
BuildRequires: ghostscript
|
BuildRequires: ghostscript
|
||||||
BuildRequires: m4
|
BuildRequires: m4
|
||||||
|
BuildRequires: systemd-units
|
||||||
Provides: MTA smtpdaemon server(smtp)
|
Provides: MTA smtpdaemon server(smtp)
|
||||||
|
Requires(post): systemd-units systemd-sysv chkconfig coreutils %{_sbindir}/alternatives
|
||||||
|
Requires(preun): systemd-units %{_sbindir}/alternatives
|
||||||
|
Requires(postun): systemd-units coreutils %{_sbindir}/alternatives
|
||||||
Requires(pre): shadow-utils
|
Requires(pre): shadow-utils
|
||||||
Requires(preun): %{_sbindir}/alternatives chkconfig
|
|
||||||
Requires(post): %{_sbindir}/alternatives chkconfig coreutils
|
|
||||||
Requires(postun): %{_sbindir}/alternatives coreutils
|
|
||||||
Requires: initscripts
|
Requires: initscripts
|
||||||
Requires: procmail
|
Requires: procmail
|
||||||
Requires: bash >= 2.0
|
Requires: bash >= 2.0
|
||||||
@ -402,13 +405,18 @@ done
|
|||||||
touch %{buildroot}%{maildir}/aliasesdb-stamp
|
touch %{buildroot}%{maildir}/aliasesdb-stamp
|
||||||
|
|
||||||
install -p -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/sendmail
|
install -p -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/sendmail
|
||||||
install -p -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/sendmail
|
|
||||||
install -p -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d/10-sendmail
|
install -p -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d/10-sendmail
|
||||||
install -p -m 755 %{SOURCE3} %{buildroot}%{maildir}/make
|
install -p -m 755 %{SOURCE3} %{buildroot}%{maildir}/make
|
||||||
install -p -m 644 %{SOURCE5} %{buildroot}%{maildir}/Makefile
|
install -p -m 644 %{SOURCE5} %{buildroot}%{maildir}/Makefile
|
||||||
|
|
||||||
chmod 644 %{buildroot}%{maildir}/helpfile
|
chmod 644 %{buildroot}%{maildir}/helpfile
|
||||||
|
|
||||||
|
# Systemd
|
||||||
|
mkdir -p %{buildroot}%{_unitdir}
|
||||||
|
install -m644 %{SOURCE1} %{buildroot}%{_unitdir}
|
||||||
|
install -m644 %{SOURCE7} %{buildroot}%{_unitdir}
|
||||||
|
rm -rf %{buildroot}%{_initrddir}
|
||||||
|
|
||||||
# fix permissions to allow debuginfo extraction and stripping
|
# fix permissions to allow debuginfo extraction and stripping
|
||||||
chmod 755 %{buildroot}%{_sbindir}/{mailstats,makemap,praliases,sendmail,smrsh}
|
chmod 755 %{buildroot}%{_sbindir}/{mailstats,makemap,praliases,sendmail,smrsh}
|
||||||
chmod 755 %{buildroot}%{_bindir}/rmail
|
chmod 755 %{buildroot}%{_bindir}/rmail
|
||||||
@ -467,8 +475,10 @@ getent passwd smmsp >/dev/null || \
|
|||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
if [ "$1" -ge "1" ]; then
|
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||||
%{_initrddir}/sendmail condrestart >/dev/null 2>&1
|
if [ $1 -ge 1 ] ; then
|
||||||
|
/bin/systemctl try-restart sendmail.service >/dev/null 2>&1 || :
|
||||||
|
/bin/systemctl try-restart sm-client.service >/dev/null 2>&1 || :
|
||||||
mta=`readlink %{_sysconfdir}/alternatives/mta`
|
mta=`readlink %{_sysconfdir}/alternatives/mta`
|
||||||
if [ "$mta" == "%{_sbindir}/sendmail.sendmail" ]; then
|
if [ "$mta" == "%{_sbindir}/sendmail.sendmail" ]; then
|
||||||
%{_sbindir}/alternatives --set mta %{_sbindir}/sendmail.sendmail
|
%{_sbindir}/alternatives --set mta %{_sbindir}/sendmail.sendmail
|
||||||
@ -477,7 +487,13 @@ fi
|
|||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
%post
|
%post
|
||||||
/sbin/chkconfig --add sendmail
|
if [ $1 -eq 1 ] ; then
|
||||||
|
# Initial installation
|
||||||
|
/bin/systemctl enable sendmail.service >/dev/null 2>&1 || :
|
||||||
|
/bin/systemctl enable sm-client.service >/dev/null 2>&1 || :
|
||||||
|
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||||
|
fi
|
||||||
|
|
||||||
# Set up the alternatives files for MTAs.
|
# Set up the alternatives files for MTAs.
|
||||||
%{_sbindir}/alternatives --install %{_sbindir}/sendmail mta %{_sbindir}/sendmail.sendmail 90 \
|
%{_sbindir}/alternatives --install %{_sbindir}/sendmail mta %{_sbindir}/sendmail.sendmail 90 \
|
||||||
--slave %{_bindir}/mailq mta-mailq %{_bindir}/mailq.sendmail \
|
--slave %{_bindir}/mailq mta-mailq %{_bindir}/mailq.sendmail \
|
||||||
@ -489,8 +505,9 @@ exit 0
|
|||||||
--slave %{_mandir}/man1/mailq.1.gz mta-mailqman %{_mandir}/man1/mailq.sendmail.1.gz \
|
--slave %{_mandir}/man1/mailq.1.gz mta-mailqman %{_mandir}/man1/mailq.sendmail.1.gz \
|
||||||
--slave %{_mandir}/man1/newaliases.1.gz mta-newaliasesman %{_mandir}/man1/newaliases.sendmail.1.gz \
|
--slave %{_mandir}/man1/newaliases.1.gz mta-newaliasesman %{_mandir}/man1/newaliases.sendmail.1.gz \
|
||||||
--slave %{_mandir}/man5/aliases.5.gz mta-aliasesman %{_mandir}/man5/aliases.sendmail.5.gz \
|
--slave %{_mandir}/man5/aliases.5.gz mta-aliasesman %{_mandir}/man5/aliases.sendmail.5.gz \
|
||||||
--slave %{_mandir}/man8/rmail.8.gz mta-rmailman %{_mandir}/man8/rmail.sendmail.8.gz \
|
--slave %{_mandir}/man8/rmail.8.gz mta-rmailman %{_mandir}/man8/rmail.sendmail.8.gz
|
||||||
--initscript sendmail
|
# it is not yet supported in systemd #714830, #697636
|
||||||
|
# --initscript sendmail
|
||||||
|
|
||||||
# Rebuild maps.
|
# Rebuild maps.
|
||||||
{
|
{
|
||||||
@ -511,8 +528,10 @@ exit 0
|
|||||||
|
|
||||||
%preun
|
%preun
|
||||||
if [ $1 = 0 ]; then
|
if [ $1 = 0 ]; then
|
||||||
%{_initrddir}/sendmail stop >/dev/null 2>&1
|
/bin/systemctl --no-reload sendmail.service > /dev/null 2>&1 || :
|
||||||
/sbin/chkconfig --del sendmail
|
/bin/systemctl stop sendmail.service > /dev/null 2>&1 || :
|
||||||
|
/bin/systemctl --no-reload sm-client.service > /dev/null 2>&1 || :
|
||||||
|
/bin/systemctl stop sm-client.service > /dev/null 2>&1 || :
|
||||||
%{_sbindir}/alternatives --remove mta %{_sbindir}/sendmail.sendmail
|
%{_sbindir}/alternatives --remove mta %{_sbindir}/sendmail.sendmail
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
@ -521,6 +540,14 @@ exit 0
|
|||||||
|
|
||||||
%postun milter -p /sbin/ldconfig
|
%postun milter -p /sbin/ldconfig
|
||||||
|
|
||||||
|
%triggerun -- sendmail < 8.14.5-3
|
||||||
|
%{_bindir}/systemd-sysv-convert --save sendmail >/dev/null 2>&1 ||:
|
||||||
|
/bin/systemctl enable sendmail.service >/dev/null 2>&1
|
||||||
|
/bin/systemctl enable sm-client.service >/dev/null 2>&1
|
||||||
|
/sbin/chkconfig --del sendmail >/dev/null 2>&1 || :
|
||||||
|
/bin/systemctl try-restart sendmail.service >/dev/null 2>&1 || :
|
||||||
|
/bin/systemctl try-restart sm-client.service >/dev/null 2>&1 || :
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
%dir %{_docdir}/sendmail-%{version}
|
%dir %{_docdir}/sendmail-%{version}
|
||||||
@ -595,7 +622,8 @@ exit 0
|
|||||||
%ghost %{maildir}/domaintable.db
|
%ghost %{maildir}/domaintable.db
|
||||||
%ghost %{maildir}/mailertable.db
|
%ghost %{maildir}/mailertable.db
|
||||||
|
|
||||||
%{_initrddir}/sendmail
|
%{_unitdir}/sendmail.service
|
||||||
|
%{_unitdir}/sm-client.service
|
||||||
%config(noreplace) %{_sysconfdir}/sysconfig/sendmail
|
%config(noreplace) %{_sysconfdir}/sysconfig/sendmail
|
||||||
%config(noreplace) %{_sysconfdir}/pam.d/smtp.sendmail
|
%config(noreplace) %{_sysconfdir}/pam.d/smtp.sendmail
|
||||||
%{_sysconfdir}/NetworkManager/dispatcher.d/10-sendmail
|
%{_sysconfdir}/NetworkManager/dispatcher.d/10-sendmail
|
||||||
@ -645,6 +673,9 @@ exit 0
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jun 30 2011 Jóhann B. Guðmundsson <johannbg@gmail.com> - 8.14.5-3
|
||||||
|
- Introduce systemd unit file, drop SysV support
|
||||||
|
|
||||||
* Thu Jun 16 2011 Paul Howarth <paul@city-fan.org> - 8.14.5-2
|
* Thu Jun 16 2011 Paul Howarth <paul@city-fan.org> - 8.14.5-2
|
||||||
- Rebuilt with libdb-5.2
|
- Rebuilt with libdb-5.2
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
DAEMON=yes
|
DAEMON="-bd"
|
||||||
QUEUE=1h
|
QUEUE="-q1h"
|
||||||
|
11
sm-client.service
Normal file
11
sm-client.service
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Sendmail Mail Transport Client.
|
||||||
|
After=syslog.target network.target sendmail.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=-/etc/sysconfig/sendmail
|
||||||
|
ExecStart=/usr/sbin/sendmail -L sm-msp-queue -Ac $QUEUE $SENDMAIL_OPTARG
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user