1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-27 00:57:50 +00:00
freebsd-ports/mail/dovecot-devel/pkg-install
Sergei Kolobov a2d84b3811 - Update to 0.99.10.4
- Improve pkg-install script (create /var/dovecot tree)
- Add pkg-deinstall to cleanup dovecot directories and remove
  created uids at de-install; ask to stop dovecot
  if it's still running
- Make pkg-message obey PREFIX/DOCSDIR
- Make use of USE_OPENLDAP, rename WITH_LDAP2 to more standard WITH_LDAP
- Remove 'Feature Autodetection'. If you want the port built with extra
  dependencies, tell it: avoid bloat
- Update the rc.d script to work with relative addressing
  (e.g. './dovecot.sh start' works.)
- Assign maintainership to the submitter

PR:		59762
Submitted by:	Robin Breathe <robin@isometry.net>
2003-12-08 16:08:14 +00:00

95 lines
2.0 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
base=/var/dovecot
ask() {
local question default answer
question=$1
default=$2
if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then
read -p "${question} [${default}]? " answer
fi
echo ${answer:-${default}}
}
yesno() {
local question default answer
question=$1
default=$2
while :; do
answer=$(ask "${question}" "${default}")
case "${answer}" in
[Yy]*) return 0;;
[Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
make_account() {
local u g gcos
u=$1
g=$2
gcos=$3
if pw group show "${g}" >/dev/null 2>&1; then
echo "You already have a group \"${g}\", so I will use it."
else
echo "You need a group \"${g}\"."
if which -s pw && yesno "Would you like me to create it" y
then
pw groupadd ${g} || exit
echo "Done."
else
echo "Please create it, and try again."
exit 1
fi
fi
if pw user show "${u}" >/dev/null 2>&1; then
echo "You already have a user \"${u}\", so I will use it."
else
echo "You need a user \"${u}\"."
if which -s pw && yesno "Would you like me to create it" y
then
pw useradd ${u} -g ${g} -h - -s /sbin/nologin -c "${gcos}" || exit
echo "Done."
else
echo "Please create it, and try again."
exit 1
fi
fi
}
case $2 in
PRE-INSTALL)
make_account dovecot dovecot "Dovecot"
make_account dovecot-auth dovecot-auth "Dovecot Auth"
;;
POST-INSTALL)
DIRLIST="${base} ${base}/auth ${base}/ssl ${base}/ssl/certs \
${base}/ssl/private ${base}/login /var/run/dovecot"
echo "Fixing ownerships and modes in \"${base}\"."
for directory in ${DIRLIST}; do
if [ ! -d "${directory}" ]; then
mkdir -p ${directory}
echo "Created directory: ${directory}"
fi
done
chown -R root:wheel ${base}
chown -R dovecot:dovecot ${base}/auth ${base}/ssl
chown root:dovecot ${base}/login /var/run/dovecot
chmod 0750 ${base}/login
chmod 0700 /var/run/dovecot
;;
esac