Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to run as root #565

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,34 @@ export JAVA_OPTS="${JAVA_OPTS} ${GEOSERVER_OPTS}"


# Chown again - seems to fix issue with resolving all created directories
dir_ownership=(${CATALINA_HOME} /home/"${USER_NAME}"/ "${COMMUNITY_PLUGINS_DIR}"
"${STABLE_PLUGINS_DIR}" "${GEOSERVER_HOME}" /usr/share/fonts/ /tomcat_apps.zip
/tmp/ "${FOOTPRINTS_DATA_DIR}" "${CERT_DIR}" "${FONTS_DIR}" /scripts/
"${EXTRA_CONFIG_DIR}")
for directory in "${dir_ownership[@]}"; do
if [[ $(stat -c '%U' ${directory}) != "${USER_NAME}" ]] && [[ $(stat -c '%G' ${directory}) != "${GEO_GROUP_NAME}" ]];then
chown -R "${USER_NAME}":"${GEO_GROUP_NAME}" ${directory}
fi
done

if [[ ${RUN_AS_ROOT} =~ [Ff][Aa][Ll][Ss][Ee] ]];then
dir_ownership=(${CATALINA_HOME} /home/"${USER_NAME}"/ "${COMMUNITY_PLUGINS_DIR}"
"${STABLE_PLUGINS_DIR}" "${GEOSERVER_HOME}" /usr/share/fonts/ /tomcat_apps.zip
/tmp/ "${FOOTPRINTS_DATA_DIR}" "${CERT_DIR}" "${FONTS_DIR}" /scripts/
"${EXTRA_CONFIG_DIR}")
for directory in "${dir_ownership[@]}"; do
if [[ $(stat -c '%U' ${directory}) != "${USER_NAME}" ]] && [[ $(stat -c '%G' ${directory}) != "${GEO_GROUP_NAME}" ]];then
chown -R "${USER_NAME}":"${GEO_GROUP_NAME}" ${directory}
fi
done
fi

chmod o+rw "${CERT_DIR}";gwc_file_perms ;chmod 400 ${CATALINA_HOME}/conf/*

if [[ ${SAMPLE_DATA} =~ [Tt][Rr][Uu][Ee] ]]; then
chown -R "${USER_NAME}":"${GEO_GROUP_NAME}" "${GEOSERVER_DATA_DIR}"
fi

if [[ -f ${GEOSERVER_HOME}/start.jar ]]; then
exec gosu ${USER_NAME} ${GEOSERVER_HOME}/bin/startup.sh
if [[ ${RUN_AS_ROOT} =~ [Ff][Aa][Ll][Ss][Ee] ]];then
if [[ -f ${GEOSERVER_HOME}/start.jar ]]; then
exec gosu ${USER_NAME} ${GEOSERVER_HOME}/bin/startup.sh
else
exec gosu ${USER_NAME} /usr/local/tomcat/bin/catalina.sh run
fi
else
exec gosu ${USER_NAME} /usr/local/tomcat/bin/catalina.sh run
if [[ -f ${GEOSERVER_HOME}/start.jar ]]; then
exec ${GEOSERVER_HOME}/bin/startup.sh
else
exec /usr/local/tomcat/bin/catalina.sh run
fi
fi
4 changes: 4 additions & 0 deletions scripts/env-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,7 @@ if [ -z "${SHOW_PASSWORD}" ]; then
# For runtime only, do not change at build-time.
SHOW_PASSWORD=true
fi

if [ -z "${RUN_AS_ROOT}" ]; then
RUN_AS_ROOT=false
fi