Add option to use implicit search path in postgres

This commit is contained in:
Alexey Pustovalov 2021-08-05 17:59:45 +02:00
parent 5f79463fcf
commit 930e66b9f7
19 changed files with 79 additions and 24 deletions

View File

@ -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

View File

@ -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``.

View File

@ -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

View File

@ -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``.

View File

@ -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

View File

@ -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``.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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