From 930e66b9f7d5f50df4ac13ccfc99f53e42ce3ca6 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Thu, 5 Aug 2021 17:59:45 +0200 Subject: [PATCH] Add option to use implicit search path in postgres --- .env_db_pgsql | 1 + server-pgsql/alpine/README.md | 4 ++++ server-pgsql/alpine/docker-entrypoint.sh | 10 ++++++---- server-pgsql/centos/README.md | 4 ++++ server-pgsql/centos/docker-entrypoint.sh | 10 ++++++---- server-pgsql/ubuntu/README.md | 4 ++++ server-pgsql/ubuntu/docker-entrypoint.sh | 10 ++++++---- web-apache-pgsql/alpine/README.md | 4 ++++ web-apache-pgsql/alpine/docker-entrypoint.sh | 6 ++++-- web-apache-pgsql/centos/README.md | 4 ++++ web-apache-pgsql/centos/docker-entrypoint.sh | 6 ++++-- web-apache-pgsql/ubuntu/README.md | 4 ++++ web-apache-pgsql/ubuntu/docker-entrypoint.sh | 6 ++++-- web-nginx-pgsql/alpine/README.md | 4 ++++ web-nginx-pgsql/alpine/docker-entrypoint.sh | 6 ++++-- web-nginx-pgsql/centos/README.md | 4 ++++ web-nginx-pgsql/centos/docker-entrypoint.sh | 6 ++++-- web-nginx-pgsql/ubuntu/README.md | 4 ++++ web-nginx-pgsql/ubuntu/docker-entrypoint.sh | 6 ++++-- 19 files changed, 79 insertions(+), 24 deletions(-) diff --git a/.env_db_pgsql b/.env_db_pgsql index fee649c67..ba5e5cbf3 100644 --- a/.env_db_pgsql +++ b/.env_db_pgsql @@ -7,3 +7,4 @@ POSTGRES_PASSWORD_FILE=/run/secrets/POSTGRES_PASSWORD # POSTGRES_DB=zabbix POSTGRES_DB=zabbix # DB_SERVER_SCHEMA=public +# POSTGRES_USE_IMPLICIT_SEARCH_PATH=false diff --git a/server-pgsql/alpine/README.md b/server-pgsql/alpine/README.md index 9d172948d..08274c868 100644 --- a/server-pgsql/alpine/README.md +++ b/server-pgsql/alpine/README.md @@ -103,6 +103,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_LOADMODULE` The variable is list of comma separated loadable Zabbix modules. It works with volume ``/var/lib/zabbix/modules``. The syntax of the variable is ``dummy1.so,dummy2.so``. diff --git a/server-pgsql/alpine/docker-entrypoint.sh b/server-pgsql/alpine/docker-entrypoint.sh index c76b004f4..4fc2fcc41 100755 --- a/server-pgsql/alpine/docker-entrypoint.sh +++ b/server-pgsql/alpine/docker-entrypoint.sh @@ -151,6 +151,8 @@ check_variables_postgresql() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect_postgresql() { @@ -171,7 +173,7 @@ check_db_connect_postgresql() { WAIT_TIMEOUT=5 - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -199,7 +201,7 @@ psql_query() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -223,7 +225,7 @@ create_db_database_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -256,7 +258,7 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/server-pgsql/centos/README.md b/server-pgsql/centos/README.md index 9d172948d..08274c868 100644 --- a/server-pgsql/centos/README.md +++ b/server-pgsql/centos/README.md @@ -103,6 +103,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_LOADMODULE` The variable is list of comma separated loadable Zabbix modules. It works with volume ``/var/lib/zabbix/modules``. The syntax of the variable is ``dummy1.so,dummy2.so``. diff --git a/server-pgsql/centos/docker-entrypoint.sh b/server-pgsql/centos/docker-entrypoint.sh index c76b004f4..4fc2fcc41 100755 --- a/server-pgsql/centos/docker-entrypoint.sh +++ b/server-pgsql/centos/docker-entrypoint.sh @@ -151,6 +151,8 @@ check_variables_postgresql() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect_postgresql() { @@ -171,7 +173,7 @@ check_db_connect_postgresql() { WAIT_TIMEOUT=5 - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -199,7 +201,7 @@ psql_query() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -223,7 +225,7 @@ create_db_database_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -256,7 +258,7 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/server-pgsql/ubuntu/README.md b/server-pgsql/ubuntu/README.md index 9d172948d..08274c868 100644 --- a/server-pgsql/ubuntu/README.md +++ b/server-pgsql/ubuntu/README.md @@ -103,6 +103,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_LOADMODULE` The variable is list of comma separated loadable Zabbix modules. It works with volume ``/var/lib/zabbix/modules``. The syntax of the variable is ``dummy1.so,dummy2.so``. diff --git a/server-pgsql/ubuntu/docker-entrypoint.sh b/server-pgsql/ubuntu/docker-entrypoint.sh index 33b907288..67be13bf7 100755 --- a/server-pgsql/ubuntu/docker-entrypoint.sh +++ b/server-pgsql/ubuntu/docker-entrypoint.sh @@ -151,6 +151,8 @@ check_variables_postgresql() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect_postgresql() { @@ -171,7 +173,7 @@ check_db_connect_postgresql() { WAIT_TIMEOUT=5 - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -199,7 +201,7 @@ psql_query() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -223,7 +225,7 @@ create_db_database_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi @@ -256,7 +258,7 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi - if [ -n "${DB_SERVER_SCHEMA}" ]; then + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/web-apache-pgsql/alpine/README.md b/web-apache-pgsql/alpine/README.md index 427cbe27e..e0866f5ed 100644 --- a/web-apache-pgsql/alpine/README.md +++ b/web-apache-pgsql/alpine/README.md @@ -120,6 +120,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_HISTORYSTORAGEURL` History storage HTTP[S] URL. This parameter is used for Elasticsearch setup. Available since 3.4.5. diff --git a/web-apache-pgsql/alpine/docker-entrypoint.sh b/web-apache-pgsql/alpine/docker-entrypoint.sh index eec3625b8..069b86334 100755 --- a/web-apache-pgsql/alpine/docker-entrypoint.sh +++ b/web-apache-pgsql/alpine/docker-entrypoint.sh @@ -75,6 +75,8 @@ check_variables() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect() { @@ -103,8 +105,8 @@ check_db_connect() { fi WAIT_TIMEOUT=5 - - if [ -n "${DB_SERVER_SCHEMA}" ]; then + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/web-apache-pgsql/centos/README.md b/web-apache-pgsql/centos/README.md index 427cbe27e..e0866f5ed 100644 --- a/web-apache-pgsql/centos/README.md +++ b/web-apache-pgsql/centos/README.md @@ -120,6 +120,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_HISTORYSTORAGEURL` History storage HTTP[S] URL. This parameter is used for Elasticsearch setup. Available since 3.4.5. diff --git a/web-apache-pgsql/centos/docker-entrypoint.sh b/web-apache-pgsql/centos/docker-entrypoint.sh index 428b86fe7..e9d30253f 100755 --- a/web-apache-pgsql/centos/docker-entrypoint.sh +++ b/web-apache-pgsql/centos/docker-entrypoint.sh @@ -75,6 +75,8 @@ check_variables() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect() { @@ -103,8 +105,8 @@ check_db_connect() { fi WAIT_TIMEOUT=5 - - if [ -n "${DB_SERVER_SCHEMA}" ]; then + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/web-apache-pgsql/ubuntu/README.md b/web-apache-pgsql/ubuntu/README.md index 427cbe27e..e0866f5ed 100644 --- a/web-apache-pgsql/ubuntu/README.md +++ b/web-apache-pgsql/ubuntu/README.md @@ -120,6 +120,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_HISTORYSTORAGEURL` History storage HTTP[S] URL. This parameter is used for Elasticsearch setup. Available since 3.4.5. diff --git a/web-apache-pgsql/ubuntu/docker-entrypoint.sh b/web-apache-pgsql/ubuntu/docker-entrypoint.sh index 8aa2e8982..67960b5d8 100755 --- a/web-apache-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-apache-pgsql/ubuntu/docker-entrypoint.sh @@ -75,6 +75,8 @@ check_variables() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect() { @@ -103,8 +105,8 @@ check_db_connect() { fi WAIT_TIMEOUT=5 - - if [ -n "${DB_SERVER_SCHEMA}" ]; then + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/web-nginx-pgsql/alpine/README.md b/web-nginx-pgsql/alpine/README.md index b0010dc3b..b12ab4894 100644 --- a/web-nginx-pgsql/alpine/README.md +++ b/web-nginx-pgsql/alpine/README.md @@ -120,6 +120,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_HISTORYSTORAGEURL` History storage HTTP[S] URL. This parameter is used for Elasticsearch setup. Available since 3.4.5. diff --git a/web-nginx-pgsql/alpine/docker-entrypoint.sh b/web-nginx-pgsql/alpine/docker-entrypoint.sh index 17bf801a4..5346b497d 100755 --- a/web-nginx-pgsql/alpine/docker-entrypoint.sh +++ b/web-nginx-pgsql/alpine/docker-entrypoint.sh @@ -75,6 +75,8 @@ check_variables() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect() { @@ -103,8 +105,8 @@ check_db_connect() { fi WAIT_TIMEOUT=5 - - if [ -n "${DB_SERVER_SCHEMA}" ]; then + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/web-nginx-pgsql/centos/README.md b/web-nginx-pgsql/centos/README.md index b0010dc3b..b12ab4894 100644 --- a/web-nginx-pgsql/centos/README.md +++ b/web-nginx-pgsql/centos/README.md @@ -120,6 +120,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_HISTORYSTORAGEURL` History storage HTTP[S] URL. This parameter is used for Elasticsearch setup. Available since 3.4.5. diff --git a/web-nginx-pgsql/centos/docker-entrypoint.sh b/web-nginx-pgsql/centos/docker-entrypoint.sh index 356edb551..f83f17774 100755 --- a/web-nginx-pgsql/centos/docker-entrypoint.sh +++ b/web-nginx-pgsql/centos/docker-entrypoint.sh @@ -75,6 +75,8 @@ check_variables() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect() { @@ -103,8 +105,8 @@ check_db_connect() { fi WAIT_TIMEOUT=5 - - if [ -n "${DB_SERVER_SCHEMA}" ]; then + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi diff --git a/web-nginx-pgsql/ubuntu/README.md b/web-nginx-pgsql/ubuntu/README.md index b0010dc3b..b12ab4894 100644 --- a/web-nginx-pgsql/ubuntu/README.md +++ b/web-nginx-pgsql/ubuntu/README.md @@ -120,6 +120,10 @@ By default, values for `POSTGRES_USER` and `POSTGRES_PASSWORD` are `zabbix`, `za The variable is Zabbix database name. By default, value is `zabbix`. +### `POSTGRES_USE_IMPLICIT_SEARCH_PATH` + +In some setups, for example including [PgBouncer](https://www.pgbouncer.org), setting the `search_path` via connection parameters fails. If this variable is set to `"true"`, the image skips setting the `search_path` and trusts that the `search_path` of the Zabbix user is setup correctly in PostgreSQL database. + ### `ZBX_HISTORYSTORAGEURL` History storage HTTP[S] URL. This parameter is used for Elasticsearch setup. Available since 3.4.5. diff --git a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh index 525d8ada8..f206d47e5 100755 --- a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh @@ -75,6 +75,8 @@ check_variables() { : ${DB_SERVER_SCHEMA:="public"} DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix"} + + : ${POSTGRES_USE_IMPLICIT_SEARCH_PATH:="false"} } check_db_connect() { @@ -103,8 +105,8 @@ check_db_connect() { fi WAIT_TIMEOUT=5 - - if [ -n "${DB_SERVER_SCHEMA}" ]; then + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" export PGOPTIONS fi