#! /bin/sh # # $FreeBSD: ports/mail/postgrey/files/pkg-install.in,v 1.1 2007/06/27 21:13:24 beech Exp $ PATH=/bin:/usr/bin:/usr/sbin case $2 in PRE-INSTALL) echo "---> Starting install script:" if [ -z "/var/db/postgrey" -o \ -z "postgrey" -o -z "postgrey" -o \ -z "225" -o -z "225" ]; then echo "ERROR: A required pragma was empty" exit 1 fi # Create group if required if pw group show "postgrey" >/dev/null 2>&1; then echo "---> Using existing group \"postgrey\"" else echo "---> Adding group \"postgrey\" (225)" /usr/sbin/pw groupadd postgrey -g 225 || exit 1 fi # Create user if required if pw user show "postgrey" >/dev/null 2>&1; then echo "---> Using existing user \"postgrey\"" else echo "---> Adding user \"postgrey\" (225)" pw useradd "postgrey" -u "225" -g "postgrey" -h - \ -d "/var/db/postgrey" -s "/sbin/nologin" -c "Postgrey Owner" || exit 1 fi # Create home directory if required if [ -d "/var/db/postgrey" ]; then echo "---> Using existing Postgrey database directory (/var/db/postgrey)" echo " (There may be existing active postgrey databases - this installation" echo " will attempt to preserve them.)" else echo "---> Creating Postgrey database directory (/var/db/postgrey)" (umask 002 && /bin/mkdir -p "/var/db/postgrey") || exit 1 /usr/sbin/chown -R "postgrey:postgrey" "/var/db/postgrey" || exit 1 /bin/chmod g+s "/var/db/postgrey" || exit 1 fi ;; POST-INSTALL) echo "---> Starting post-install script:" for i in whitelist_clients whitelist_recipients; do if [ ! -f "/usr/local/etc/postfix/postgrey_${i}" ]; then echo "---> Installing new config file /usr/local/etc/postfix/postgrey_${i}" cp -p /usr/local/etc/postfix/dist-postgrey_${i} \ /usr/local/etc/postfix/postgrey_${i} else echo "---> Keeping existing config file /usr/local/etc/postfix/postgrey_${i}" fi done ;; esac