Added permissions check before re-applying permissions

This commit is contained in:
Dave Chevell 2017-08-29 17:41:40 +10:00
parent ca78534396
commit 6ee5182477
No known key found for this signature in database
GPG Key ID: 279DF1B52C7C44DC

View File

@ -21,10 +21,13 @@ export JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}"
# Start Bamboo as the correct user
if [ "${UID}" -eq 0 ]; then
echo "User is currently root. Will change directories to daemon control, then downgrade permission to daemon"
mkdir -p "${CONFLUENCE_HOME}/lib" &&
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}"
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