diff --git a/scripts/functions.sh b/scripts/functions.sh index cc1587a5..05d720c9 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -556,6 +556,13 @@ function setup_jdbc_db_config() { else envsubst < /build_data/jdbcconfig/jdbcconfig.properties > "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties fi + + # Set jndiName if POSTGRES_JNDI is set to true + sed -i '/^jndiName=/d' "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties + if [[ ${POSTGRES_JNDI} =~ [Tt][Rr][Uu][Ee] ]];then + echo "jndiName=java:comp/env/jdbc/postgres" >> "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties + fi + check_jdbc_config_table=$(psql -d "$POSTGRES_DB" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -h "$HOST" -tAc "SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'object_property')") if [[ ${check_jdbc_config_table} = "t" ]]; then sed -i 's/initdb=true/initdb=false/g' "${GEOSERVER_DATA_DIR}"/jdbcconfig/jdbcconfig.properties @@ -591,6 +598,12 @@ function setup_jdbc_db_store() { envsubst < /build_data/jdbcstore/jdbcstore.properties > "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties fi + # Set jndiName if POSTGRES_JNDI is set to true + sed -i '/^jndiName=/d' "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties + if [[ ${POSTGRES_JNDI} =~ [Tt][Rr][Uu][Ee] ]];then + echo "jndiName=java:comp/env/jdbc/postgres" >> "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties + fi + check_jdbc_store_table=$(psql -d "$POSTGRES_DB" -p "${POSTGRES_PORT}" -U "${POSTGRES_USER}" -h "${HOST}" -tAc "SELECT EXISTS(SELECT 1 from information_schema.tables where table_name = 'resources')") if [[ ${check_jdbc_store_table} = "t" ]]; then sed -i 's/initdb=true/initdb=false/g' "${GEOSERVER_DATA_DIR}"/jdbcstore/jdbcstore.properties