diff --git a/agent/alpine/docker-entrypoint.sh b/agent/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/agent/alpine/docker-entrypoint.sh +++ b/agent/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/agent/centos/docker-entrypoint.sh b/agent/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/agent/centos/docker-entrypoint.sh +++ b/agent/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/agent/ubuntu/docker-entrypoint.sh b/agent/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/agent/ubuntu/docker-entrypoint.sh +++ b/agent/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/java-gateway/alpine/docker-entrypoint.sh b/java-gateway/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/java-gateway/alpine/docker-entrypoint.sh +++ b/java-gateway/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/java-gateway/centos/docker-entrypoint.sh b/java-gateway/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/java-gateway/centos/docker-entrypoint.sh +++ b/java-gateway/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/java-gateway/ubuntu/docker-entrypoint.sh b/java-gateway/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/java-gateway/ubuntu/docker-entrypoint.sh +++ b/java-gateway/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/proxy-mysql/alpine/docker-entrypoint.sh b/proxy-mysql/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/proxy-mysql/alpine/docker-entrypoint.sh +++ b/proxy-mysql/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/proxy-mysql/centos/docker-entrypoint.sh b/proxy-mysql/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/proxy-mysql/centos/docker-entrypoint.sh +++ b/proxy-mysql/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/proxy-mysql/ubuntu/docker-entrypoint.sh b/proxy-mysql/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/proxy-mysql/ubuntu/docker-entrypoint.sh +++ b/proxy-mysql/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/proxy-sqlite3/alpine/docker-entrypoint.sh b/proxy-sqlite3/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/proxy-sqlite3/alpine/docker-entrypoint.sh +++ b/proxy-sqlite3/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/proxy-sqlite3/centos/docker-entrypoint.sh b/proxy-sqlite3/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/proxy-sqlite3/centos/docker-entrypoint.sh +++ b/proxy-sqlite3/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/proxy-sqlite3/ubuntu/docker-entrypoint.sh b/proxy-sqlite3/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/proxy-sqlite3/ubuntu/docker-entrypoint.sh +++ b/proxy-sqlite3/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/server-mysql/alpine/docker-entrypoint.sh b/server-mysql/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/server-mysql/alpine/docker-entrypoint.sh +++ b/server-mysql/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/server-mysql/centos/docker-entrypoint.sh b/server-mysql/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/server-mysql/centos/docker-entrypoint.sh +++ b/server-mysql/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/server-mysql/ubuntu/docker-entrypoint.sh b/server-mysql/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/server-mysql/ubuntu/docker-entrypoint.sh +++ b/server-mysql/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/server-pgsql/alpine/docker-entrypoint.sh b/server-pgsql/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/server-pgsql/alpine/docker-entrypoint.sh +++ b/server-pgsql/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/server-pgsql/centos/docker-entrypoint.sh b/server-pgsql/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/server-pgsql/centos/docker-entrypoint.sh +++ b/server-pgsql/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/server-pgsql/ubuntu/docker-entrypoint.sh b/server-pgsql/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/server-pgsql/ubuntu/docker-entrypoint.sh +++ b/server-pgsql/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-apache-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php b/web-apache-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-apache-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-apache-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-apache-mysql/alpine/docker-entrypoint.sh b/web-apache-mysql/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-apache-mysql/alpine/docker-entrypoint.sh +++ b/web-apache-mysql/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-apache-mysql/centos/Dockerfile b/web-apache-mysql/centos/Dockerfile index 91688351c..74d9981c0 100644 --- a/web-apache-mysql/centos/Dockerfile +++ b/web-apache-mysql/centos/Dockerfile @@ -77,7 +77,7 @@ RUN groupadd --system zabbix && \ php-mbstring \ php-mysql \ php-xml && \ - ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ + ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ yum ${YUM_FLAGS_PERSISTANT} clean all && \ rm -rf /var/cache/yum/ diff --git a/web-apache-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php b/web-apache-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-apache-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-apache-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-apache-mysql/centos/docker-entrypoint.sh b/web-apache-mysql/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-apache-mysql/centos/docker-entrypoint.sh +++ b/web-apache-mysql/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-apache-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php b/web-apache-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-apache-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-apache-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-apache-mysql/ubuntu/docker-entrypoint.sh b/web-apache-mysql/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-apache-mysql/ubuntu/docker-entrypoint.sh +++ b/web-apache-mysql/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-apache-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php b/web-apache-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-apache-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-apache-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-apache-pgsql/alpine/docker-entrypoint.sh b/web-apache-pgsql/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-apache-pgsql/alpine/docker-entrypoint.sh +++ b/web-apache-pgsql/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-apache-pgsql/centos/Dockerfile b/web-apache-pgsql/centos/Dockerfile index 8c357d735..e67e3154e 100644 --- a/web-apache-pgsql/centos/Dockerfile +++ b/web-apache-pgsql/centos/Dockerfile @@ -78,7 +78,7 @@ RUN groupadd --system zabbix && \ php-pgsql \ php-xml \ postgresql && \ - ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ + ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ yum ${YUM_FLAGS_PERSISTENT} clean all && \ rm -rf /var/cache/yum/ diff --git a/web-apache-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php b/web-apache-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-apache-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-apache-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-apache-pgsql/centos/docker-entrypoint.sh b/web-apache-pgsql/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-apache-pgsql/centos/docker-entrypoint.sh +++ b/web-apache-pgsql/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-apache-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php b/web-apache-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-apache-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-apache-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-apache-pgsql/ubuntu/docker-entrypoint.sh b/web-apache-pgsql/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-apache-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-apache-pgsql/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-nginx-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php b/web-nginx-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-nginx-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-nginx-mysql/alpine/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-nginx-mysql/alpine/docker-entrypoint.sh b/web-nginx-mysql/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-nginx-mysql/alpine/docker-entrypoint.sh +++ b/web-nginx-mysql/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-nginx-mysql/centos/Dockerfile b/web-nginx-mysql/centos/Dockerfile index ac49165f5..1fe34103d 100644 --- a/web-nginx-mysql/centos/Dockerfile +++ b/web-nginx-mysql/centos/Dockerfile @@ -80,7 +80,7 @@ RUN groupadd --system zabbix && \ php-mysql \ php-xml \ supervisor && \ - ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ + ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ rm -f /etc/php-fpm.d/www.conf && \ mkdir -p /var/lib/php/ && \ chown --quiet -R nginx:nginx /var/lib/php/ && \ diff --git a/web-nginx-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php b/web-nginx-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-nginx-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-nginx-mysql/centos/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-nginx-mysql/centos/docker-entrypoint.sh b/web-nginx-mysql/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-nginx-mysql/centos/docker-entrypoint.sh +++ b/web-nginx-mysql/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-nginx-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php b/web-nginx-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-nginx-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-nginx-mysql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-nginx-mysql/ubuntu/docker-entrypoint.sh b/web-nginx-mysql/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-nginx-mysql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-mysql/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-nginx-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php b/web-nginx-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-nginx-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-nginx-pgsql/alpine/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-nginx-pgsql/alpine/docker-entrypoint.sh b/web-nginx-pgsql/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-nginx-pgsql/alpine/docker-entrypoint.sh +++ b/web-nginx-pgsql/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-nginx-pgsql/centos/Dockerfile b/web-nginx-pgsql/centos/Dockerfile index 2af9a370a..9fb1b0dc3 100644 --- a/web-nginx-pgsql/centos/Dockerfile +++ b/web-nginx-pgsql/centos/Dockerfile @@ -79,7 +79,7 @@ RUN groupadd --system zabbix && \ php-mbstring \ php-pgsql \ php-xml && \ - ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ + ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ rm -f /etc/php-fpm.d/www.conf && \ mkdir -p /var/lib/php/ && \ chown --quiet -R nginx:nginx /var/lib/php/ && \ diff --git a/web-nginx-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php b/web-nginx-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-nginx-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-nginx-pgsql/centos/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-nginx-pgsql/centos/docker-entrypoint.sh b/web-nginx-pgsql/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-nginx-pgsql/centos/docker-entrypoint.sh +++ b/web-nginx-pgsql/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/web-nginx-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php b/web-nginx-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php index 4e6eb414e..6cbd68590 100644 --- a/web-nginx-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php +++ b/web-nginx-pgsql/ubuntu/conf/etc/zabbix/web/zabbix.conf.php @@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}'; $DB['PASSWORD'] = '{DB_SERVER_PASS}'; // Schema name. Used for IBM DB2 and PostgreSQL. -$DB['SCHEMA'] = ''; +$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}'; $ZBX_SERVER = '{ZBX_SERVER_HOST}'; $ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}'; diff --git a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/zabbix-appliance/alpine/docker-entrypoint.sh b/zabbix-appliance/alpine/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/zabbix-appliance/alpine/docker-entrypoint.sh +++ b/zabbix-appliance/alpine/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/zabbix-appliance/centos/Dockerfile b/zabbix-appliance/centos/Dockerfile index 2973864b3..f804f3233 100644 --- a/zabbix-appliance/centos/Dockerfile +++ b/zabbix-appliance/centos/Dockerfile @@ -168,7 +168,7 @@ RUN groupadd --system zabbix && \ mkdir -p /var/lib/php/ && \ chown --quiet -R nginx:nginx /var/lib/php/ && \ ls -lah /usr/share/zabbix/ && \ - ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ + ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \ yum ${YUM_FLAGS_PERSISTENT} clean all && \ rm -rf /var/cache/yum/ diff --git a/zabbix-appliance/centos/docker-entrypoint.sh b/zabbix-appliance/centos/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/zabbix-appliance/centos/docker-entrypoint.sh +++ b/zabbix-appliance/centos/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/zabbix-appliance/rhel/docker-entrypoint.sh b/zabbix-appliance/rhel/docker-entrypoint.sh index 173ccd8bf..dedd2e656 100755 --- a/zabbix-appliance/rhel/docker-entrypoint.sh +++ b/zabbix-appliance/rhel/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -656,6 +675,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -847,6 +867,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \ diff --git a/zabbix-appliance/ubuntu/docker-entrypoint.sh b/zabbix-appliance/ubuntu/docker-entrypoint.sh index 19270b07a..80a9afa9f 100755 --- a/zabbix-appliance/ubuntu/docker-entrypoint.sh +++ b/zabbix-appliance/ubuntu/docker-entrypoint.sh @@ -290,6 +290,7 @@ check_db_connect_postgresql() { echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}" echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}" echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}" + echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}" if [ "${USE_DB_ROOT_USER}" == "true" ]; then echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}" echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}" @@ -306,6 +307,11 @@ check_db_connect_postgresql() { fi WAIT_TIMEOUT=5 + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..." @@ -313,6 +319,7 @@ check_db_connect_postgresql() { done unset PGPASSWORD + unset PGOPTIONS } @@ -335,11 +342,17 @@ psql_query() { if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null); unset PGPASSWORD + unset PGOPTIONS echo $result } @@ -436,11 +449,17 @@ create_db_schema_postgresql() { export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi + if [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \ -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null unset PGPASSWORD + unset PGOPTIONS fi } @@ -651,6 +670,7 @@ update_zbx_config() { else update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}" update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}" + update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}" update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}" update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}" update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}" @@ -835,6 +855,7 @@ prepare_zbx_web_config() { -e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \ -e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \ -e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \ + -e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \ -e "s/{DB_SERVER_USER}/$server_user/g" \ -e "s/{DB_SERVER_PASS}/$server_pass/g" \ -e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \