#! /bin/sh
# $FreeBSD#

PATH=/bin:/usr/bin:/usr/sbin

MKDIR="/bin/mkdir -p"
CHOWN="/usr/sbin/chown"
CHMOD="/bin/chmod"

DBDIR="/var/db/pootle"
LOGDIR="/var/log/pootle"
RUNDIR="/var/run/pootle"

UID="nobody"
GID="nobody"

case $2 in

POST-INSTALL)
	for DIR in ${LOGDIR} ${DBDIR} ${RUNDIR}; do
	  if [ ! -d ${DIR} ]; then
	    echo "===> Creating directory ${DIR}"
	    ${MKDIR} ${DIR}
	    echo "===> Changing ownership of ${DIR}"
	    ${CHOWN} -R ${UID}:${GID} ${DIR}
	    echo "===> Changing permissions of ${DIR}"
	    ${CHMOD} -R 770 ${DIR}
	  fi
	done
	;;
esac
