2017-08-25 22:52:43 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Setup Catalina Opts
|
|
|
|
: ${CATALINA_CONNECTOR_PROXYNAME:=}
|
|
|
|
: ${CATALINA_CONNECTOR_PROXYPORT:=}
|
|
|
|
: ${CATALINA_CONNECTOR_SCHEME:=http}
|
|
|
|
: ${CATALINA_CONNECTOR_SECURE:=false}
|
2018-10-11 23:43:29 +00:00
|
|
|
: ${CATALINA_CONTEXT_PATH:=}
|
2017-08-25 22:52:43 +00:00
|
|
|
|
|
|
|
: ${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}"
|
2018-10-11 23:43:29 +00:00
|
|
|
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaContextPath=${CATALINA_CONTEXT_PATH}"
|
2017-08-25 22:52:43 +00:00
|
|
|
|
2017-08-29 10:59:05 +00:00
|
|
|
export CATALINA_OPTS
|
2017-08-25 22:52:43 +00:00
|
|
|
|
|
|
|
|
2017-08-29 10:59:05 +00:00
|
|
|
# Start Confluence as the correct user
|
2017-08-25 22:52:43 +00:00
|
|
|
if [ "${UID}" -eq 0 ]; then
|
2017-08-29 07:41:40 +00:00
|
|
|
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
|
2017-08-25 22:52:43 +00:00
|
|
|
chmod -R 700 "${CONFLUENCE_HOME}" &&
|
2017-08-29 07:41:40 +00:00
|
|
|
chown -R "${RUN_USER}:${RUN_GROUP}" "${CONFLUENCE_HOME}"
|
|
|
|
fi
|
2017-08-25 22:52:43 +00:00
|
|
|
# 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
|