#!/bin/bash
# This software is property of KTC-Karlsruhe Technology Consulting GmbH
# and contains proprietary information that is a trade secret of
# KTC-Karlsruhe Technology Consulting GmbH and is also protected as
# an unpublished work under international copyright laws and treaties.
# 
# Usage of this software is restricted solely to those rights that are
# contained in a prior written agreement with
# KTC-Karlsruhe Technology Consulting GmbH.
# 
# Copyright (c) 2017 KTC-Karlsruhe Technology Consulting GmbH
# All rights reserved
# 
# Copyright Version: 1.0
# 
# ----------------
# Date: 2017-04-27

# 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
