#!/bin/sh
#
# Request a new activated UCS license
#
# SPDX-FileCopyrightText: 2014-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

# shellcheck source=../scripts/setup_utils.sh
. /usr/lib/univention-system-setup/scripts/setup_utils.sh

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

if [ "$server_role" = "domaincontroller_master" ] && email=$(get_profile_var email_address) && [ -n "$email" ]; then
	echo "Activating the UCS license with the email address $email..."
	/usr/sbin/umc-command -r -U "${hostname:?}\$" -y /etc/machine.secret udm/request_new_license -f license-request -o email="$email"
	echo "... done"
fi

exit 0
