Refactor kc.sh, kcadm.sh and kcreg.sh scripts, make kc.sh POSIX shell compatible (#21124)
Closes #22041
This commit is contained in:
parent
0536078282
commit
d50fa65247
3 changed files with 46 additions and 63 deletions
|
@ -1,36 +1,31 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
case "`uname`" in
|
case "$(uname)" in
|
||||||
CYGWIN*)
|
CYGWIN*)
|
||||||
CFILE = `cygpath "$0"`
|
CFILE="$(cygpath "$0")"
|
||||||
RESOLVED_NAME=`readlink -f "$CFILE"`
|
RESOLVED_NAME="$(readlink -f "$CFILE")"
|
||||||
;;
|
;;
|
||||||
Darwin*)
|
Darwin*)
|
||||||
RESOLVED_NAME=`readlink "$0"`
|
RESOLVED_NAME="$(readlink "$0")"
|
||||||
;;
|
|
||||||
FreeBSD)
|
|
||||||
RESOLVED_NAME=`readlink -f "$0"`
|
|
||||||
;;
|
;;
|
||||||
OpenBSD)
|
OpenBSD)
|
||||||
RESOLVED_NAME=`readlink -f "$0"`
|
RESOLVED_NAME="$(readlink -f "$0")"
|
||||||
JAVA_HOME=`/usr/local/bin/javaPathHelper -h keycloak`
|
JAVA_HOME="$(/usr/local/bin/javaPathHelper -h keycloak)"
|
||||||
;;
|
;;
|
||||||
Linux)
|
FreeBSD | Linux)
|
||||||
RESOLVED_NAME=`readlink -f "$0"`
|
RESOLVED_NAME="$(readlink -f "$0")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "x$RESOLVED_NAME" = "x" ]; then
|
RESOLVED_NAME="${RESOLVED_NAME:-"$0"}"
|
||||||
RESOLVED_NAME="$0"
|
|
||||||
fi
|
|
||||||
|
|
||||||
DIRNAME=`dirname "$RESOLVED_NAME"`
|
DIRNAME="$(dirname "$RESOLVED_NAME")"
|
||||||
|
|
||||||
if [ "x$JAVA" = "x" ]; then
|
if [ -z "$JAVA" ]; then
|
||||||
if [ "x$JAVA_HOME" != "x" ]; then
|
if [ -n "$JAVA_HOME" ]; then
|
||||||
JAVA="$JAVA_HOME/bin/java"
|
JAVA="$JAVA_HOME/bin/java"
|
||||||
else
|
else
|
||||||
JAVA="java"
|
JAVA="java"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$JAVA" $KC_OPTS -cp $DIRNAME/client/keycloak-admin-cli-${project.version}.jar --add-opens=java.base/java.security=ALL-UNNAMED -Dkc.lib.dir=$DIRNAME/client/lib org.keycloak.client.admin.cli.KcAdmMain "$@"
|
exec "$JAVA" $KC_OPTS -cp $DIRNAME/client/keycloak-admin-cli-${project.version}.jar --add-opens=java.base/java.security=ALL-UNNAMED -Dkc.lib.dir=$DIRNAME/client/lib org.keycloak.client.admin.cli.KcAdmMain "$@"
|
||||||
|
|
|
@ -1,35 +1,30 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
case "`uname`" in
|
case "$(uname)" in
|
||||||
CYGWIN*)
|
CYGWIN*)
|
||||||
CFILE = `cygpath "$0"`
|
CFILE="$(cygpath "$0")"
|
||||||
RESOLVED_NAME=`readlink -f "$CFILE"`
|
RESOLVED_NAME="$(readlink -f "$CFILE")"
|
||||||
;;
|
;;
|
||||||
Darwin*)
|
Darwin*)
|
||||||
RESOLVED_NAME=`readlink "$0"`
|
RESOLVED_NAME="$(readlink "$0")"
|
||||||
;;
|
|
||||||
FreeBSD)
|
|
||||||
RESOLVED_NAME=`readlink -f "$0"`
|
|
||||||
;;
|
;;
|
||||||
OpenBSD)
|
OpenBSD)
|
||||||
RESOLVED_NAME=`readlink -f "$0"`
|
RESOLVED_NAME="$(readlink -f "$0")"
|
||||||
JAVA_HOME=`/usr/local/bin/javaPathHelper -h keycloak`
|
JAVA_HOME="$(/usr/local/bin/javaPathHelper -h keycloak)"
|
||||||
;;
|
;;
|
||||||
Linux)
|
FreeBSD | Linux)
|
||||||
RESOLVED_NAME=`readlink -f "$0"`
|
RESOLVED_NAME="$(readlink -f "$0")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "x$RESOLVED_NAME" = "x" ]; then
|
RESOLVED_NAME="${RESOLVED_NAME:-"$0"}"
|
||||||
RESOLVED_NAME="$0"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "x$JAVA" = "x" ]; then
|
if [ -z "$JAVA" ]; then
|
||||||
if [ "x$JAVA_HOME" != "x" ]; then
|
if [ -n "$JAVA_HOME" ]; then
|
||||||
JAVA="$JAVA_HOME/bin/java"
|
JAVA="$JAVA_HOME/bin/java"
|
||||||
else
|
else
|
||||||
JAVA="java"
|
JAVA="java"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DIRNAME=`dirname "$RESOLVED_NAME"`
|
DIRNAME="$(dirname "$RESOLVED_NAME")"
|
||||||
"$JAVA" $KC_OPTS -cp $DIRNAME/client/keycloak-client-registration-cli-${project.version}.jar --add-opens=java.base/java.security=ALL-UNNAMED -Dkc.lib.dir=$DIRNAME/client/lib org.keycloak.client.registration.cli.KcRegMain "$@"
|
exec "$JAVA" $KC_OPTS -cp $DIRNAME/client/keycloak-client-registration-cli-${project.version}.jar --add-opens=java.base/java.security=ALL-UNNAMED -Dkc.lib.dir=$DIRNAME/client/lib org.keycloak.client.registration.cli.KcRegMain "$@"
|
||||||
|
|
47
quarkus/dist/src/main/content/bin/kc.sh
vendored
47
quarkus/dist/src/main/content/bin/kc.sh
vendored
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$(uname)" in
|
||||||
CYGWIN*)
|
CYGWIN*)
|
||||||
|
@ -21,9 +21,7 @@ case "$(uname)" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "x$RESOLVED_NAME" = "x" ]; then
|
RESOLVED_NAME="${RESOLVED_NAME:-"$0"}"
|
||||||
RESOLVED_NAME="$0"
|
|
||||||
fi
|
|
||||||
|
|
||||||
GREP="grep"
|
GREP="grep"
|
||||||
DIRNAME="$(dirname "$RESOLVED_NAME")"
|
DIRNAME="$(dirname "$RESOLVED_NAME")"
|
||||||
|
@ -53,7 +51,7 @@ do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--debug)
|
--debug)
|
||||||
DEBUG_MODE=true
|
DEBUG_MODE=true
|
||||||
if [ -n "$2" ] && [[ "$2" =~ ^[0-9]+$ ]]; then
|
if [ -n "$2" ] && expr "$2" : '[0-9]\+$' >/dev/null; then
|
||||||
DEBUG_PORT=$2
|
DEBUG_PORT=$2
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
@ -63,22 +61,18 @@ do
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ $1 = --* || ! $1 =~ ^-D.* ]]; then
|
case "$1" in
|
||||||
if [[ "$1" = "start-dev" ]]; then
|
start-dev) CONFIG_ARGS="$CONFIG_ARGS --profile=dev $1";;
|
||||||
CONFIG_ARGS="$CONFIG_ARGS --profile=dev $1"
|
-D*) SERVER_OPTS="$SERVER_OPTS $1";;
|
||||||
else
|
*) CONFIG_ARGS="$CONFIG_ARGS $1";;
|
||||||
CONFIG_ARGS="$CONFIG_ARGS $1"
|
esac
|
||||||
fi
|
|
||||||
else
|
|
||||||
SERVER_OPTS="$SERVER_OPTS $1"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "x$JAVA" = "x" ]; then
|
if [ -z "$JAVA" ]; then
|
||||||
if [ "x$JAVA_HOME" != "x" ]; then
|
if [ -n "$JAVA_HOME" ]; then
|
||||||
JAVA="$JAVA_HOME/bin/java"
|
JAVA="$JAVA_HOME/bin/java"
|
||||||
else
|
else
|
||||||
JAVA="java"
|
JAVA="java"
|
||||||
|
@ -88,7 +82,7 @@ fi
|
||||||
#
|
#
|
||||||
# Specify options to pass to the Java VM.
|
# Specify options to pass to the Java VM.
|
||||||
#
|
#
|
||||||
if [ "x$JAVA_OPTS" = "x" ]; then
|
if [ -z "$JAVA_OPTS" ]; then
|
||||||
# The defaults set up Keycloak with '-XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90' which proved to provide a good throughput and efficiency in the total memory allocation and CPU overhead.
|
# The defaults set up Keycloak with '-XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90' which proved to provide a good throughput and efficiency in the total memory allocation and CPU overhead.
|
||||||
# If the memory is not used, it will be freed. See https://developers.redhat.com/blog/2017/04/04/openjdk-and-containers for details.
|
# If the memory is not used, it will be freed. See https://developers.redhat.com/blog/2017/04/04/openjdk-and-containers for details.
|
||||||
# To optimize for large heap sizes or for throughput and better response time due to shorter GC pauses, consider ZGC and Shenandoah GC.
|
# To optimize for large heap sizes or for throughput and better response time due to shorter GC pauses, consider ZGC and Shenandoah GC.
|
||||||
|
@ -99,14 +93,14 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# See also https://github.com/wildfly/wildfly-core/blob/7e5624cf92ebe4b64a4793a8c0b2a340c0d6d363/core-feature-pack/common/src/main/resources/content/bin/common.sh#L57-L60
|
# See also https://github.com/wildfly/wildfly-core/blob/7e5624cf92ebe4b64a4793a8c0b2a340c0d6d363/core-feature-pack/common/src/main/resources/content/bin/common.sh#L57-L60
|
||||||
if [ "x$JAVA_ADD_OPENS" = "x" ]; then
|
if [ -z "$JAVA_ADD_OPENS" ]; then
|
||||||
JAVA_ADD_OPENS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED"
|
JAVA_ADD_OPENS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED"
|
||||||
else
|
else
|
||||||
echo "JAVA_ADD_OPENS already set in environment; overriding default settings with values: $JAVA_ADD_OPENS"
|
echo "JAVA_ADD_OPENS already set in environment; overriding default settings with values: $JAVA_ADD_OPENS"
|
||||||
fi
|
fi
|
||||||
JAVA_OPTS="$JAVA_OPTS $JAVA_ADD_OPENS"
|
JAVA_OPTS="$JAVA_OPTS $JAVA_ADD_OPENS"
|
||||||
|
|
||||||
if [ "x$JAVA_OPTS_APPEND" != "x" ]; then
|
if [ -n "$JAVA_OPTS_APPEND" ]; then
|
||||||
echo "Appending additional Java properties to JAVA_OPTS: $JAVA_OPTS_APPEND"
|
echo "Appending additional Java properties to JAVA_OPTS: $JAVA_OPTS_APPEND"
|
||||||
JAVA_OPTS="$JAVA_OPTS $JAVA_OPTS_APPEND"
|
JAVA_OPTS="$JAVA_OPTS $JAVA_OPTS_APPEND"
|
||||||
fi
|
fi
|
||||||
|
@ -114,7 +108,7 @@ fi
|
||||||
# Set debug settings if not already set
|
# Set debug settings if not already set
|
||||||
if [ "$DEBUG_MODE" = "true" ]; then
|
if [ "$DEBUG_MODE" = "true" ]; then
|
||||||
DEBUG_OPT="$(echo "$JAVA_OPTS" | $GREP "\-agentlib:jdwp")"
|
DEBUG_OPT="$(echo "$JAVA_OPTS" | $GREP "\-agentlib:jdwp")"
|
||||||
if [ "x$DEBUG_OPT" = "x" ]; then
|
if [ -z "$DEBUG_OPT" ]; then
|
||||||
JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=$DEBUG_SUSPEND"
|
JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=$DEBUG_SUSPEND"
|
||||||
else
|
else
|
||||||
echo "Debug already enabled in JAVA_OPTS, ignoring --debug argument"
|
echo "Debug already enabled in JAVA_OPTS, ignoring --debug argument"
|
||||||
|
@ -128,13 +122,12 @@ if [ "$PRINT_ENV" = "true" ]; then
|
||||||
echo "Using JAVA_RUN_OPTS: $JAVA_RUN_OPTS"
|
echo "Using JAVA_RUN_OPTS: $JAVA_RUN_OPTS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ (! $CONFIG_ARGS = *"--optimized"*) ]] && [[ ! "$CONFIG_ARGS" == " build"* ]] && [[ ! "$CONFIG_ARGS" == *"-h" ]] && [[ ! "$CONFIG_ARGS" == *"--help"* ]]; then
|
case "$CONFIG_ARGS" in
|
||||||
eval "'$JAVA'" -Dkc.config.build-and-exit=true $JAVA_RUN_OPTS
|
" build"* | *--optimized* | *-h | *--help*) ;;
|
||||||
EXIT_CODE=$?
|
*)
|
||||||
|
eval "'$JAVA'" -Dkc.config.build-and-exit=true $JAVA_RUN_OPTS || exit $?
|
||||||
JAVA_RUN_OPTS="-Dkc.config.built=true $JAVA_RUN_OPTS"
|
JAVA_RUN_OPTS="-Dkc.config.built=true $JAVA_RUN_OPTS"
|
||||||
if [ $EXIT_CODE != 0 ]; then
|
;;
|
||||||
exit $EXIT_CODE
|
esac
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
eval exec "'$JAVA'" $JAVA_RUN_OPTS
|
eval exec "'$JAVA'" $JAVA_RUN_OPTS
|
||||||
|
|
Loading…
Reference in a new issue