mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-02-09 06:20:37 +01:00
Added MySQL cert encryption support to RHEL images
This commit is contained in:
parent
a4804f5e4c
commit
a2b0873785
@ -189,8 +189,12 @@ check_db_connect_mysql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||||
|
ssl_opts="--ssl --ssl-ca=${ZBX_DBTLSCAFILE} --ssl-key=${ZBX_DBTLSKEYFILE} --ssl-cert=${ZBX_DBTLSCERTFILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(mysqladmin ping -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} -u ${DB_SERVER_ROOT_USER} \
|
while [ ! "$(mysqladmin ping -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} -u ${DB_SERVER_ROOT_USER} \
|
||||||
--password="${DB_SERVER_ROOT_PASS}" --silent --connect_timeout=10)" ]; do
|
--password="${DB_SERVER_ROOT_PASS}" --silent --connect_timeout=10 $ssl_opts)" ]; do
|
||||||
echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
@ -200,8 +204,12 @@ mysql_query() {
|
|||||||
query=$1
|
query=$1
|
||||||
local result=""
|
local result=""
|
||||||
|
|
||||||
|
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||||
|
ssl_opts="--ssl --ssl-ca=${ZBX_DBTLSCAFILE} --ssl-key=${ZBX_DBTLSKEYFILE} --ssl-cert=${ZBX_DBTLSCERTFILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(mysql --silent --skip-column-names -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
|
result=$(mysql --silent --skip-column-names -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
|
||||||
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" -e "$query")
|
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" -e "$query" $ssl_opts)
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -246,9 +254,13 @@ create_db_schema_mysql() {
|
|||||||
if [ -z "${ZBX_DB_VERSION}" ]; then
|
if [ -z "${ZBX_DB_VERSION}" ]; then
|
||||||
echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL"
|
echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL"
|
||||||
|
|
||||||
|
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||||
|
ssl_opts="--ssl --ssl-ca=${ZBX_DBTLSCAFILE} --ssl-key=${ZBX_DBTLSKEYFILE} --ssl-cert=${ZBX_DBTLSCERTFILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \
|
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \
|
||||||
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
|
||||||
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" \
|
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" $ssl_opts \
|
||||||
${DB_SERVER_DBNAME} 1>/dev/null
|
${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -268,6 +280,15 @@ update_zbx_config() {
|
|||||||
|
|
||||||
update_config_var $ZBX_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
|
update_config_var $ZBX_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
|
||||||
|
|
||||||
|
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||||
|
update_config_var $ZBX_CONFIG "DBTLSConnect" "${ZBX_DBTLSCONNECT}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBTLSCAFile" "${ZBX_DBTLSCAFILE}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBTLSCertFile" "${ZBX_DBTLSCERTFILE}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBTLSKeyFile" "${ZBX_DBTLSKEYFILE}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBTLSCipher" "${ZBX_DBTLSCIPHER}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBTLSCipher13" "${ZBX_DBTLSCIPHER13}"
|
||||||
|
fi
|
||||||
|
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
@ -295,7 +316,6 @@ update_zbx_config() {
|
|||||||
update_config_var $ZBX_CONFIG "StartTimers" "${ZBX_STARTTIMERS}"
|
update_config_var $ZBX_CONFIG "StartTimers" "${ZBX_STARTTIMERS}"
|
||||||
update_config_var $ZBX_CONFIG "StartEscalators" "${ZBX_STARTESCALATORS}"
|
update_config_var $ZBX_CONFIG "StartEscalators" "${ZBX_STARTESCALATORS}"
|
||||||
update_config_var $ZBX_CONFIG "StartAlerters" "${ZBX_STARTALERTERS}"
|
update_config_var $ZBX_CONFIG "StartAlerters" "${ZBX_STARTALERTERS}"
|
||||||
|
|
||||||
update_config_var $ZBX_CONFIG "StartTimers" "${ZBX_STARTTIMERS}"
|
update_config_var $ZBX_CONFIG "StartTimers" "${ZBX_STARTTIMERS}"
|
||||||
update_config_var $ZBX_CONFIG "StartEscalators" "${ZBX_STARTESCALATORS}"
|
update_config_var $ZBX_CONFIG "StartEscalators" "${ZBX_STARTESCALATORS}"
|
||||||
|
|
||||||
@ -378,6 +398,9 @@ update_zbx_config() {
|
|||||||
update_config_var $ZBX_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}"
|
update_config_var $ZBX_CONFIG "TLSCertFile" "${ZBX_TLSCERTFILE}"
|
||||||
update_config_var $ZBX_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}"
|
update_config_var $ZBX_CONFIG "TLSKeyFile" "${ZBX_TLSKEYFILE}"
|
||||||
|
|
||||||
|
update_config_var $ZBX_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
|
||||||
|
update_config_var $ZBX_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
|
||||||
|
|
||||||
if [ "$(id -u)" != '0' ]; then
|
if [ "$(id -u)" != '0' ]; then
|
||||||
update_config_var $ZBX_CONFIG "User" "$(whoami)"
|
update_config_var $ZBX_CONFIG "User" "$(whoami)"
|
||||||
else
|
else
|
||||||
|
@ -20,9 +20,6 @@ fi
|
|||||||
# Default timezone for web interface
|
# Default timezone for web interface
|
||||||
: ${PHP_TZ:="Europe/Riga"}
|
: ${PHP_TZ:="Europe/Riga"}
|
||||||
|
|
||||||
#Enable PostgreSQL timescaleDB feature:
|
|
||||||
ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"}
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# Configuration files directory
|
# Configuration files directory
|
||||||
ZABBIX_ETC_DIR="/etc/zabbix"
|
ZABBIX_ETC_DIR="/etc/zabbix"
|
||||||
|
@ -20,9 +20,6 @@ fi
|
|||||||
# Default timezone for web interface
|
# Default timezone for web interface
|
||||||
: ${PHP_TZ:="Europe/Riga"}
|
: ${PHP_TZ:="Europe/Riga"}
|
||||||
|
|
||||||
#Enable PostgreSQL timescaleDB feature:
|
|
||||||
ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"}
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# Configuration files directory
|
# Configuration files directory
|
||||||
ZABBIX_ETC_DIR="/etc/zabbix"
|
ZABBIX_ETC_DIR="/etc/zabbix"
|
||||||
|
@ -20,9 +20,6 @@ fi
|
|||||||
# Default timezone for web interface
|
# Default timezone for web interface
|
||||||
: ${PHP_TZ:="Europe/Riga"}
|
: ${PHP_TZ:="Europe/Riga"}
|
||||||
|
|
||||||
#Enable PostgreSQL timescaleDB feature:
|
|
||||||
ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"}
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# Configuration files directory
|
# Configuration files directory
|
||||||
ZABBIX_ETC_DIR="/etc/zabbix"
|
ZABBIX_ETC_DIR="/etc/zabbix"
|
||||||
|
@ -20,9 +20,6 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
|
|||||||
# Default timezone for web interface
|
# Default timezone for web interface
|
||||||
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
||||||
|
|
||||||
#Enable PostgreSQL timescaleDB feature:
|
|
||||||
ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"}
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# User 'zabbix' home directory
|
# User 'zabbix' home directory
|
||||||
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
||||||
|
@ -20,9 +20,6 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
|
|||||||
# Default timezone for web interface
|
# Default timezone for web interface
|
||||||
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
||||||
|
|
||||||
#Enable PostgreSQL timescaleDB feature:
|
|
||||||
ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"}
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# User 'zabbix' home directory
|
# User 'zabbix' home directory
|
||||||
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
||||||
|
@ -20,9 +20,6 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
|
|||||||
# Default timezone for web interface
|
# Default timezone for web interface
|
||||||
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
||||||
|
|
||||||
#Enable PostgreSQL timescaleDB feature:
|
|
||||||
ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"}
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# User 'zabbix' home directory
|
# User 'zabbix' home directory
|
||||||
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
||||||
|
@ -20,9 +20,6 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"}
|
|||||||
# Default timezone for web interface
|
# Default timezone for web interface
|
||||||
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
PHP_TZ=${PHP_TZ:-"Europe/Riga"}
|
||||||
|
|
||||||
#Enable PostgreSQL timescaleDB feature:
|
|
||||||
ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"}
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# User 'zabbix' home directory
|
# User 'zabbix' home directory
|
||||||
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
ZABBIX_USER_HOME_DIR="/var/lib/zabbix"
|
||||||
|
Loading…
Reference in New Issue
Block a user