#!/bin/bash
#
# Copyright (c) 2024, 2025 Contributors to the Eclipse Foundation
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0, which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
# version 2 with the GNU Classpath Exception, which is available at
# https://www.gnu.org/software/classpath/license.html.
#
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#

AS_CONFIG="$(dirname "$(realpath "$0")")/../glassfish/config"
AS_CONFIG_SH="${AS_CONFIG}/config.sh"
source "${AS_CONFIG_SH}" "$AS_CONFIG" || { echo "${AS_CONFIG_SH} not found" >&2; exit 1; }
export ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$ASADMIN_CLASSPATH"
exec "$JAVA" ${ASADMIN_JVM_OPTIONS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain "$@"
