aboutsummaryrefslogtreecommitdiffstats
path: root/mail/postfix-current/pkg-install
diff options
context:
space:
mode:
Diffstat (limited to 'mail/postfix-current/pkg-install')
-rw-r--r--mail/postfix-current/pkg-install132
1 files changed, 90 insertions, 42 deletions
diff --git a/mail/postfix-current/pkg-install b/mail/postfix-current/pkg-install
index 03d6d352e37d..b2b0e42a0332 100644
--- a/mail/postfix-current/pkg-install
+++ b/mail/postfix-current/pkg-install
@@ -5,10 +5,6 @@
PKG_PREFIX=${PKG_PREFIX:=/usr/local}
-user=postfix
-group=postfix
-group2=maildrop
-
ask() {
local question default answer
@@ -24,74 +20,126 @@ ask() {
}
yesno() {
- local dflt question answer
+ local question default answer
question=$1
- dflt=$2
+ default=$2
while :; do
- answer=$(ask "${question}" "${dflt}")
+ answer=$(ask "${question}" "${default}")
case "${answer}" in
- [Yy]*) return 0;;
- [Nn]*) return 1;;
+ [Yy]*) return 0;;
+ [Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
if [ x"$2" = xPRE-INSTALL ]; then
- if /usr/sbin/pw groupshow "${group}" 2>/dev/null; then
- echo "You already have a group \"${group}\", so I will use it."
+ USER=postfix
+ GROUP=postfix
+ GROUP2=maildrop
+
+ if /usr/sbin/pw groupshow "${GROUP}" 2>/dev/null; then
+ echo "You already have a group \"${GROUP}\", so I will use it."
else
- echo "You need a group \"${group}\"."
- if yesno "Would you like me to create it" y; then
- /usr/sbin/pw groupadd ${group} -h - || exit
- echo "Done."
- else
+ if /usr/sbin/pw groupadd ${GROUP} -h -
+ then
+ echo "Added group \"${GROUP}\"."
+ else
+ echo "Adding group \"${GROUP}\" failed..."
echo "Please create it, and try again."
exit 1
fi
fi
- if /usr/sbin/pw groupshow "${group2}" 2>/dev/null; then
- echo "You already have a group \"${group2}\", so I will use it."
+ if /usr/sbin/pw groupshow "${GROUP2}" 2>/dev/null; then
+ echo "You already have a group \"${GROUP2}\", so I will use it."
else
- echo "You need a group \"${group2}\"."
- if yesno "Would you like me to create it" y; then
- /usr/sbin/pw groupadd ${group2} -h - || exit
- echo "Done."
- else
+ if /usr/sbin/pw groupadd ${GROUP2} -h -
+ then
+ echo "Added group \"${GROUP2}\"."
+ else
+ echo "Adding group \"${GROUP2}\" failed..."
echo "Please create it, and try again."
exit 1
fi
fi
- if /usr/sbin/pw user show "${user}" 2>/dev/null; then
- echo "You already have a user \"${user}\", so I will use it."
+ if /usr/sbin/pw user show "${USER}" 2>/dev/null; then
+ echo "You already have a user \"${USER}\", so I will use it."
else
- echo "You need a user \"${user}\"."
- if yesno "Would you like me to create it" y; then
- /usr/sbin/pw useradd ${user} -g ${group} -h - -d /nonexistent \
- -s /nonexistent -c "Postfix Mail System" || exit
- echo "Done."
- else
+ if /usr/sbin/pw useradd ${USER} -g ${GROUP} -h - \
+ -d /var/spool/postfix \
+ -s /sbin/nologin \
+ -c "Postfix Mail System"
+ then
+ echo "Added user \"${USER}\"."
+ else
+ echo "Adding user \"${USER}\" failed..."
echo "Please create it, and try again."
exit 1
fi
fi
-
fi
if [ x"$2" = xPOST-INSTALL ]; then
- if [ ! -e ${PKG_PREFIX}/etc/postfix/main.cf ]; then
- cp -p ${PKG_PREFIX}/etc/postfix/sample-main.cf \
- ${PKG_PREFIX}/etc/postfix/main.cf
+ sh ${PKG_PREFIX}/etc/postfix/post-install tempdir=/tmp \
+ config_directory=${PKG_PREFIX}/etc/postfix \
+ daemon_directory=${PKG_PREFIX}/libexec/postfix \
+ command_directory=${PKG_PREFIX}/sbin \
+ queue_directory=/var/spool/postfix \
+ sendmail_path=${PKG_PREFIX}/sbin/sendmail \
+ newaliases_path=${PKG_PREFIX}/bin/newaliases \
+ mailq_path=${PKG_PREFIX}/bin/mailq \
+ mail_owner=postfix \
+ setgid_group=maildrop \
+ manpage_directory=${PKG_PREFIX}/man \
+ sample_directory=${PKG_PREFIX}/etc/postfix \
+ readme_directory=no \
+ upgrade-package
+# readme_directory is "no" above since the package will have correct perms
+# already, and we don't know if they had PORTDOCS.
+fi
+
+replace() {
+ local orig repl
+
+ orig=$1
+ repl=$2
+ if [ -e ${orig} ]; then
+ mv -f ${orig} ${orig}.OFF
+ chmod 0 ${orig}.OFF
fi
- if [ ! -e ${PKG_PREFIX}/etc/postfix/master.cf ]; then
- cp -p ${PKG_PREFIX}/etc/postfix/sample-master.cf \
- ${PKG_PREFIX}/etc/postfix/master.cf
+ if [ -e ${repl} ]; then
+ ln -s ${repl} ${orig}
+ fi
+}
+
+if [ x"$2" = xPOST-INSTALL -a -z "${PACKAGE_BUILDING}" ]; then
+ if [ -x /sbin/sysctl ]; then
+ OSVERSION=`/sbin/sysctl -n kern.osreldate`
+ else
+ OSVERSION=`/usr/sbin/sysctl -n kern.osreldate`
+ fi
+ if [ ${OSVERSION} -ge 400014 ]; then
+ if yesno "Would you like to activate Postfix in /etc/mail/mailer.conf" n; then
+ mv -f /etc/mail/mailer.conf /etc/mail/mailer.conf.old
+ echo "#" > /etc/mail/mailer.conf
+ echo -n "# Execute the Postfix sendmail program" >> /etc/mail/mailer.conf
+ echo ", named ${PKG_PREFIX}/sbin/sendmail" >> /etc/mail/mailer.conf
+ echo "#" >> /etc/mail/mailer.conf
+ echo "sendmail ${PKG_PREFIX}/sbin/sendmail" >> /etc/mail/mailer.conf
+ echo "send-mail ${PKG_PREFIX}/sbin/sendmail" >> /etc/mail/mailer.conf
+ echo "mailq ${PKG_PREFIX}/sbin/sendmail" >> /etc/mail/mailer.conf
+ echo "newaliases ${PKG_PREFIX}/sbin/sendmail" >> /etc/mail/mailer.conf
+ echo "Done."
+ fi
+ else
+ if yesno "Would you like to replace {sendmail,mailq,newaliases} with Postfix versions" n; then
+ replace /usr/sbin/sendmail ${PKG_PREFIX}/sbin/sendmail
+ replace /usr/bin/mailq ${PKG_PREFIX}/sbin/sendmail
+ replace /usr/bin/newaliases ${PKG_PREFIX}/sbin/sendmail
+ echo "Done."
+ fi
fi
- /usr/sbin/chown root:maildrop ${PKG_PREFIX}/sbin/postdrop
- /bin/chmod 2555 ${PKG_PREFIX}/sbin/postdrop
- /bin/mkdir -p /var/spool/postfix
- ${PKG_PREFIX}/sbin/postfix check
fi