From dd9afde5f250597beddf4374521795dbe192feb5 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Sat, 27 Aug 2022 21:40:18 +0300 Subject: [PATCH] Added posibility for custom SQL scripts during DB init --- .../proxy-mysql/alpine/docker-entrypoint.sh | 35 +++++--- .../proxy-mysql/centos/docker-entrypoint.sh | 35 +++++--- .../proxy-mysql/ol/docker-entrypoint.sh | 35 +++++--- .../proxy-mysql/rhel/docker-entrypoint.sh | 36 +++++--- .../proxy-mysql/ubuntu/docker-entrypoint.sh | 35 +++++--- Dockerfiles/server-mysql/alpine/Dockerfile | 2 + .../server-mysql/alpine/docker-entrypoint.sh | 49 ++++++++--- Dockerfiles/server-mysql/centos/Dockerfile | 2 + .../server-mysql/centos/docker-entrypoint.sh | 49 ++++++++--- Dockerfiles/server-mysql/ol/Dockerfile | 2 + .../server-mysql/ol/docker-entrypoint.sh | 49 ++++++++--- Dockerfiles/server-mysql/rhel/Dockerfile | 2 + .../server-mysql/rhel/docker-entrypoint.sh | 49 ++++++++--- Dockerfiles/server-mysql/ubuntu/Dockerfile | 2 + .../server-mysql/ubuntu/docker-entrypoint.sh | 49 ++++++++--- Dockerfiles/server-pgsql/alpine/Dockerfile | 2 + .../server-pgsql/alpine/docker-entrypoint.sh | 82 ++++++++++++------- Dockerfiles/server-pgsql/centos/Dockerfile | 2 + .../server-pgsql/centos/docker-entrypoint.sh | 82 ++++++++++++------- Dockerfiles/server-pgsql/ol/Dockerfile | 2 + .../server-pgsql/ol/docker-entrypoint.sh | 82 ++++++++++++------- Dockerfiles/server-pgsql/ubuntu/Dockerfile | 2 + .../server-pgsql/ubuntu/docker-entrypoint.sh | 82 ++++++++++++------- docker-compose_v3_alpine_mysql_latest.yaml | 1 + docker-compose_v3_alpine_mysql_local.yaml | 1 + docker-compose_v3_alpine_pgsql_latest.yaml | 1 + docker-compose_v3_alpine_pgsql_local.yaml | 1 + docker-compose_v3_centos_mysql_latest.yaml | 1 + docker-compose_v3_centos_mysql_local.yaml | 1 + docker-compose_v3_centos_pgsql_latest.yaml | 1 + docker-compose_v3_centos_pgsql_local.yaml | 1 + docker-compose_v3_ol_mysql_latest.yaml | 1 + docker-compose_v3_ol_mysql_local.yaml | 1 + docker-compose_v3_ol_pgsql_latest.yaml | 1 + docker-compose_v3_ol_pgsql_local.yaml | 1 + docker-compose_v3_ubuntu_mysql_latest.yaml | 1 + docker-compose_v3_ubuntu_mysql_local.yaml | 1 + docker-compose_v3_ubuntu_pgsql_latest.yaml | 1 + docker-compose_v3_ubuntu_pgsql_local.yaml | 1 + 39 files changed, 566 insertions(+), 217 deletions(-) diff --git a/Dockerfiles/proxy-mysql/alpine/docker-entrypoint.sh b/Dockerfiles/proxy-mysql/alpine/docker-entrypoint.sh index d4cd7dd83..7d23d36cb 100755 --- a/Dockerfiles/proxy-mysql/alpine/docker-entrypoint.sh +++ b/Dockerfiles/proxy-mysql/alpine/docker-entrypoint.sh @@ -20,6 +20,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -250,6 +253,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -290,16 +314,7 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" - - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-proxy-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + exec_sql_file "/usr/share/doc/zabbix-proxy-mysql/create.sql.gz" fi } diff --git a/Dockerfiles/proxy-mysql/centos/docker-entrypoint.sh b/Dockerfiles/proxy-mysql/centos/docker-entrypoint.sh index 036228363..358b3f143 100755 --- a/Dockerfiles/proxy-mysql/centos/docker-entrypoint.sh +++ b/Dockerfiles/proxy-mysql/centos/docker-entrypoint.sh @@ -20,6 +20,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -247,6 +250,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -287,16 +311,7 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" - - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-proxy-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + exec_sql_file "/usr/share/doc/zabbix-proxy-mysql/create.sql.gz" fi } diff --git a/Dockerfiles/proxy-mysql/ol/docker-entrypoint.sh b/Dockerfiles/proxy-mysql/ol/docker-entrypoint.sh index 036228363..358b3f143 100755 --- a/Dockerfiles/proxy-mysql/ol/docker-entrypoint.sh +++ b/Dockerfiles/proxy-mysql/ol/docker-entrypoint.sh @@ -20,6 +20,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -247,6 +250,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -287,16 +311,7 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" - - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-proxy-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + exec_sql_file "/usr/share/doc/zabbix-proxy-mysql/create.sql.gz" fi } diff --git a/Dockerfiles/proxy-mysql/rhel/docker-entrypoint.sh b/Dockerfiles/proxy-mysql/rhel/docker-entrypoint.sh index 9bbf13b2f..358b3f143 100755 --- a/Dockerfiles/proxy-mysql/rhel/docker-entrypoint.sh +++ b/Dockerfiles/proxy-mysql/rhel/docker-entrypoint.sh @@ -20,6 +20,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -247,6 +250,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -261,7 +285,6 @@ create_db_user_mysql() { fi mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null - mysql_query "GRANT SESSION_VARIABLES_ADMIN ON *. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null } create_db_database_mysql() { @@ -288,16 +311,7 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" - - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-proxy-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + exec_sql_file "/usr/share/doc/zabbix-proxy-mysql/create.sql.gz" fi } diff --git a/Dockerfiles/proxy-mysql/ubuntu/docker-entrypoint.sh b/Dockerfiles/proxy-mysql/ubuntu/docker-entrypoint.sh index 2e4a3df03..3fb69b37a 100755 --- a/Dockerfiles/proxy-mysql/ubuntu/docker-entrypoint.sh +++ b/Dockerfiles/proxy-mysql/ubuntu/docker-entrypoint.sh @@ -20,6 +20,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -247,6 +250,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -287,16 +311,7 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" - - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-proxy-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + exec_sql_file "/usr/share/doc/zabbix-proxy-mysql/create.sql.gz" fi } diff --git a/Dockerfiles/server-mysql/alpine/Dockerfile b/Dockerfiles/server-mysql/alpine/Dockerfile index ad281563a..86161c03a 100644 --- a/Dockerfiles/server-mysql/alpine/Dockerfile +++ b/Dockerfiles/server-mysql/alpine/Dockerfile @@ -73,6 +73,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-mysql/alpine/docker-entrypoint.sh b/Dockerfiles/server-mysql/alpine/docker-entrypoint.sh index fd842d1e0..39cdc3b8a 100755 --- a/Dockerfiles/server-mysql/alpine/docker-entrypoint.sh +++ b/Dockerfiles/server-mysql/alpine/docker-entrypoint.sh @@ -15,6 +15,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -245,6 +248,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -266,7 +290,7 @@ create_db_database_mysql() { if [ -z ${DB_EXISTS} ]; then echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..." - mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET utf8 COLLATE utf8_bin" 1>/dev/null + mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET ${DB_CHARACTER_SET} COLLATE ${DB_CHARACTER_COLLATE}" 1>/dev/null # better solution? mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null else @@ -274,6 +298,17 @@ create_db_database_mysql() { fi } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_mysql() { DBVERSION_TABLE_EXISTS=$(mysql_query "SELECT 1 FROM information_schema.tables WHERE table_schema='${DB_SERVER_DBNAME}' and table_name = 'dbversion'") @@ -285,16 +320,10 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" + exec_sql_file "/usr/share/doc/zabbix-server-mysql/create.sql.gz" - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-mysql/centos/Dockerfile b/Dockerfiles/server-mysql/centos/Dockerfile index 7ad3554af..41349fc79 100644 --- a/Dockerfiles/server-mysql/centos/Dockerfile +++ b/Dockerfiles/server-mysql/centos/Dockerfile @@ -81,6 +81,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-mysql/centos/docker-entrypoint.sh b/Dockerfiles/server-mysql/centos/docker-entrypoint.sh index 840dc78e2..0e00ddbf6 100755 --- a/Dockerfiles/server-mysql/centos/docker-entrypoint.sh +++ b/Dockerfiles/server-mysql/centos/docker-entrypoint.sh @@ -15,6 +15,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -242,6 +245,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -263,7 +287,7 @@ create_db_database_mysql() { if [ -z ${DB_EXISTS} ]; then echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..." - mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET utf8 COLLATE utf8_bin" 1>/dev/null + mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET ${DB_CHARACTER_SET} COLLATE ${DB_CHARACTER_COLLATE}" 1>/dev/null # better solution? mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null else @@ -271,6 +295,17 @@ create_db_database_mysql() { fi } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_mysql() { DBVERSION_TABLE_EXISTS=$(mysql_query "SELECT 1 FROM information_schema.tables WHERE table_schema='${DB_SERVER_DBNAME}' and table_name = 'dbversion'") @@ -282,16 +317,10 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" + exec_sql_file "/usr/share/doc/zabbix-server-mysql/create.sql.gz" - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-mysql/ol/Dockerfile b/Dockerfiles/server-mysql/ol/Dockerfile index 6dab75291..060e93724 100644 --- a/Dockerfiles/server-mysql/ol/Dockerfile +++ b/Dockerfiles/server-mysql/ol/Dockerfile @@ -83,6 +83,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-mysql/ol/docker-entrypoint.sh b/Dockerfiles/server-mysql/ol/docker-entrypoint.sh index 840dc78e2..d1a9cd00e 100755 --- a/Dockerfiles/server-mysql/ol/docker-entrypoint.sh +++ b/Dockerfiles/server-mysql/ol/docker-entrypoint.sh @@ -15,6 +15,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -242,6 +245,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -263,7 +287,7 @@ create_db_database_mysql() { if [ -z ${DB_EXISTS} ]; then echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..." - mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET utf8 COLLATE utf8_bin" 1>/dev/null + mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET ${DB_CHARACTER_SET} COLLATE ${DB_CHARACTER_COLLATE}" 1>/dev/null # better solution? mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null else @@ -271,6 +295,17 @@ create_db_database_mysql() { fi } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_mysql() { DBVERSION_TABLE_EXISTS=$(mysql_query "SELECT 1 FROM information_schema.tables WHERE table_schema='${DB_SERVER_DBNAME}' and table_name = 'dbversion'") @@ -282,16 +317,10 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" + exec_sql_file "/usr/share/doc/zabbix-server-mysql/create.sql.gz" - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-mysql/rhel/Dockerfile b/Dockerfiles/server-mysql/rhel/Dockerfile index 4c723db66..d73dde979 100644 --- a/Dockerfiles/server-mysql/rhel/Dockerfile +++ b/Dockerfiles/server-mysql/rhel/Dockerfile @@ -109,6 +109,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-mysql/rhel/docker-entrypoint.sh b/Dockerfiles/server-mysql/rhel/docker-entrypoint.sh index 840dc78e2..d1a9cd00e 100755 --- a/Dockerfiles/server-mysql/rhel/docker-entrypoint.sh +++ b/Dockerfiles/server-mysql/rhel/docker-entrypoint.sh @@ -15,6 +15,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -242,6 +245,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -263,7 +287,7 @@ create_db_database_mysql() { if [ -z ${DB_EXISTS} ]; then echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..." - mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET utf8 COLLATE utf8_bin" 1>/dev/null + mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET ${DB_CHARACTER_SET} COLLATE ${DB_CHARACTER_COLLATE}" 1>/dev/null # better solution? mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null else @@ -271,6 +295,17 @@ create_db_database_mysql() { fi } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_mysql() { DBVERSION_TABLE_EXISTS=$(mysql_query "SELECT 1 FROM information_schema.tables WHERE table_schema='${DB_SERVER_DBNAME}' and table_name = 'dbversion'") @@ -282,16 +317,10 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" + exec_sql_file "/usr/share/doc/zabbix-server-mysql/create.sql.gz" - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-mysql/ubuntu/Dockerfile b/Dockerfiles/server-mysql/ubuntu/Dockerfile index 0190228a6..17a940a94 100644 --- a/Dockerfiles/server-mysql/ubuntu/Dockerfile +++ b/Dockerfiles/server-mysql/ubuntu/Dockerfile @@ -76,6 +76,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-mysql/ubuntu/docker-entrypoint.sh b/Dockerfiles/server-mysql/ubuntu/docker-entrypoint.sh index 3352937ae..881a6b11a 100755 --- a/Dockerfiles/server-mysql/ubuntu/docker-entrypoint.sh +++ b/Dockerfiles/server-mysql/ubuntu/docker-entrypoint.sh @@ -15,6 +15,9 @@ ZABBIX_USER_HOME_DIR="/var/lib/zabbix" # Configuration files directory ZABBIX_ETC_DIR="/etc/zabbix" +: ${DB_CHARACTER_SET:="utf8"} +: ${DB_CHARACTER_COLLATE:="utf8_bin"} + # usage: file_env VAR [DEFAULT] # as example: file_env 'MYSQL_PASSWORD' 'zabbix' # (will allow for "$MYSQL_PASSWORD_FILE" to fill in the value of "$MYSQL_PASSWORD" from a file) @@ -242,6 +245,27 @@ mysql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + ssl_opts="$(db_tls_params)" + + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command "$sql_script" | mysql --silent --skip-column-names \ + -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ + -u ${DB_SERVER_ROOT_USER} $ssl_opts \ + ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD +} + create_db_user_mysql() { [ "${CREATE_ZBX_DB_USER}" == "true" ] || return @@ -263,7 +287,7 @@ create_db_database_mysql() { if [ -z ${DB_EXISTS} ]; then echo "** Database '${DB_SERVER_DBNAME}' does not exist. Creating..." - mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET utf8 COLLATE utf8_bin" 1>/dev/null + mysql_query "CREATE DATABASE ${DB_SERVER_DBNAME} CHARACTER SET ${DB_CHARACTER_SET} COLLATE ${DB_CHARACTER_COLLATE}" 1>/dev/null # better solution? mysql_query "GRANT ALL PRIVILEGES ON $DB_SERVER_DBNAME. * TO '${DB_SERVER_ZBX_USER}'@'%'" 1>/dev/null else @@ -271,6 +295,17 @@ create_db_database_mysql() { fi } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_mysql() { DBVERSION_TABLE_EXISTS=$(mysql_query "SELECT 1 FROM information_schema.tables WHERE table_schema='${DB_SERVER_DBNAME}' and table_name = 'dbversion'") @@ -282,16 +317,10 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" - ssl_opts="$(db_tls_params)" + exec_sql_file "/usr/share/doc/zabbix-server-mysql/create.sql.gz" - export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" - - zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \ - -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \ - -u ${DB_SERVER_ROOT_USER} $ssl_opts \ - ${DB_SERVER_DBNAME} 1>/dev/null - - unset MYSQL_PWD + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-pgsql/alpine/Dockerfile b/Dockerfiles/server-pgsql/alpine/Dockerfile index ec910c020..bfa539d16 100644 --- a/Dockerfiles/server-pgsql/alpine/Dockerfile +++ b/Dockerfiles/server-pgsql/alpine/Dockerfile @@ -74,6 +74,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-pgsql/alpine/docker-entrypoint.sh b/Dockerfiles/server-pgsql/alpine/docker-entrypoint.sh index e57992004..2f62adaa1 100755 --- a/Dockerfiles/server-pgsql/alpine/docker-entrypoint.sh +++ b/Dockerfiles/server-pgsql/alpine/docker-entrypoint.sh @@ -242,6 +242,44 @@ psql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then + export PGPASSWORD="${DB_SERVER_ZBX_PASS}" + fi + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + + if [ -n "${ZBX_DBTLSCONNECT}" ]; then + PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} + export PGSSLMODE=${PGSSLMODE//required/require} + export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} + export PGSSLCERT=${ZBX_DBTLSCERTFILE} + export PGSSLKEY=${ZBX_DBTLSKEYFILE} + fi + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command $sql_script | psql --quiet \ + --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ + --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + + unset PGPASSWORD + unset PGOPTIONS + unset PGSSLMODE + unset PGSSLROOTCERT + unset PGSSLCERT + unset PGSSLKEY +} + create_db_database_postgresql() { DB_EXISTS=$(psql_query "SELECT 1 AS result FROM pg_database WHERE datname='${DB_SERVER_DBNAME}'" "${DB_SERVER_DBNAME}") @@ -281,6 +319,17 @@ create_db_database_postgresql() { psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" "${DB_SERVER_DBNAME}" 1>/dev/null } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_postgresql() { DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") @@ -297,39 +346,14 @@ create_db_schema_postgresql() { psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" "${DB_SERVER_DBNAME}" fi - if [ -n "${DB_SERVER_ZBX_PASS}" ]; then - export PGPASSWORD="${DB_SERVER_ZBX_PASS}" - fi - - if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then - PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" - export PGOPTIONS - fi - - if [ -n "${ZBX_DBTLSCONNECT}" ]; then - PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} - export PGSSLMODE=${PGSSLMODE//required/require} - export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} - export PGSSLCERT=${ZBX_DBTLSCERTFILE} - export PGSSLKEY=${ZBX_DBTLSKEYFILE} - fi - - zcat /usr/share/doc/zabbix-server-postgresql/create.sql.gz | psql --quiet \ - --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ - --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/create.sql.gz" if [ "${ENABLE_TIMESCALEDB,,}" == "true" ]; then - cat /usr/share/doc/zabbix-server-postgresql/timescaledb.sql | psql --quiet \ - --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} \ - --username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/timescaledb.sql" fi - unset PGPASSWORD - unset PGOPTIONS - unset PGSSLMODE - unset PGSSLROOTCERT - unset PGSSLCERT - unset PGSSLKEY + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-pgsql/centos/Dockerfile b/Dockerfiles/server-pgsql/centos/Dockerfile index e542157b5..e2423cc3b 100644 --- a/Dockerfiles/server-pgsql/centos/Dockerfile +++ b/Dockerfiles/server-pgsql/centos/Dockerfile @@ -80,6 +80,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-pgsql/centos/docker-entrypoint.sh b/Dockerfiles/server-pgsql/centos/docker-entrypoint.sh index e57992004..2f62adaa1 100755 --- a/Dockerfiles/server-pgsql/centos/docker-entrypoint.sh +++ b/Dockerfiles/server-pgsql/centos/docker-entrypoint.sh @@ -242,6 +242,44 @@ psql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then + export PGPASSWORD="${DB_SERVER_ZBX_PASS}" + fi + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + + if [ -n "${ZBX_DBTLSCONNECT}" ]; then + PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} + export PGSSLMODE=${PGSSLMODE//required/require} + export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} + export PGSSLCERT=${ZBX_DBTLSCERTFILE} + export PGSSLKEY=${ZBX_DBTLSKEYFILE} + fi + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command $sql_script | psql --quiet \ + --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ + --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + + unset PGPASSWORD + unset PGOPTIONS + unset PGSSLMODE + unset PGSSLROOTCERT + unset PGSSLCERT + unset PGSSLKEY +} + create_db_database_postgresql() { DB_EXISTS=$(psql_query "SELECT 1 AS result FROM pg_database WHERE datname='${DB_SERVER_DBNAME}'" "${DB_SERVER_DBNAME}") @@ -281,6 +319,17 @@ create_db_database_postgresql() { psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" "${DB_SERVER_DBNAME}" 1>/dev/null } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_postgresql() { DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") @@ -297,39 +346,14 @@ create_db_schema_postgresql() { psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" "${DB_SERVER_DBNAME}" fi - if [ -n "${DB_SERVER_ZBX_PASS}" ]; then - export PGPASSWORD="${DB_SERVER_ZBX_PASS}" - fi - - if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then - PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" - export PGOPTIONS - fi - - if [ -n "${ZBX_DBTLSCONNECT}" ]; then - PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} - export PGSSLMODE=${PGSSLMODE//required/require} - export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} - export PGSSLCERT=${ZBX_DBTLSCERTFILE} - export PGSSLKEY=${ZBX_DBTLSKEYFILE} - fi - - zcat /usr/share/doc/zabbix-server-postgresql/create.sql.gz | psql --quiet \ - --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ - --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/create.sql.gz" if [ "${ENABLE_TIMESCALEDB,,}" == "true" ]; then - cat /usr/share/doc/zabbix-server-postgresql/timescaledb.sql | psql --quiet \ - --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} \ - --username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/timescaledb.sql" fi - unset PGPASSWORD - unset PGOPTIONS - unset PGSSLMODE - unset PGSSLROOTCERT - unset PGSSLCERT - unset PGSSLKEY + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-pgsql/ol/Dockerfile b/Dockerfiles/server-pgsql/ol/Dockerfile index 8b2f7a200..6a3fa41f9 100644 --- a/Dockerfiles/server-pgsql/ol/Dockerfile +++ b/Dockerfiles/server-pgsql/ol/Dockerfile @@ -81,6 +81,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-pgsql/ol/docker-entrypoint.sh b/Dockerfiles/server-pgsql/ol/docker-entrypoint.sh index e57992004..2f62adaa1 100755 --- a/Dockerfiles/server-pgsql/ol/docker-entrypoint.sh +++ b/Dockerfiles/server-pgsql/ol/docker-entrypoint.sh @@ -242,6 +242,44 @@ psql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then + export PGPASSWORD="${DB_SERVER_ZBX_PASS}" + fi + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + + if [ -n "${ZBX_DBTLSCONNECT}" ]; then + PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} + export PGSSLMODE=${PGSSLMODE//required/require} + export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} + export PGSSLCERT=${ZBX_DBTLSCERTFILE} + export PGSSLKEY=${ZBX_DBTLSKEYFILE} + fi + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command $sql_script | psql --quiet \ + --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ + --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + + unset PGPASSWORD + unset PGOPTIONS + unset PGSSLMODE + unset PGSSLROOTCERT + unset PGSSLCERT + unset PGSSLKEY +} + create_db_database_postgresql() { DB_EXISTS=$(psql_query "SELECT 1 AS result FROM pg_database WHERE datname='${DB_SERVER_DBNAME}'" "${DB_SERVER_DBNAME}") @@ -281,6 +319,17 @@ create_db_database_postgresql() { psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" "${DB_SERVER_DBNAME}" 1>/dev/null } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_postgresql() { DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") @@ -297,39 +346,14 @@ create_db_schema_postgresql() { psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" "${DB_SERVER_DBNAME}" fi - if [ -n "${DB_SERVER_ZBX_PASS}" ]; then - export PGPASSWORD="${DB_SERVER_ZBX_PASS}" - fi - - if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then - PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" - export PGOPTIONS - fi - - if [ -n "${ZBX_DBTLSCONNECT}" ]; then - PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} - export PGSSLMODE=${PGSSLMODE//required/require} - export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} - export PGSSLCERT=${ZBX_DBTLSCERTFILE} - export PGSSLKEY=${ZBX_DBTLSKEYFILE} - fi - - zcat /usr/share/doc/zabbix-server-postgresql/create.sql.gz | psql --quiet \ - --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ - --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/create.sql.gz" if [ "${ENABLE_TIMESCALEDB,,}" == "true" ]; then - cat /usr/share/doc/zabbix-server-postgresql/timescaledb.sql | psql --quiet \ - --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} \ - --username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/timescaledb.sql" fi - unset PGPASSWORD - unset PGOPTIONS - unset PGSSLMODE - unset PGSSLROOTCERT - unset PGSSLCERT - unset PGSSLKEY + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/Dockerfiles/server-pgsql/ubuntu/Dockerfile b/Dockerfiles/server-pgsql/ubuntu/Dockerfile index 7edd8c922..d5c8a9aa2 100644 --- a/Dockerfiles/server-pgsql/ubuntu/Dockerfile +++ b/Dockerfiles/server-pgsql/ubuntu/Dockerfile @@ -77,6 +77,8 @@ RUN set -eux && \ mkdir -p /etc/zabbix && \ mkdir -p /var/lib/zabbix && \ mkdir -p /usr/lib/zabbix/alertscripts && \ + mkdir -p /usr/lib/zabbix/dbscripts && \ + mkdir -p /var/lib/zabbix/dbscripts && \ mkdir -p /var/lib/zabbix/enc && \ mkdir -p /var/lib/zabbix/export && \ mkdir -p /usr/lib/zabbix/externalscripts && \ diff --git a/Dockerfiles/server-pgsql/ubuntu/docker-entrypoint.sh b/Dockerfiles/server-pgsql/ubuntu/docker-entrypoint.sh index b45ff8114..bc83dd5bf 100755 --- a/Dockerfiles/server-pgsql/ubuntu/docker-entrypoint.sh +++ b/Dockerfiles/server-pgsql/ubuntu/docker-entrypoint.sh @@ -242,6 +242,44 @@ psql_query() { echo $result } +exec_sql_file() { + sql_script=$1 + + local command="cat" + + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then + export PGPASSWORD="${DB_SERVER_ZBX_PASS}" + fi + + if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then + PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" + export PGOPTIONS + fi + + if [ -n "${ZBX_DBTLSCONNECT}" ]; then + PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} + export PGSSLMODE=${PGSSLMODE//required/require} + export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} + export PGSSLCERT=${ZBX_DBTLSCERTFILE} + export PGSSLKEY=${ZBX_DBTLSKEYFILE} + fi + + if [ "${sql_script: -3}" == ".gz" ]; then + command="zcat" + fi + + $command $sql_script | psql --quiet \ + --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ + --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + + unset PGPASSWORD + unset PGOPTIONS + unset PGSSLMODE + unset PGSSLROOTCERT + unset PGSSLCERT + unset PGSSLKEY +} + create_db_database_postgresql() { DB_EXISTS=$(psql_query "SELECT 1 AS result FROM pg_database WHERE datname='${DB_SERVER_DBNAME}'" "${DB_SERVER_DBNAME}") @@ -281,6 +319,17 @@ create_db_database_postgresql() { psql_query "CREATE SCHEMA IF NOT EXISTS ${DB_SERVER_SCHEMA}" "${DB_SERVER_DBNAME}" 1>/dev/null } +apply_db_scripts() { + db_scripts=$1 + + for sql_script in $db_scripts; do + [ -e "$sql_script" ] || continue + echo "** Processing additional '$sql_script' SQL script" + + exec_sql_file "$sql_script" + done +} + create_db_schema_postgresql() { DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") @@ -297,39 +346,14 @@ create_db_schema_postgresql() { psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" "${DB_SERVER_DBNAME}" fi - if [ -n "${DB_SERVER_ZBX_PASS}" ]; then - export PGPASSWORD="${DB_SERVER_ZBX_PASS}" - fi - - if [ "${POSTGRES_USE_IMPLICIT_SEARCH_PATH,,}" == "false" ] && [ -n "${DB_SERVER_SCHEMA}" ]; then - PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}" - export PGOPTIONS - fi - - if [ -n "${ZBX_DBTLSCONNECT}" ]; then - PGSSLMODE=${ZBX_DBTLSCONNECT//_/-} - export PGSSLMODE=${PGSSLMODE//required/require} - export PGSSLROOTCERT=${ZBX_DBTLSCAFILE} - export PGSSLCERT=${ZBX_DBTLSCERTFILE} - export PGSSLKEY=${ZBX_DBTLSKEYFILE} - fi - - zcat /usr/share/doc/zabbix-server-postgresql/create.sql.gz | psql --quiet \ - --host "${DB_SERVER_HOST}" --port "${DB_SERVER_PORT}" \ - --username "${DB_SERVER_ZBX_USER}" --dbname "${DB_SERVER_DBNAME}" 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/create.sql.gz" if [ "${ENABLE_TIMESCALEDB,,}" == "true" ]; then - cat /usr/share/doc/zabbix-server-postgresql/timescaledb.sql | psql --quiet \ - --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} \ - --username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1 + exec_sql_file "/usr/share/doc/zabbix-server-postgresql/timescaledb.sql" fi - unset PGPASSWORD - unset PGOPTIONS - unset PGSSLMODE - unset PGSSLROOTCERT - unset PGSSLCERT - unset PGSSLKEY + apply_db_scripts "/usr/lib/zabbix/dbscripts/*.sql" + apply_db_scripts "/var/lib/zabbix/dbscripts/*.sql" fi } diff --git a/docker-compose_v3_alpine_mysql_latest.yaml b/docker-compose_v3_alpine_mysql_latest.yaml index 87174771b..64f75e4f3 100644 --- a/docker-compose_v3_alpine_mysql_latest.yaml +++ b/docker-compose_v3_alpine_mysql_latest.yaml @@ -9,6 +9,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_alpine_mysql_local.yaml b/docker-compose_v3_alpine_mysql_local.yaml index cd12385f3..b28fb0a95 100644 --- a/docker-compose_v3_alpine_mysql_local.yaml +++ b/docker-compose_v3_alpine_mysql_local.yaml @@ -46,6 +46,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_alpine_pgsql_latest.yaml b/docker-compose_v3_alpine_pgsql_latest.yaml index 1b0c9a270..b2498eaf0 100644 --- a/docker-compose_v3_alpine_pgsql_latest.yaml +++ b/docker-compose_v3_alpine_pgsql_latest.yaml @@ -9,6 +9,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_alpine_pgsql_local.yaml b/docker-compose_v3_alpine_pgsql_local.yaml index 510594de7..ad55a9cba 100644 --- a/docker-compose_v3_alpine_pgsql_local.yaml +++ b/docker-compose_v3_alpine_pgsql_local.yaml @@ -59,6 +59,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_centos_mysql_latest.yaml b/docker-compose_v3_centos_mysql_latest.yaml index cb48b1d3a..b9d92f0eb 100644 --- a/docker-compose_v3_centos_mysql_latest.yaml +++ b/docker-compose_v3_centos_mysql_latest.yaml @@ -9,6 +9,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_centos_mysql_local.yaml b/docker-compose_v3_centos_mysql_local.yaml index d53845340..85e079e8c 100644 --- a/docker-compose_v3_centos_mysql_local.yaml +++ b/docker-compose_v3_centos_mysql_local.yaml @@ -46,6 +46,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_centos_pgsql_latest.yaml b/docker-compose_v3_centos_pgsql_latest.yaml index d48dc8dfe..9b137020c 100644 --- a/docker-compose_v3_centos_pgsql_latest.yaml +++ b/docker-compose_v3_centos_pgsql_latest.yaml @@ -9,6 +9,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_centos_pgsql_local.yaml b/docker-compose_v3_centos_pgsql_local.yaml index bda423e99..025f59315 100644 --- a/docker-compose_v3_centos_pgsql_local.yaml +++ b/docker-compose_v3_centos_pgsql_local.yaml @@ -59,6 +59,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ol_mysql_latest.yaml b/docker-compose_v3_ol_mysql_latest.yaml index a3999af22..07fab0d6f 100644 --- a/docker-compose_v3_ol_mysql_latest.yaml +++ b/docker-compose_v3_ol_mysql_latest.yaml @@ -9,6 +9,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ol_mysql_local.yaml b/docker-compose_v3_ol_mysql_local.yaml index 8e93f24e4..b3f082180 100644 --- a/docker-compose_v3_ol_mysql_local.yaml +++ b/docker-compose_v3_ol_mysql_local.yaml @@ -46,6 +46,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ol_pgsql_latest.yaml b/docker-compose_v3_ol_pgsql_latest.yaml index a57209ff5..6150cea3c 100644 --- a/docker-compose_v3_ol_pgsql_latest.yaml +++ b/docker-compose_v3_ol_pgsql_latest.yaml @@ -9,6 +9,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ol_pgsql_local.yaml b/docker-compose_v3_ol_pgsql_local.yaml index a2d4c4e02..ae6ca7712 100644 --- a/docker-compose_v3_ol_pgsql_local.yaml +++ b/docker-compose_v3_ol_pgsql_local.yaml @@ -59,6 +59,7 @@ services: - /etc/timezone:/etc/timezone:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ubuntu_mysql_latest.yaml b/docker-compose_v3_ubuntu_mysql_latest.yaml index c3a60301b..6c260a662 100644 --- a/docker-compose_v3_ubuntu_mysql_latest.yaml +++ b/docker-compose_v3_ubuntu_mysql_latest.yaml @@ -8,6 +8,7 @@ services: - /etc/localtime:/etc/localtime:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ubuntu_mysql_local.yaml b/docker-compose_v3_ubuntu_mysql_local.yaml index 6c4582ae1..c96344755 100644 --- a/docker-compose_v3_ubuntu_mysql_local.yaml +++ b/docker-compose_v3_ubuntu_mysql_local.yaml @@ -45,6 +45,7 @@ services: - /etc/localtime:/etc/localtime:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ubuntu_pgsql_latest.yaml b/docker-compose_v3_ubuntu_pgsql_latest.yaml index 4b7c8e4ee..67f546bdc 100644 --- a/docker-compose_v3_ubuntu_pgsql_latest.yaml +++ b/docker-compose_v3_ubuntu_pgsql_latest.yaml @@ -8,6 +8,7 @@ services: - /etc/localtime:/etc/localtime:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro diff --git a/docker-compose_v3_ubuntu_pgsql_local.yaml b/docker-compose_v3_ubuntu_pgsql_local.yaml index 9ae8f476a..f91a432c3 100644 --- a/docker-compose_v3_ubuntu_pgsql_local.yaml +++ b/docker-compose_v3_ubuntu_pgsql_local.yaml @@ -58,6 +58,7 @@ services: - /etc/localtime:/etc/localtime:ro - ./zbx_env/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts:ro - ./zbx_env/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts:ro + - ./zbx_env/var/lib/zabbix/dbscripts:/var/lib/zabbix/dbscripts:ro - ./zbx_env/var/lib/zabbix/export:/var/lib/zabbix/export:rw - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro