#!/bin/bash

# VERSION is needed for some tools to recognize that as a join script
VERSION=1
. /usr/share/univention-appcenter/joinscripthelper.sh
. /usr/share/univention-lib/all.sh
joinscript_init

APP="wildfly"
SERVICE="$APP"
ldapBase=`ucr get ldap/base`

eval "$(ucr shell)"

ucs_removeServiceFromLocalhost "$SERVICE" "$@" || die

if ucs_isServiceUnused "$SERVICE" "$@"
then
  udm users/user remove "$@" --dn "uid=$APP-systemuser,cn=users,$ldap_base"
fi

# do NOT call "joinscript_save_current_version"
# otherwise an entry will be appended to /var/univenion-join/status
# instead the join script needs to be removed from the status file
joinscript_remove_script_from_status_file wildfly
exit 0
