- rework pkg-install and pkg-message [1]

- install postfix specific mailer.conf.postfix into DATADIR [2]

- use new notation instead PATCH_DIST_STRIP

- bump PORTREVISION

1) detect if the port is installed without TERM, in this case
   do not ask the to make postfix the default mailer and respect
   the env POSTFIX_DEFAULT_MTA. This helps tools like salt,
   ansible, cfengine and puppet during the first package installation.

2) $DATADIR/mailer.conf.postfix can be used by the tools in 1)

MFH:		2016Q1
This commit is contained in:
Olli Hauer 2016-01-04 10:33:26 +00:00
parent 28eb67e0f7
commit 8c3dbcf8bd
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=405234
5 changed files with 71 additions and 43 deletions

View file

@ -3,6 +3,7 @@
PORTNAME= postfix
PORTVERSION= 2.11.7
PORTREVISION= 1
PORTEPOCH= 1
CATEGORIES= mail ipv6
MASTER_SITES= ftp://ftp.porcupine.org/mirrors/postfix-release/ \
@ -122,7 +123,7 @@ DAEMONDIR= ${PREFIX}/libexec/postfix
SUB_LIST+= REQUIRE="${_REQUIRE}" READMEDIR="${READMEDIR}" \
DAEMONDIR="${DAEMONDIR}"
SUB_FILES+= pkg-install pkg-message
SUB_FILES+= pkg-install pkg-message mailer.conf.postfix
POSTFIX_CCARGS+= -DDEF_CONFIG_DIR=\\\"${ETCDIR}\\\" \
-DDEF_DAEMON_DIR=\\\"${DAEMONDIR}\\\" \
@ -181,8 +182,7 @@ POSTFIX_CCARGS+= -DNO_TLS
.if ${PORT_OPTIONS:MSPF}
PATCH_SITES+= LOCAL/mm
PATCHFILES+= postfix-2.8.0-libspf2-1.2.x-0.patch.gz
PATCH_DIST_STRIP= -p1
PATCHFILES+= postfix-2.8.0-libspf2-1.2.x-0.patch.gz:-p1
POSTFIX_CCARGS+= -DHAVE_NS_TYPE -DHAS_SPF -I${LOCALBASE}/include
POSTFIX_AUXLIBS+= -L${LOCALBASE}/lib -lspf2
.endif
@ -237,9 +237,8 @@ _REQUIRE+= ypserv
.endif
.if ${PORT_OPTIONS:MVDA}
PATCH_SITES+= http://vda.sourceforge.net/VDA/:vda
PATCH_SITES+= http://vda.sourceforge.net/VDA/:-p1:vda
PATCHFILES+= postfix-vda-v13-${VDAVERSION}.patch:vda
PATCH_DIST_STRIP= -p1
.endif
.if ${PORT_OPTIONS:MTEST}
@ -348,6 +347,8 @@ post-stage:
# == do not overwrite existing config
${MV} ${STAGEDIR}${ETCDIR}/main.cf ${STAGEDIR}${ETCDIR}/main.cf.sample
${MV} ${STAGEDIR}${ETCDIR}/master.cf ${STAGEDIR}${ETCDIR}/master.cf.sample
${MKDIR} ${STAGEDIR}${DATADIR}
${INSTALL_DATA} ${WRKDIR}/mailer.conf.postfix ${STAGEDIR}${DATADIR}
# Fix compressed man pages and strip executables
${SED} -i '' -E -e "s|(man[158]/.*.[158]):|\1.gz:|g" ${STAGEDIR}${DAEMONDIR}/postfix-files

View file

@ -0,0 +1,7 @@
#
# Execute the Postfix sendmail program, named %%PREFIX%%/sbin/sendmail
#
sendmail %%PREFIX%%/sbin/sendmail
send-mail %%PREFIX%%/sbin/sendmail
mailq %%PREFIX%%/sbin/sendmail
newaliases %%PREFIX%%/sbin/sendmail

View file

