Skip to content

Commit

Permalink
MID-9270 fix in ninja shell script to use same keystore as midpoint
Browse files Browse the repository at this point in the history
(cherry picked from commit ca13dfa)
  • Loading branch information
1azyman committed Nov 6, 2023
1 parent b569d45 commit a1ae584
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dist/src/main/bin/ninja.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright (C) 2017-2020 Evolveum and contributors
# Copyright (C) 2017-2023 Evolveum and contributors
#
# This work is dual-licensed under the Apache License 2.0
# and European Union Public License. See LICENSE file for details.
Expand All @@ -13,14 +13,20 @@ BASE_DIR=$(cd "${SCRIPT_DIR}/.." && pwd -P)
: "${MIDPOINT_HOME:="${BASE_DIR}/var"}"

if [[ ! -f "${BASE_DIR}/lib/ninja.jar" ]]; then
echo "ERROR: ninja.jar not found in ${BASE_DIR}/lib directory"
echo "ERROR: ninja.jar not found in ${BASE_DIR}/lib directory" >&2
exit 1
fi

# Set UMASK unless it has been overridden
: "${UMASK:="0027"}"
umask ${UMASK}

JAVA_def_trustStore="keystore.jceks"
JAVA_def_trustStoreType="jceks"

if $(echo "${JAVA_OPTS:-}" | grep -v -q "\-Djavax.net.ssl.trustStore="); then JAVA_OPTS="${JAVA_OPTS:-} -Djavax.net.ssl.trustStore=\"${MIDPOINT_HOME}/${JAVA_def_trustStore}\""; fi
if $(echo "${JAVA_OPTS:-}" | grep -v -q "\-Djavax.net.ssl.trustStoreType="); then JAVA_OPTS="${JAVA_OPTS:-} -Djavax.net.ssl.trustStoreType=${JAVA_def_trustStoreType}"; fi

# can't use -v here because of bash 3.2 support
if [[ -z "${JAVA_HOME:-}" ]]; then
_RUNJAVA=java
Expand All @@ -40,8 +46,8 @@ done
# Technically we could do one exec, but then we can't quote -Dloader.path argument, because it
# would be empty and considered a class name by the "java -jar" command.
if [ -n "${JDBC_DRIVER:-}" ]; then
echo "Using JDBC driver path: ${JDBC_DRIVER}"
exec "${_RUNJAVA}" "-Dloader.path=${JDBC_DRIVER}" -jar "${BASE_DIR}/lib/ninja.jar" -m "${MIDPOINT_HOME}" "$@"
echo "Using JDBC driver path: ${JDBC_DRIVER}" >&2
eval "${_RUNJAVA}" ${JAVA_OPTS} "-Dloader.path=${JDBC_DRIVER}" -jar "${BASE_DIR}/lib/ninja.jar" -m "${MIDPOINT_HOME}" "$@"
else
exec "${_RUNJAVA}" -jar "${BASE_DIR}/lib/ninja.jar" -m "${MIDPOINT_HOME}" "$@"
eval "${_RUNJAVA}" ${JAVA_OPTS} -jar "${BASE_DIR}/lib/ninja.jar" -m "${MIDPOINT_HOME}" "$@"
fi

0 comments on commit a1ae584

Please sign in to comment.