#!/bin/sh
# $FreeBSD: /tmp/pcvs/ports/net/freeswitch-core-devel/files/pkg-install.in,v 1.2 2012-05-22 19:12:47 crees Exp $
#

if [ "$2" != "POST-INSTALL" ]; then
	exit 0
fi

for dir in \
    etc/freeswitch/conf/directory/default \
    etc/freeswitch/scripts \
    share/freeswitch/sounds
	do install -d -o freeswitch -g freeswitch ${PKG_PREFIX}/$dir
done

find ${PKG_PREFIX}/etc/freeswitch/ -type d -exec chmod 770 {} +
find ${PKG_PREFIX}/etc/freeswitch/ -type f -exec chmod 660 {} +
/usr/sbin/chown -R freeswitch:freeswitch \
		/usr/local/etc/freeswitch /usr/local/share/freeswitch \
                ${PKG_PREFIX}/include/freeswitch \
                ${PKG_PREFIX}/lib/freeswitch

chmod 775 ${PKG_PREFIX}/share/freeswitch

for dir in \
    db/freeswitch \
    freeswitch/recordings \
    log/freeswitch/xml_cdr 
	do install -d -m 775 -o freeswitch -g freeswitch /var/$dir
done

echo "This port chown -R various directories freeswitch:freeswitch"
echo "This port chmod -R 770 various directories"
echo "This port chmod -R 660 various files"
echo "This is for security reasons.  In the event something should"
echo "stop working, please take the time to check the following dirs:"
echo " /var/log/freeswitch /var/freeswitch"

exit 0
