1999-03-29 20:15:09 +00:00
|
|
|
#!/bin/sh
|
2001-03-04 19:35:00 +00:00
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
2003-07-10 07:12:46 +00:00
|
|
|
# If the POSTFIX_DEFAULT_MTA environment variable is set to YES, it
|
2004-06-11 14:41:47 +00:00
|
|
|
# will make the port/package use defaults which make postfix replace
|
2003-07-10 07:12:46 +00:00
|
|
|
# sendmail as much as possible.
|
|
|
|
|
2001-03-04 19:35:00 +00:00
|
|
|
PKG_PREFIX=${PKG_PREFIX:=/usr/local}
|
2002-04-20 18:27:48 +00:00
|
|
|
BATCH=${BATCH:=no}
|
2003-07-10 07:12:46 +00:00
|
|
|
POSTFIX_DEFAULT_MTA=${POSTFIX_DEFAULT_MTA:=no}
|
|
|
|
|
|
|
|
if [ x${POSTFIX_DEFAULT_MTA} = xno ]; then
|
2005-03-19 23:17:54 +00:00
|
|
|
DEFAULT_REPLACE_MAILERCONF=n
|
2003-07-10 07:12:46 +00:00
|
|
|
else
|
2005-03-19 23:17:54 +00:00
|
|
|
DEFAULT_REPLACE_MAILERCONF=y
|
2003-07-10 07:12:46 +00:00
|
|
|
fi
|
1999-03-29 20:15:09 +00:00
|
|
|
|
2004-04-13 15:08:15 +00:00
|
|
|
if [ -x /usr/sbin/nologin ]; then
|
2005-03-19 23:17:54 +00:00
|
|
|
NOLOGIN=/usr/sbin/nologin
|
2004-04-13 15:08:15 +00:00
|
|
|
else
|
2005-03-19 23:17:54 +00:00
|
|
|
NOLOGIN=/sbin/nologin
|
2004-04-13 15:08:15 +00:00
|
|
|
fi
|
|
|
|
|
1999-03-29 20:15:09 +00:00
|
|
|
ask() {
|
2005-03-19 23:17:54 +00:00
|
|
|
local question default answer
|
|
|
|
|
|
|
|
question=$1
|
|
|
|
default=$2
|
|
|
|
if [ -z "${PACKAGE_BUILDING}" -a x${BATCH} = xno ]; then
|
2005-04-05 22:03:14 +00:00
|
|
|
read -p "${question} [${default}]? " answer
|
2005-03-19 23:17:54 +00:00
|
|
|
fi
|
|
|
|
if [ x${answer} = x ]; then
|
|
|
|
answer=${default}
|
|
|
|
fi
|
2005-09-11 21:42:42 +00:00
|
|
|
echo ${answer}
|
1999-03-29 20:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yesno() {
|
2005-03-19 23:17:54 +00:00
|
|
|
local question default answer
|
|
|
|
|
|
|
|
question=$1
|
|
|
|
default=$2
|
|
|
|
while :; do
|
|
|
|
answer=$(ask "${question}" "${default}")
|
|
|
|
case "${answer}" in
|
|
|
|
[Yy]*) return 0;;
|
|
|
|
[Nn]*) return 1;;
|
|
|
|
esac
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Please answer yes or no."
|
2005-03-19 23:17:54 +00:00
|
|
|
done
|
1999-03-29 20:15:09 +00:00
|
|
|
}
|
|
|
|
|
2000-02-13 20:17:43 +00:00
|
|
|
if [ x"$2" = xPRE-INSTALL ]; then
|
2005-03-19 23:17:54 +00:00
|
|
|
USER=postfix
|
|
|
|
UID=125
|
|
|
|
GROUP=postfix
|
|
|
|
GID=125
|
|
|
|
GROUP2=maildrop
|
|
|
|
GID2=126
|
|
|
|
|
|
|
|
if /usr/sbin/pw groupshow "${GROUP}" 2>/dev/null; then
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "You already have a group \"${GROUP}\", so I will use it."
|
2002-01-30 19:59:40 +00:00
|
|
|
else
|
2006-07-19 12:59:11 +00:00
|
|
|
if /usr/sbin/pw groupadd ${GROUP} -g ${GID}; then
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Added group \"${GROUP}\"."
|
2005-03-19 23:17:54 +00:00
|
|
|
else
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Adding group \"${GROUP}\" failed..."
|
|
|
|
echo "Please create it, and try again."
|
2005-03-19 23:17:54 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if /usr/sbin/pw groupshow "${GROUP2}" 2>/dev/null; then
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "You already have a group \"${GROUP2}\", so I will use it."
|
2002-01-30 19:59:40 +00:00
|
|
|
else
|
2005-03-19 23:17:54 +00:00
|
|
|
if /usr/sbin/pw groupadd ${GROUP2} -g ${GID2}; then
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Added group \"${GROUP2}\"."
|
2005-03-19 23:17:54 +00:00
|
|
|
else
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Adding group \"${GROUP2}\" failed..."
|
|
|
|
echo "Please create it, and try again."
|
2005-03-19 23:17:54 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if /usr/sbin/pw user show "${USER}" 2>/dev/null; then
|
2006-07-19 12:59:11 +00:00
|
|
|
echo "You already have a user \"${USER}\", so I will use it."
|
2002-01-30 19:59:40 +00:00
|
|
|
else
|
2005-03-19 23:17:54 +00:00
|
|
|
if /usr/sbin/pw useradd ${USER} -u ${UID} -g ${GROUP} -h - -d /var/spool/postfix -s ${NOLOGIN} -c "Postfix Mail System"; then
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Added user \"${USER}\"."
|
2005-03-19 23:17:54 +00:00
|
|
|
else
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Adding user \"${USER}\" failed..."
|
|
|
|
echo "Please create it, and try again."
|
2005-03-19 23:17:54 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if /usr/sbin/pw show group mail | grep -q "${USER}" 2>/dev/null; then
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "You already have user \"${USER}\" in group \"mail\", so I will use it."
|
2005-03-19 23:17:54 +00:00
|
|
|
else
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "You need user \"${USER}\" added to group \"mail\"."
|
2005-03-19 23:17:54 +00:00
|
|
|
if yesno "Would you like me to add it" y; then
|
|
|
|
/usr/sbin/pw groupmod mail -m ${USER} || exit
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Done."
|
2005-03-19 23:17:54 +00:00
|
|
|
else
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Please create it, and try again."
|
2005-03-19 23:17:54 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
1999-03-29 20:15:09 +00:00
|
|
|
fi
|
|
|
|
|
2000-02-13 20:17:43 +00:00
|
|
|
if [ x"$2" = xPOST-INSTALL ]; then
|
2005-03-19 23:17:54 +00:00
|
|
|
if [ -d ${PKG_PREFIX}/etc/postfix/dist ]; then
|
|
|
|
for file in ${PKG_PREFIX}/etc/postfix/dist/*; do
|
|
|
|
if [ ! -f ${PKG_PREFIX}/etc/postfix/${file#${PKG_PREFIX}/etc/postfix/dist} ]; then
|
|
|
|
cp $file ${PKG_PREFIX}/etc/postfix/
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
/bin/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
|
|
|
|
fi
|
2002-01-30 19:59:40 +00:00
|
|
|
# readme_directory is "no" above since the package will have correct perms
|
|
|
|
# already, and we don't know if they had PORTDOCS.
|
|
|
|
|
|
|
|
replace() {
|
2005-03-19 23:17:54 +00:00
|
|
|
local orig repl
|
|
|
|
|
|
|
|
orig=$1
|
|
|
|
repl=$2
|
|
|
|
if [ -e ${orig} ]; then
|
|
|
|
/bin/mv -f ${orig} ${orig}.OFF
|
|
|
|
/bin/chmod 0 ${orig}.OFF
|
|
|
|
fi
|
|
|
|
if [ -e ${repl} ]; then
|
|
|
|
/bin/ln -s ${repl} ${orig}
|
|
|
|
fi
|
2002-01-30 19:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ x"$2" = xPOST-INSTALL -a -z "${PACKAGE_BUILDING}" ]; then
|
2005-03-19 23:17:54 +00:00
|
|
|
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" ${DEFAULT_REPLACE_MAILERCONF}; then
|
2006-07-19 12:59:11 +00:00
|
|
|
/bin/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
|
2005-03-19 23:17:54 +00:00
|
|
|
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
|
2005-09-11 21:42:42 +00:00
|
|
|
echo "Done."
|
2005-03-19 23:17:54 +00:00
|
|
|
fi
|
|
|
|
fi
|
2000-02-13 20:17:43 +00:00
|
|
|
fi
|