#!/bin/sh

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

USERS_HOME="/var/spool/ejabberd"

install -d -m 750 -o %%USERS%% -g %%GROUPS%% ${USERS_HOME} /var/log/ejabberd /var/run/ejabberdctl

chown -R %%USERS%%:%%GROUPS%%  %%PREFIX%%/etc/%%PORTNAME%%
chown -R %%USERS%%:%%GROUPS%%  %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%%

find %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%% -type f -print0 | xargs -0 chmod %%SHAREMODE%%
find %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%% -type f -print0 | xargs -0 chown %%SHAREOWN%%:%%SHAREGRP%%

%%PAM%%chmod 4750 %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%%/lib/epam-%%EPAM_VER%%/priv/bin/epam \
%%PAM%%	     %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%%/priv/bin/epam
%%PAM%%chown root:%%GROUPS%% %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%%/lib/epam-%%EPAM_VER%%/priv/bin/epam \
%%PAM%%	     %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%%/priv/bin/epam

chmod +x %%PREFIX%%/%%EJABBERD_LIBDIR%%/%%PORTNAME%%-%%PORTVERSION%%/lib/eimp-%%EIMP_VER%%/priv/bin/eimp

exit 0
