#! /bin/sh # # $FreeBSD: ports/mail/sqlgrey/files/pkg-install.in,v 1.2 2006/11/06 19:46:25 alepulver Exp $ PATH=/bin:/usr/bin:/usr/sbin case $2 in POST-INSTALL) echo "---> Starting install script:" if [ -z "sqlgrey" -o -z "sqlgrey" ]; then echo "ERROR: A required pragma was empty" exit 1 fi # Create group if required if /usr/sbin/pw group show "sqlgrey" >/dev/null 2>&1; then echo "---> Using existing group \"sqlgrey\"" else echo "---> Adding group \"sqlgrey\"" /usr/sbin/pw groupadd sqlgrey || exit 1 fi # Create user if required if /usr/sbin/pw user show "sqlgrey" >/dev/null 2>&1; then echo "---> Using existing user \"sqlgrey\"" else echo "---> Adding user \"sqlgrey\"" /usr/sbin/pw useradd "sqlgrey" -g "sqlgrey" -h - \ -d "/usr/local/share/sqlgrey" -s "/sbin/nologin" -c "Sqlgrey Owner" || exit 1 fi # Create home directory if required if [ -d "/usr/local/share/sqlgrey" ]; then echo "---> Using existing Sqlgrey database directory (/usr/local/share/sqlgrey)" echo " (There may be existing active sqlgrey databases - this installation" echo " will attempt to preserve them.)" else echo "---> Creating Sqlgrey database directory (/usr/local/share/sqlgrey)" (umask 002 && /bin/mkdir -p "/usr/local/share/sqlgrey") || exit 1 /usr/sbin/chown -R "sqlgrey:sqlgrey" "/usr/local/share/sqlgrey" || exit 1 /bin/chmod g+s "/usr/local/share/sqlgrey" || exit 1 fi ;; POST-DEINSTALL) echo "---> Please, remember to remove the user and the group with :" if /usr/sbin/pw user show "sqlgrey" >/dev/null 2>&1; then echo " /usr/sbin/pw userdel -n sqlgrey" fi if /usr/sbin/pw group show "sqlgrey" >/dev/null 2>&1; then echo " /usr/sbin/pw groupdel -n sqlgrey" fi echo " as well as the databases." echo " If you're only updating, you can leave the things as they are." ;; esac