Skip to content

Commit

Permalink
fix: allow usage of jndi with jdbcconfig & jdbcstore
Browse files Browse the repository at this point in the history
  • Loading branch information
tldev-de committed Nov 5, 2024
1 parent cae3168 commit b074649
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b074649

Please sign in to comment.