mirror of
https://github.com/EpicMorg/docker-scripts.git
synced 2024-12-25 14:15:38 +03:00
40 lines
1.5 KiB
Bash
40 lines
1.5 KiB
Bash
|
#!/bin/bash
|
||
|
set -euo pipefail
|
||
|
|
||
|
export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
|
||
|
export JRE_HOME="$JAVA_HOME/jre"
|
||
|
export JAVA_BINARY="$JRE_HOME/bin/java"
|
||
|
export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}')
|
||
|
|
||
|
|
||
|
# Setup Catalina Opts
|
||
|
: ${CATALINA_CONNECTOR_PROXYNAME:=}
|
||
|
: ${CATALINA_CONNECTOR_PROXYPORT:=}
|
||
|
: ${CATALINA_CONNECTOR_SCHEME:=http}
|
||
|
: ${CATALINA_CONNECTOR_SECURE:=false}
|
||
|
|
||
|
: ${CATALINA_OPTS:=}
|
||
|
|
||
|
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}"
|
||
|
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}"
|
||
|
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}"
|
||
|
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}"
|
||
|
|
||
|
export CATALINA_OPTS
|
||
|
|
||
|
|
||
|
# Start Confluence as the correct user
|
||
|
if [ "${UID}" -eq 0 ]; then
|
||
|
echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}"
|
||
|
PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${CONFLUENCE_HOME}")
|
||
|
EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700
|
||
|
if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then
|
||
|
chmod -R 700 "${CONFLUENCE_HOME}" &&
|
||
|
chown -R "${RUN_USER}:${RUN_GROUP}" "${CONFLUENCE_HOME}"
|
||
|
fi
|
||
|
# Now drop privileges
|
||
|
exec su -s /bin/bash "${RUN_USER}" -c "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh $@"
|
||
|
else
|
||
|
exec "$CONFLUENCE_INSTALL_DIR/bin/start-confluence.sh" "$@"
|
||
|
fi
|