#!/bin/sh

VERSION=1

. /usr/share/univention-lib/base.sh
. /usr/share/univention-lib/ldap.sh
. /usr/share/univention-join/joinscripthelper.lib

joinscript_init

SERVICE="SuiteCRM"

eval "$(univention-config-registry shell)"

ucs_removeServiceFromLocalhost "${SERVICE}" "$@"

if ucs_isServiceUnused "${SERVICE}" "$@"; then
       univention-directory-manager container/cn remove "$@" --dn "cn=DIGITEC SuiteCRM Attributes,cn=custom attributes,cn=univention,$ldap_base"

       stop_udm_cli_server
fi

# Remove old join script from index file otherwise the re-installation will not work
joinscript_remove_script_from_status_file digitec-suitecrm

exit 0
