mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-21 04:06:46 +00:00
e81e3cf827
- Add new options KQUEUE & SQLITE PR: ports/93250 Submitted by: maintainer
92 lines
1.7 KiB
Bash
92 lines
1.7 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
# ex:ts=4
|
|
|
|
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} -c "${gcos}" -d /nonexistent -s /sbin/nologin -h - || 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"
|
|
;;
|
|
|
|
POST-INSTALL)
|
|
base=/var/run/dovecot
|
|
DIRLIST="${base} ${base}/login"
|
|
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}
|
|
chmod -R 0700 ${base}
|
|
chown -R root:dovecot ${base}/login
|
|
chmod -R 0750 ${base}/login
|
|
;;
|
|
|
|
esac
|