fix check for postifx installed before systemd migration [release 2.11.3-3mamba;Wed Jan 14 2015]

This commit is contained in:
Silvan Calarco 2024-01-06 10:26:06 +01:00
parent 5bc4a583da
commit 4b433d1ec7
3 changed files with 45 additions and 110 deletions

View File

@ -1,100 +0,0 @@
#!/bin/bash
#
# /etc/rc.d/init.d/postfix
#
# Copyright (c) 2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# Start/stop the postscript mail daemon
#
# chkconfig: 345 30 60
# description: The postfix mail daemon
# processname: postfix
# Source function library.
. /etc/rc.d/init.d/functions
PROGNAME=postfix
test -x /usr/sbin/$PROGNAME || exit 0
RETVAL=0
#
# See how we were called.
#
start() {
echo -n "Starting $PROGNAME: "
/usr/sbin/$PROGNAME start
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROGNAME
evaluate_retval
echo
return $RETVAL
}
stop() {
if [[ -f /var/lock/subsys/$PROGNAME ]]; then
echo -n "Stopping $PROGNAME: "
/usr/sbin/$PROGNAME stop
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROGNAME
evaluate_retval
echo
return $RETVAL
fi
}
reload() {
/usr/sbin/$PROGNAME reload
}
flush() {
/usr/sbin/$PROGNAME flush
}
check() {
/usr/sbin/$PROGNAME check
}
abort() {
/usr/sbin/$PROGNAME abort
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
abort)
abort
;;
flush)
flush
;;
check)
check
;;
condrestart)
if [ -f /var/lock/subsys/$PROGNAME ]; then
restart
fi
;;
status)
status $PROGNAME
;;
*)
INITNAME=`basename $0`
echo "Usage: $INITNAME {start|stop|restart|reload|condrestart|abort|flush|check|status}"
exit 1
esac
exit $RETVAL

12
postfix.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Postfix Mail Daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/sbin/postfix start
ExecStop=/usr/sbin/postfix stop
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -9,7 +9,7 @@
Name: postfix
Version: 2.11.3
Release: 1mamba
Release: 3mamba
Summary: A fast, easy to administer, and secure mail transfer agent
Group: System/Servers
Vendor: openmamba
@ -17,7 +17,7 @@ Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: http://www.postfix.org
Source: ftp://ftp.porcupine.org/mirrors/postfix-release/official/%{name}-%{version}.tar.gz
Source1: %{name}-initscript
Source1: postfix.service
Source2: %{name}-mysql_virtual_alias_maps.cf
Source3: %{name}-mysql_virtual_domains_maps.cf
Source4: %{name}-mysql_virtual_mailbox_maps.cf
@ -37,10 +37,10 @@ BuildRequires: libsasl-devel
BuildRequires: libz-devel
BuildRequires: mysql-client
## AUTOBUILDREQ-END
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Provides: mta
Provides: /usr/lib/sendmail
%systemd_requires
%description
Postfix attempts to be fast, easy to administer, and secure, while at the same time being sendmail compatible enough to not upset existing users.
@ -78,7 +78,7 @@ sh ./postfix-install \
install_root=%{buildroot} \
-non-interactive
install -D -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/postfix
install -D -m0755 %{SOURCE1} %{buildroot}%{_unitdir}/postfix.service
mv %{buildroot}%{_sysconfdir}/postfix/aliases %{buildroot}%{_sysconfdir}/
@ -137,8 +137,10 @@ install -m 0640 %{SOURCE7} %{buildroot}%{_sysconfdir}/postfix/mysql-tables.txt
exit 0
%post
%systemd_post postfix
if [ $1 -eq 1 ]; then
/sbin/service postfix start
systemctl -q enable postfix
systemctl -q start postfix
fi
if [ $1 -ge 1 ]; then
/usr/sbin/groupadd nobody -g %{nobodygroupid} 2>/dev/null
@ -150,23 +152,38 @@ if [ $1 -ge 1 ]; then
postalias /etc/aliases
# sysv -> systemd upgrade
if [ -L /etc/rc.d/rc5.d/S30postfix -o -L /etc/rc.d/rc3.d/S30postfix ]; then
systemctl -q enable postfix
systemctl -q restart postfix
fi
# new install
#if [ $1 -eq 1 ]; then
# sed -i "s|#myhostname .*|myhostname = `hostname -f`|;
# S|#mydomain .*|mydomain = `hostname -d`|" /etc/postfix/main.cf
#fi
fi
exit 0
:
%preun
%systemd_preun postfix
# erase
if [ $1 -eq 0 ]; then
/sbin/service postfix stop
/sbin/chkconfig --del postfix
systemctl -q stop postfix
systemctl -q disable postfix
/usr/sbin/userdel postfix 2>/dev/null
/usr/sbin/groupdel %{postdrop_groupid} 2>/dev/null
fi
exit 0
:
%postun
%systemd_postun_with_restart postfix
:
%posttrans
find /etc/rc[0-6].d/ -type l -xtype l -exec rm -f {} \;
:
%pre virtualdomains-mysql
/usr/sbin/groupadd vmail -g %{vmail_groupid} 2>/dev/null
@ -237,7 +254,6 @@ exit 0
%attr(-,root,postfix) %config(noreplace) %{_sysconfdir}/postfix/transport
%attr(-,root,postfix) %config(noreplace) %{_sysconfdir}/postfix/virtual
%{_sysconfdir}/postfix/TLS_LICENSE
%{_initrddir}/postfix
%{_bindir}/mailq
%{_bindir}/newaliases
%{_libexecdir}/postfix/*
@ -255,6 +271,7 @@ exit 0
%attr(2755,root,postdrop) %{_sbindir}/postqueue
%{_sbindir}/postsuper
%{_sbindir}/sendmail
%{_unitdir}/postfix.service
%{_datadir}/%{name}-%{version}/html/*
%{_mandir}/man1/*
%{_mandir}/man5/*
@ -285,6 +302,12 @@ exit 0
%attr(0771,vmail,vmail) %dir %{_localstatedir}/spool/deleted-maildirs
%changelog
* Wed Jan 14 2015 Silvan Calarco <silvan.calarco@mambasoft.it> 2.11.3-3mamba
- fix check for postifx installed before systemd migration
* Sun Jan 11 2015 Silvan Calarco <silvan.calarco@mambasoft.it> 2.11.3-2mamba
- systemd switch
* Mon Oct 20 2014 Automatic Build System <autodist@mambasoft.it> 2.11.3-1mamba
- automatic version update by autodist