- 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 PORTNAME= postfix
PORTVERSION= 2.11.7 PORTVERSION= 2.11.7
PORTREVISION= 1
PORTEPOCH= 1 PORTEPOCH= 1
CATEGORIES= mail ipv6 CATEGORIES= mail ipv6
MASTER_SITES= ftp://ftp.porcupine.org/mirrors/postfix-release/ \ MASTER_SITES= ftp://ftp.porcupine.org/mirrors/postfix-release/ \
@ -122,7 +123,7 @@ DAEMONDIR= ${PREFIX}/libexec/postfix
SUB_LIST+= REQUIRE="${_REQUIRE}" READMEDIR="${READMEDIR}" \ SUB_LIST+= REQUIRE="${_REQUIRE}" READMEDIR="${READMEDIR}" \
DAEMONDIR="${DAEMONDIR}" DAEMONDIR="${DAEMONDIR}"
SUB_FILES+= pkg-install pkg-message SUB_FILES+= pkg-install pkg-message mailer.conf.postfix
POSTFIX_CCARGS+= -DDEF_CONFIG_DIR=\\\"${ETCDIR}\\\" \ POSTFIX_CCARGS+= -DDEF_CONFIG_DIR=\\\"${ETCDIR}\\\" \
-DDEF_DAEMON_DIR=\\\"${DAEMONDIR}\\\" \ -DDEF_DAEMON_DIR=\\\"${DAEMONDIR}\\\" \
@ -181,8 +182,7 @@ POSTFIX_CCARGS+= -DNO_TLS
.if ${PORT_OPTIONS:MSPF} .if ${PORT_OPTIONS:MSPF}
PATCH_SITES+= LOCAL/mm PATCH_SITES+= LOCAL/mm
PATCHFILES+= postfix-2.8.0-libspf2-1.2.x-0.patch.gz PATCHFILES+= postfix-2.8.0-libspf2-1.2.x-0.patch.gz:-p1
PATCH_DIST_STRIP= -p1
POSTFIX_CCARGS+= -DHAVE_NS_TYPE -DHAS_SPF -I${LOCALBASE}/include POSTFIX_CCARGS+= -DHAVE_NS_TYPE -DHAS_SPF -I${LOCALBASE}/include
POSTFIX_AUXLIBS+= -L${LOCALBASE}/lib -lspf2 POSTFIX_AUXLIBS+= -L${LOCALBASE}/lib -lspf2
.endif .endif
@ -237,9 +237,8 @@ _REQUIRE+= ypserv
.endif .endif
.if ${PORT_OPTIONS:MVDA} .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 PATCHFILES+= postfix-vda-v13-${VDAVERSION}.patch:vda
PATCH_DIST_STRIP= -p1
.endif .endif
.if ${PORT_OPTIONS:MTEST} .if ${PORT_OPTIONS:MTEST}
@ -348,6 +347,8 @@ post-stage:
# == do not overwrite existing config # == do not overwrite existing config
${MV} ${STAGEDIR}${ETCDIR}/main.cf ${STAGEDIR}${ETCDIR}/main.cf.sample ${MV} ${STAGEDIR}${ETCDIR}/main.cf ${STAGEDIR}${ETCDIR}/main.cf.sample
${MV} ${STAGEDIR}${ETCDIR}/master.cf ${STAGEDIR}${ETCDIR}/master.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 # Fix compressed man pages and strip executables
${SED} -i '' -E -e "s|(man[158]/.*.[158]):|\1.gz:|g" ${STAGEDIR}${DAEMONDIR}/postfix-files ${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 # will make the port/package use defaults which make postfix replace
# sendmail as much as possible. # sendmail as much as possible.
PREFIX=${PKG_PREFIX:=%%PREFIX%%} # allowed vars during package installation
ETCDIR=${ETCDIR:=%%ETCDIR%%}
DAEMONDIR=${DAEMONDIR:=%%DAEMONDIR%%}
READMEDIR=${READMEDIR:=%%READMEDIR%%}
BATCH=${BATCH:=no} BATCH=${BATCH:=no}
POSTFIX_DEFAULT_MTA=${POSTFIX_DEFAULT_MTA:=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 if [ "${POSTFIX_DEFAULT_MTA}" = "no" ]; then
DEFAULT_REPLACE_MAILERCONF=n DEFAULT_REPLACE_MAILERCONF=n
@ -21,12 +25,6 @@ else
DEFAULT_REPLACE_MAILERCONF=y DEFAULT_REPLACE_MAILERCONF=y
fi fi
if [ -x /usr/sbin/nologin ]; then
NOLOGIN=/usr/sbin/nologin
else
NOLOGIN=/sbin/nologin
fi
ask() { ask() {
local question default answer local question default answer
@ -56,6 +54,25 @@ yesno() {
done 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 if [ "$2" = "POST-INSTALL" ]; then
/bin/sh ${DAEMONDIR}/post-install tempdir=/tmp \ /bin/sh ${DAEMONDIR}/post-install tempdir=/tmp \
daemon_directory=${DAEMONDIR} \ 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} egrep -q "^newaliases.*${PREFIX}/sbin/sendmail" ${MC}
ret=$? ret=$?
if [ ${ret} -ne 0 ]; then if [ ${ret} -ne 0 ]; then
if yesno "Would you like to activate Postfix in ${MC}" ${DEFAULT_REPLACE_MAILERCONF}; then # Respect POSTFIX_DEFAULT_MTA, do not ask for confirmation!
/bin/mv -f ${MC} ${MC}.old # (This helps tools like salt, ansible or puppet on new installations)
echo "#" > ${MC} if [ "${DEFAULT_REPLACE_MAILERCONF}" = "y" ]; then
echo -n "# Execute the Postfix sendmail program" >> ${MC} install_mailer_conf
echo ", named ${PREFIX}/sbin/sendmail" >> ${MC} elif [ "${DEFAULT_REPLACE_MAILERCONF}" = "n" -a -t 0 ]; then
echo "#" >> ${MC} if yesno "Would you like to activate Postfix in ${MC}" ${DEFAULT_REPLACE_MAILERCONF:="n"}; then
echo "sendmail ${PREFIX}/sbin/sendmail" >> ${MC} install_mailer_conf
echo "send-mail ${PREFIX}/sbin/sendmail" >> ${MC} else
echo "mailq ${PREFIX}/sbin/sendmail" >> ${MC} show_not_activated_msg
echo "newaliases ${PREFIX}/sbin/sendmail" >> ${MC} fi
else
show_not_activated_msg
fi fi
else else
echo "==============================================================="
echo "Postfix already activated in ${MC}" echo "Postfix already activated in ${MC}"
echo "==============================================================="
fi fi
fi fi

View file

@ -1,27 +1,25 @@
To enable postfix startup script please add postfix_enable="YES" in To use postfix instead of sendmail:
your rc.conf - 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" If postfix is *not* already activated in /etc/mail/mailer.conf
sendmail_submit_enable="NO" - mv /etc/mail/mailer.conf /etc/mail/mailer.conf.old
sendmail_outbound_enable="NO" - install -m 0644 %%DAEMONDIR%%/mailer.conf.postfix /etc/mail/mailer.conf
sendmail_msp_queue_enable="NO"
And you can disable some sendmail specific daily maintenance routines in your Disable sendmail(8) specific tasks,
/etc/periodic.conf file: add the following lines to /etc/periodic.conf(.local):
daily_clean_hoststat_enable="NO"
daily_clean_hoststat_enable="NO" daily_status_mail_rejects_enable="NO"
daily_status_mail_rejects_enable="NO" daily_status_include_submit_mailq="NO"
daily_status_include_submit_mailq="NO" daily_submit_queuerun="NO"
daily_submit_queuerun="NO"
If /etc/periodic.conf does not exist please create it and add those values.
If you are using SASL, you need to make sure that postfix has access to read 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 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 making the %%PREFIX%%/etc/sasldb* file(s) readable by group mail (this should
be the default for new installs). 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. familiarize yourself with new features and incompatabilities.

View file

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