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
|
||||
case "`uname`" in
|
||||
case "$(uname)" in
|
||||
CYGWIN*)
|
||||
CFILE = `cygpath "$0"`
|
||||
RESOLVED_NAME=`readlink -f "$CFILE"`
|
||||
CFILE="$(cygpath "$0")"
|
||||
RESOLVED_NAME="$(readlink -f "$CFILE")"
|
||||
;;
|
||||
Darwin*)
|
||||
RESOLVED_NAME=`readlink "$0"`
|
||||
;;
|
||||
FreeBSD)
|
||||
RESOLVED_NAME=`readlink -f "$0"`
|
||||
RESOLVED_NAME="$(readlink "$0")"
|
||||
;;
|
||||
OpenBSD)
|
||||
RESOLVED_NAME=`readlink -f "$0"`
|
||||
JAVA_HOME=`/usr/local/bin/javaPathHelper -h keycloak`
|
||||
RESOLVED_NAME="$(readlink -f "$0")"
|
||||
JAVA_HOME="$(/usr/local/bin/javaPathHelper -h keycloak)"
|
||||
;;
|
||||
Linux)
|
||||
RESOLVED_NAME=`readlink -f "$0"`
|
||||
FreeBSD | Linux)
|
||||
RESOLVED_NAME="$(readlink -f "$0")"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "x$RESOLVED_NAME" = "x" ]; then
|
||||
RESOLVED_NAME="$0"
|
||||
fi
|
||||
RESOLVED_NAME="${RESOLVED_NAME:-"$0"}"
|
||||
|
||||
DIRNAME=`dirname "$RESOLVED_NAME"`
|
||||
DIRNAME="$(dirname "$RESOLVED_NAME")"
|
||||
|
||||
if [ "x$JAVA" = "x" ]; then
|
||||
if [ "x$JAVA_HOME" != "x" ]; then
|
||||
if [ -z "$JAVA" ]; then
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
JAVA="$JAVA_HOME/bin/java"
|
||||
else
|
||||
JAVA="java"
|
||||
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
|
||||
case "`uname`" in
|
||||
case "$(uname)" in
|
||||
CYGWIN*)
|
||||
CFILE = `cygpath "$0"`
|
||||
RESOLVED_NAME=`readlink -f "$CFILE"`
|
||||
CFILE="$(cygpath "$0")"
|
||||
RESOLVED_NAME="$(readlink -f "$CFILE")"
|
||||
;;
|
||||
Darwin*)
|
||||
RESOLVED_NAME=`readlink "$0"`
|
||||
;;
|
||||
FreeBSD)
|
||||
RESOLVED_NAME=`readlink -f "$0"`
|
||||
RESOLVED_NAME="$(readlink "$0")"
|
||||
;;
|
||||
OpenBSD)
|
||||
RESOLVED_NAME=`readlink -f "$0"`
|
||||
JAVA_HOME=`/usr/local/bin/javaPathHelper -h keycloak`
|
||||
RESOLVED_NAME="$(readlink -f "$0")"
|
||||
JAVA_HOME="$(/usr/local/bin/javaPathHelper -h keycloak)"
|
||||
;;
|
||||
Linux)
|
||||
RESOLVED_NAME=`readlink -f "$0"`
|
||||
FreeBSD | Linux)
|
||||
RESOLVED_NAME="$(readlink -f "$0")"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "x$RESOLVED_NAME" = "x" ]; then
|
||||
RESOLVED_NAME="$0"
|
||||
fi
|
||||
RESOLVED_NAME="${RESOLVED_NAME:-"$0"}"
|
||||
|
||||
if [ "x$JAVA" = "x" ]; then
|
||||
if [ "x$JAVA_HOME" != "x" ]; then
|
||||
if [ -z "$JAVA" ]; then
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
JAVA="$JAVA_HOME/bin/java"
|
||||
else
|
||||
JAVA="java"
|
||||
fi
|
||||
fi
|
||||
|
||||
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 "$@"
|
||||
DIRNAME="$(dirname "$RESOLVED_NAME")"
|
||||
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
|
||||
CYGWIN*)
|
||||
|
@ -21,9 +21,7 @@ case "$(uname)" in
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ "x$RESOLVED_NAME" = "x" ]; then
|
||||
RESOLVED_NAME="$0"
|
||||
fi
|
||||
RESOLVED_NAME="${RESOLVED_NAME:-"$0"}"
|
||||
|
||||
GREP="grep"
|
||||
DIRNAME="$(dirname "$RESOLVED_NAME")"
|
||||
|
@ -53,7 +51,7 @@ do
|
|||
case "$1" in
|
||||
--debug)
|
||||
DEBUG_MODE=true
|
||||
if [ -n "$2" ] && [[ "$2" =~ ^[0-9]+$ ]]; then
|
||||
if [ -n "$2" ] && expr "$2" : '[0-9]\+$' >/dev/null; then
|
||||
DEBUG_PORT=$2
|
||||
shift
|
||||
fi
|
||||
|
@ -63,22 +61,18 @@ do
|
|||
break
|
||||
;;
|
||||
*)
|
||||
if [[ $1 = --* || ! $1 =~ ^-D.* ]]; then
|
||||
if [[ "$1" = "start-dev" ]]; then
|
||||
CONFIG_ARGS="$CONFIG_ARGS --profile=dev $1"
|
||||
else
|
||||
CONFIG_ARGS="$CONFIG_ARGS $1"
|
||||
fi
|
||||
else
|
||||
SERVER_OPTS="$SERVER_OPTS $1"
|
||||
fi
|
||||
case "$1" in
|
||||
start-dev) CONFIG_ARGS="$CONFIG_ARGS --profile=dev $1";;
|
||||
-D*) SERVER_OPTS="$SERVER_OPTS $1";;
|
||||
*) CONFIG_ARGS="$CONFIG_ARGS $1";;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "x$JAVA" = "x" ]; then
|
||||
if [ "x$JAVA_HOME" != "x" ]; then
|
||||
if [ -z "$JAVA" ]; then
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
JAVA="$JAVA_HOME/bin/java"
|
||||
else
|
||||
JAVA="java"
|
||||
|
@ -88,7 +82,7 @@ fi
|
|||
#
|
||||
# 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.
|
||||
# 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.
|
||||
|
@ -99,14 +93,14 @@ else
|
|||
fi
|
||||
|
||||
# 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"
|
||||
else
|
||||
echo "JAVA_ADD_OPENS already set in environment; overriding default settings with values: $JAVA_ADD_OPENS"
|
||||
fi
|
||||
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"
|
||||
JAVA_OPTS="$JAVA_OPTS $JAVA_OPTS_APPEND"
|
||||
fi
|
||||
|
@ -114,7 +108,7 @@ fi
|
|||
# Set debug settings if not already set
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
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"
|
||||
else
|
||||
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"
|
||||
fi
|
||||
|
||||
if [[ (! $CONFIG_ARGS = *"--optimized"*) ]] && [[ ! "$CONFIG_ARGS" == " build"* ]] && [[ ! "$CONFIG_ARGS" == *"-h" ]] && [[ ! "$CONFIG_ARGS" == *"--help"* ]]; then
|
||||
eval "'$JAVA'" -Dkc.config.build-and-exit=true $JAVA_RUN_OPTS
|
||||
EXIT_CODE=$?
|
||||
case "$CONFIG_ARGS" in
|
||||
" build"* | *--optimized* | *-h | *--help*) ;;
|
||||
*)
|
||||
eval "'$JAVA'" -Dkc.config.build-and-exit=true $JAVA_RUN_OPTS || exit $?
|
||||
JAVA_RUN_OPTS="-Dkc.config.built=true $JAVA_RUN_OPTS"
|
||||
if [ $EXIT_CODE != 0 ]; then
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
eval exec "'$JAVA'" $JAVA_RUN_OPTS
|
||||
|
|
Loading…
Reference in a new issue