Skip to content

Commit

Permalink
Add option to use implicit search path in postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
dotneft committed Aug 5, 2021
1 parent 5f79463 commit 930e66b
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 24 deletions.
1 change: 1 addition & 0 deletions .env_db_pgsql
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions server-pgsql/alpine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
10 changes: 6 additions & 4 deletions server-pgsql/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions server-pgsql/centos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
10 changes: 6 additions & 4 deletions server-pgsql/centos/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions server-pgsql/ubuntu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
10 changes: 6 additions & 4 deletions server-pgsql/ubuntu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions web-apache-pgsql/alpine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions web-apache-pgsql/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions web-apache-pgsql/centos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions web-apache-pgsql/centos/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions web-apache-pgsql/ubuntu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions web-apache-pgsql/ubuntu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions web-nginx-pgsql/alpine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions web-nginx-pgsql/alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions web-nginx-pgsql/centos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions web-nginx-pgsql/centos/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions web-nginx-pgsql/ubuntu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions web-nginx-pgsql/ubuntu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 930e66b

Please sign in to comment.