#!/bin/sh
# $FreeBSD: ports/mail/majordomo/pkg-install,v 1.1 2007/03/01 20:56:42 anders Exp $

MAJORDOMOUSER=majordom
MAJORDOMOGROUP=majordom
UID=54
GID=$UID

case $2 in
PRE-INSTALL|ADDUSER)
	if ! pw groupshow ${MAJORDOMOGROUP} 2>/dev/null 1>&2; then
		if pw groupadd ${MAJORDOMOGROUP} -g $GID; then
			echo "=> Added group \"${MAJORDOMOGROUP}\"."
		else
			echo "=> Adding group \"${MAJORDOMOGROUP}\" failed..."
			exit 1
		fi
	fi

	if ! pw usershow ${MAJORDOMOUSER} 2>/dev/null 1>&2; then
		if pw useradd ${MAJORDOMOUSER} -u $UID -g ${MAJORDOMOGROUP} -h - \
			-s "/nonexistent" -d "/usr/local/majordomo" \
			-c "Majordomo Pseudo User"; \
		then
			pw groupmod ${MAJORDOMOGROUP} -m ${MAJORDOMOUSER}
			echo "=> Added user \"${MAJORDOMOUSER}\"."
		else
			echo "=> Adding user \"${MAJORDOMOUSER}\" failed..."
			exit 1
		fi
	fi
	;;
POST-INSTALL)
	# Add misc empty dirs, correct permissions
	for dir in tmp lists/test-l.archive lists/test-l-digest.archive digests/test-l-digest doc; do
		mkdir -p ${PKG_PREFIX}/majordomo/$dir
	done
	chown -R majordom:majordom ${PKG_PREFIX}/majordomo
	chmod 700 ${PKG_PREFIX}/majordomo/tmp
	chmod 755 ${PKG_PREFIX}/majordomo
	for dir in digests lists/*.archive digests/test-l-digest doc; do
		chmod 775 ${PKG_PREFIX}/majordomo/$dir
	done
	chmod 755 ${PKG_PREFIX}/majordomo/lists ${PKG_PREFIX}/majordomo
	;;
esac

exit 0


syntax highlighted by Code2HTML, v. 0.9.1