@ -7,13 +7,17 @@
# will make the port/package use defaults which make postfix replace
# sendmail as much as possible.
PREFIX=${PKG_PREFIX:=%%PREFIX%%}
ETCDIR=${ETCDIR:=%%ETCDIR%%}
DAEMONDIR=${DAEMONDIR:=%%DAEMONDIR%%}
READMEDIR=${READMEDIR:=%%READMEDIR%%}
# allowed vars during package installation
BATCH=${BATCH:=no}
POSTFIX_DEFAULT_MTA=${POSTFIX_DEFAULT_MTA:=no}
MC=/etc/mail/mailer.conf
# fixed vars
PREFIX="%%PREFIX%%"
ETCDIR="%%ETCDIR%%"
DAEMONDIR="%%DAEMONDIR%%"
READMEDIR="%%READMEDIR%%"
MCP="%%DATADIR%%/mailer.conf.postfix"
MC="/etc/mail/mailer.conf"
if [ "${POSTFIX_DEFAULT_MTA}" = "no" ]; then
DEFAULT_REPLACE_MAILERCONF=n
@ -21,12 +25,6 @@ else
DEFAULT_REPLACE_MAILERCONF=y
fi
if [ -x /usr/sbin/nologin ]; then
NOLOGIN=/usr/sbin/nologin
else
NOLOGIN=/sbin/nologin
fi
ask() {
local question default answer
@ -56,6 +54,25 @@ yesno() {
done
}
install_mailer_conf() {
echo "Activate Postfix in ${MC}"
/bin/mv -f ${MC} ${MC}.old
/usr/bin/install -m 644 ${MCP} ${MC}
}
show_not_activated_msg() {
echo
echo "==============================================================="
echo "Postfix was *not* activated in /etc/mail/mailer.conf! "
echo
echo "To finish installation run the following commands:"
echo
echo " mv ${MC} ${MC}.old"
echo " install -m 0644 ${MCP} ${MC}"
echo "==============================================================="
echo
}
if [ "$2" = "POST-INSTALL" ]; then
/bin/sh ${DAEMONDIR}/post-install tempdir=/tmp \
daemon_directory=${DAEMONDIR} \
@ -71,18 +88,22 @@ if [ "$2" = "POST-INSTALL" -a -z "${PACKAGE_BUILDING}" -a -f "${MC}" ]; then
egrep -q "^newaliases.*${PREFIX}/sbin/sendmail" ${MC}
ret=$?
if [ ${ret} -ne 0 ]; then
if yesno "Would you like to activate Postfix in ${MC}" ${DEFAULT_REPLACE_MAILERCONF}; then
/bin/mv -f ${MC} ${MC}.old
echo "#" > ${MC}
echo -n "# Execute the Postfix sendmail program" >> ${MC}
echo ", named ${PREFIX}/sbin/sendmail" >> ${MC}
echo "#" >> ${MC}
echo "sendmail ${PREFIX}/sbin/sendmail" >> ${MC}
echo "send-mail ${PREFIX}/sbin/sendmail" >> ${MC}
echo "mailq ${PREFIX}/sbin/sendmail" >> ${MC}
echo "newaliases ${PREFIX}/sbin/sendmail" >> ${MC}
# Respect POSTFIX_DEFAULT_MTA, do not ask for confirmation!
# (This helps tools like salt, ansible or puppet on new installations)
if [ "${DEFAULT_REPLACE_MAILERCONF}" = "y" ]; then
install_mailer_conf
elif [ "${DEFAULT_REPLACE_MAILERCONF}" = "n" -a -t 0 ]; then
if yesno "Would you like to activate Postfix in ${MC}" ${DEFAULT_REPLACE_MAILERCONF:="n"}; then
install_mailer_conf
else
show_not_activated_msg
fi
else
show_not_activated_msg
fi
else
echo "==============================================================="
echo "Postfix already activated in ${MC}"
echo "==============================================================="
fi
fi

View file

@ -1,27 +1,25 @@
To enable postfix startup script please add postfix_enable="YES" in
your rc.conf
To use postfix instead of sendmail:
- clear sendmail queue and stop the sendmail daemons
If you not need sendmail anymore, please add in your rc.conf:
Run the following commands to enable postfix during startup:
- sysrc postfix_enable="YES"
- sysrc sendmail_enable="NONE"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
If postfix is *not* already activated in /etc/mail/mailer.conf
- mv /etc/mail/mailer.conf /etc/mail/mailer.conf.old
- install -m 0644 %%DAEMONDIR%%/mailer.conf.postfix /etc/mail/mailer.conf
And you can disable some sendmail specific daily maintenance routines in your
/etc/periodic.conf file:
daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"
If /etc/periodic.conf does not exist please create it and add those values.
Disable sendmail(8) specific tasks,
add the following lines to /etc/periodic.conf(.local):
daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"
If you are using SASL, you need to make sure that postfix has access to read
the sasldb file. This is accomplished by adding postfix to group mail and
making the %%PREFIX%%/etc/sasldb* file(s) readable by group mail (this should
be the default for new installs).
If you are upgrading from Postfix 2.6 or earlier, review the RELEASE_NOTES to
If you are upgrading from prior postfix version, review the RELEASE_NOTES to
familiarize yourself with new features and incompatabilities.

View file

@ -137,6 +137,7 @@ sbin/postmulti
sbin/postsuper
sbin/posttls-finger
sbin/sendmail
%%DATADIR%%/mailer.conf.postfix
@dir %%PFETC%%
@dir(postfix,,700) /var/db/postfix
@dir(postfix,,700) /var/spool/postfix/active