#!/bin/sh
# $FreeBSD: ports/net/freeswitch-core/files/pkg-install.in,v 1.4 2011/10/28 21:56:51 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

for dir in etc/freeswitch include/freeswitch lib/freeswitch share/freeswitch
	do chown freeswitch:freeswitch ${PKG_PREFIX}/$dir
done

find ${PKG_PREFIX}/etc/freeswitch/ -type d -exec chmod 755 {} +
chmod 775 ${PKG_PREFIX}/share/freeswitch

# @cwd /var

for dir in \
    db/freeswitch \
    freeswitch/recordings \
    log/freeswitch/xml_cdr \
    spool/freeswitch/voicemail
	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 775 various directories"
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/spool/freeswitch /var/log/freeswitch /var/freeswitch"

exit 0
