#! /bin/sh

# Script that is executed whenever a new user is deleted from
# the external user source, such as an Active Directory tree or
# /etc/passwd.

# This script executes all scripts in @USERSCRIPTDIR@/deleteuser.d
# using find.  The environment variable KOPANO_USER is set, but beware
# that this string can contain any characters, so take heed to correct
# quoting.

KOPANO_USER_SCRIPTS=@USERSCRIPTDIR@/deleteuser.d
PATH=/bin:/usr/local/bin:/usr/bin
export PATH
if [ -z "${KOPANO_USER}" -a -z "${KOPANO_STOREGUID}" ] ; then
    exec >&2
    echo "KOPANO_USER and KOPANO_STOREGUID is not set."
    exit 1
fi
exec "/usr/local/libexec/kopano/kscriptrun" /usr/local/lib/kopano/userscripts/deleteuser.d /etc/kopano/userscripts/deleteuser.d
