From 6e6139168416f23de29cd1214f65faff7ff73b2a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 11 Apr 2019 19:41:44 +0300 Subject: [PATCH] Fixed PostgreSQL custom schema usage --- .env_db_pgsql | 2 +- agent/alpine/docker-entrypoint.sh | 8 ++++++-- agent/centos/docker-entrypoint.sh | 8 ++++++-- agent/ubuntu/docker-entrypoint.sh | 8 ++++++-- java-gateway/alpine/docker-entrypoint.sh | 8 ++++++-- java-gateway/centos/docker-entrypoint.sh | 8 ++++++-- java-gateway/ubuntu/docker-entrypoint.sh | 8 ++++++-- proxy-mysql/alpine/docker-entrypoint.sh | 8 ++++++-- proxy-mysql/centos/docker-entrypoint.sh | 8 ++++++-- proxy-mysql/ubuntu/docker-entrypoint.sh | 8 ++++++-- proxy-sqlite3/alpine/docker-entrypoint.sh | 8 ++++++-- proxy-sqlite3/centos/docker-entrypoint.sh | 8 ++++++-- proxy-sqlite3/ubuntu/docker-entrypoint.sh | 8 ++++++-- server-mysql/alpine/docker-entrypoint.sh | 8 ++++++-- server-mysql/centos/docker-entrypoint.sh | 8 ++++++-- server-mysql/ubuntu/docker-entrypoint.sh | 8 ++++++-- server-pgsql/alpine/docker-entrypoint.sh | 8 ++++++-- server-pgsql/centos/docker-entrypoint.sh | 8 ++++++-- server-pgsql/ubuntu/docker-entrypoint.sh | 8 ++++++-- web-apache-mysql/alpine/docker-entrypoint.sh | 8 ++++++-- web-apache-mysql/centos/docker-entrypoint.sh | 8 ++++++-- web-apache-mysql/ubuntu/docker-entrypoint.sh | 8 ++++++-- web-apache-pgsql/alpine/docker-entrypoint.sh | 8 ++++++-- web-apache-pgsql/centos/docker-entrypoint.sh | 8 ++++++-- web-apache-pgsql/ubuntu/docker-entrypoint.sh | 8 ++++++-- web-nginx-mysql/alpine/docker-entrypoint.sh | 8 ++++++-- web-nginx-mysql/centos/docker-entrypoint.sh | 8 ++++++-- web-nginx-mysql/ubuntu/docker-entrypoint.sh | 8 ++++++-- web-nginx-pgsql/alpine/docker-entrypoint.sh | 8 ++++++-- web-nginx-pgsql/centos/docker-entrypoint.sh | 8 ++++++-- web-nginx-pgsql/ubuntu/docker-entrypoint.sh | 8 ++++++-- zabbix-appliance/alpine/docker-entrypoint.sh | 8 ++++++-- zabbix-appliance/centos/docker-entrypoint.sh | 8 ++++++-- zabbix-appliance/rhel/docker-entrypoint.sh | 8 ++++++-- zabbix-appliance/ubuntu/docker-entrypoint.sh | 8 ++++++-- 35 files changed, 205 insertions(+), 69 deletions(-) diff --git a/.env_db_pgsql b/.env_db_pgsql index 20f1a878e..6cef2214a 100644 --- a/.env_db_pgsql +++ b/.env_db_pgsql @@ -6,4 +6,4 @@ POSTGRES_USER=zabbix POSTGRES_PASSWORD=zabbix # POSTGRES_DB=zabbix POSTGRES_DB=zabbix -# ZBX_DBSCHEMA=public +# DB_SERVER_SCHEMA=public diff --git a/agent/alpine/docker-entrypoint.sh b/agent/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/agent/alpine/docker-entrypoint.sh +++ b/agent/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/agent/centos/docker-entrypoint.sh b/agent/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/agent/centos/docker-entrypoint.sh +++ b/agent/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/agent/ubuntu/docker-entrypoint.sh b/agent/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/agent/ubuntu/docker-entrypoint.sh +++ b/agent/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/java-gateway/alpine/docker-entrypoint.sh b/java-gateway/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/java-gateway/alpine/docker-entrypoint.sh +++ b/java-gateway/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/java-gateway/centos/docker-entrypoint.sh b/java-gateway/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/java-gateway/centos/docker-entrypoint.sh +++ b/java-gateway/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/java-gateway/ubuntu/docker-entrypoint.sh b/java-gateway/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/java-gateway/ubuntu/docker-entrypoint.sh +++ b/java-gateway/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/proxy-mysql/alpine/docker-entrypoint.sh b/proxy-mysql/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/proxy-mysql/alpine/docker-entrypoint.sh +++ b/proxy-mysql/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/proxy-mysql/centos/docker-entrypoint.sh b/proxy-mysql/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/proxy-mysql/centos/docker-entrypoint.sh +++ b/proxy-mysql/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/proxy-mysql/ubuntu/docker-entrypoint.sh b/proxy-mysql/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/proxy-mysql/ubuntu/docker-entrypoint.sh +++ b/proxy-mysql/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/proxy-sqlite3/alpine/docker-entrypoint.sh b/proxy-sqlite3/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/proxy-sqlite3/alpine/docker-entrypoint.sh +++ b/proxy-sqlite3/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/proxy-sqlite3/centos/docker-entrypoint.sh b/proxy-sqlite3/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/proxy-sqlite3/centos/docker-entrypoint.sh +++ b/proxy-sqlite3/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/proxy-sqlite3/ubuntu/docker-entrypoint.sh b/proxy-sqlite3/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/proxy-sqlite3/ubuntu/docker-entrypoint.sh +++ b/proxy-sqlite3/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/server-mysql/alpine/docker-entrypoint.sh b/server-mysql/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/server-mysql/alpine/docker-entrypoint.sh +++ b/server-mysql/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/server-mysql/centos/docker-entrypoint.sh b/server-mysql/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/server-mysql/centos/docker-entrypoint.sh +++ b/server-mysql/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/server-mysql/ubuntu/docker-entrypoint.sh b/server-mysql/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/server-mysql/ubuntu/docker-entrypoint.sh +++ b/server-mysql/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/server-pgsql/alpine/docker-entrypoint.sh b/server-pgsql/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/server-pgsql/alpine/docker-entrypoint.sh +++ b/server-pgsql/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/server-pgsql/centos/docker-entrypoint.sh b/server-pgsql/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/server-pgsql/centos/docker-entrypoint.sh +++ b/server-pgsql/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/server-pgsql/ubuntu/docker-entrypoint.sh b/server-pgsql/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/server-pgsql/ubuntu/docker-entrypoint.sh +++ b/server-pgsql/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-apache-mysql/alpine/docker-entrypoint.sh b/web-apache-mysql/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-apache-mysql/alpine/docker-entrypoint.sh +++ b/web-apache-mysql/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-apache-mysql/centos/docker-entrypoint.sh b/web-apache-mysql/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-apache-mysql/centos/docker-entrypoint.sh +++ b/web-apache-mysql/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-apache-mysql/ubuntu/docker-entrypoint.sh b/web-apache-mysql/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-apache-mysql/ubuntu/docker-entrypoint.sh +++ b/web-apache-mysql/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-apache-pgsql/alpine/docker-entrypoint.sh b/web-apache-pgsql/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-apache-pgsql/alpine/docker-entrypoint.sh +++ b/web-apache-pgsql/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-apache-pgsql/centos/docker-entrypoint.sh b/web-apache-pgsql/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-apache-pgsql/centos/docker-entrypoint.sh +++ b/web-apache-pgsql/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-apache-pgsql/ubuntu/docker-entrypoint.sh b/web-apache-pgsql/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-apache-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-apache-pgsql/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-nginx-mysql/alpine/docker-entrypoint.sh b/web-nginx-mysql/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-nginx-mysql/alpine/docker-entrypoint.sh +++ b/web-nginx-mysql/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-nginx-mysql/centos/docker-entrypoint.sh b/web-nginx-mysql/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-nginx-mysql/centos/docker-entrypoint.sh +++ b/web-nginx-mysql/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-nginx-mysql/ubuntu/docker-entrypoint.sh b/web-nginx-mysql/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-nginx-mysql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-mysql/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-nginx-pgsql/alpine/docker-entrypoint.sh b/web-nginx-pgsql/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-nginx-pgsql/alpine/docker-entrypoint.sh +++ b/web-nginx-pgsql/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-nginx-pgsql/centos/docker-entrypoint.sh b/web-nginx-pgsql/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-nginx-pgsql/centos/docker-entrypoint.sh +++ b/web-nginx-pgsql/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/zabbix-appliance/alpine/docker-entrypoint.sh b/zabbix-appliance/alpine/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/zabbix-appliance/alpine/docker-entrypoint.sh +++ b/zabbix-appliance/alpine/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/zabbix-appliance/centos/docker-entrypoint.sh b/zabbix-appliance/centos/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/zabbix-appliance/centos/docker-entrypoint.sh +++ b/zabbix-appliance/centos/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/zabbix-appliance/rhel/docker-entrypoint.sh b/zabbix-appliance/rhel/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/zabbix-appliance/rhel/docker-entrypoint.sh +++ b/zabbix-appliance/rhel/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then diff --git a/zabbix-appliance/ubuntu/docker-entrypoint.sh b/zabbix-appliance/ubuntu/docker-entrypoint.sh index 611bf5f99..e5e127d73 100755 --- a/zabbix-appliance/ubuntu/docker-entrypoint.sh +++ b/zabbix-appliance/ubuntu/docker-entrypoint.sh @@ -256,6 +256,8 @@ check_variables_postgresql() { DB_SERVER_ZBX_USER=${POSTGRES_USER:-"zabbix"} DB_SERVER_ZBX_PASS=${POSTGRES_PASSWORD:-"zabbix"} + DB_SERVER_SCHEMA=${DB_SERVER_SCHEMA:-"public"} + if [ "$type" == "proxy" ]; then DB_SERVER_DBNAME=${POSTGRES_DB:-"zabbix_proxy"} else @@ -409,6 +411,8 @@ create_db_database_postgresql() { else echo "** Database '${DB_SERVER_DBNAME}' already exists. Please be careful with database owner!" fi + + psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" } create_db_schema_mysql() { @@ -435,11 +439,11 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = 'public' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." - ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM public.dbversion" "${DB_SERVER_DBNAME}") + ZBX_DB_VERSION=$(psql_query "SELECT mandatory FROM ${DB_SERVER_SCHEMA}.dbversion" "${DB_SERVER_DBNAME}") fi if [ -z "${ZBX_DB_VERSION}" ]; then