mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-06-20 09:57:43 +02:00
More flexible DB TLS params usage
This commit is contained in:
parent
5537e6abd2
commit
b72b334a03
@ -229,6 +229,32 @@ check_variables_mysql() {
|
||||
DB_SERVER_DBNAME=${MYSQL_DATABASE:-"zabbix"}
|
||||
}
|
||||
|
||||
db_tls_params() {
|
||||
local result=""
|
||||
|
||||
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||
result="--ssl"
|
||||
|
||||
if [ "${ZBX_DBTLSCONNECT}" != "required" ]; then
|
||||
result="${result} --ssl-verify-server-cert"
|
||||
fi
|
||||
|
||||
if [ -n "${ZBX_DBTLSCAFILE}" ]; then
|
||||
result="${result} --ssl-ca=${ZBX_DBTLSCAFILE}"
|
||||
fi
|
||||
|
||||
if [ -n "${ZBX_DBTLSKEYFILE}" ]; then
|
||||
result="${result} --ssl-key=${ZBX_DBTLSKEYFILE}"
|
||||
fi
|
||||
|
||||
if [ -n "${ZBX_DBTLSCERTFILE}" ]; then
|
||||
result="${result} --ssl-cert=${ZBX_DBTLSCERTFILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $result
|
||||
}
|
||||
|
||||
check_db_connect() {
|
||||
echo "********************"
|
||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||
@ -246,12 +272,7 @@ check_db_connect() {
|
||||
|
||||
WAIT_TIMEOUT=5
|
||||
|
||||
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||
if [ "${ZBX_DBTLSCONNECT}" != "required" ]; then
|
||||
verify_cert="--ssl-verify-server-cert"
|
||||
fi
|
||||
ssl_opts="--ssl --ssl-ca=${ZBX_DBTLSCAFILE} --ssl-key=${ZBX_DBTLSKEYFILE} --ssl-cert=${ZBX_DBTLSCERTFILE} $verify_cert"
|
||||
fi
|
||||
ssl_opts="$(db_tls_params)"
|
||||
|
||||
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 $ssl_opts)" ]; do
|
||||
@ -264,12 +285,7 @@ mysql_query() {
|
||||
query=$1
|
||||
local result=""
|
||||
|
||||
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||
if [ "${ZBX_DBTLSCONNECT}" != "required" ]; then
|
||||
verify_cert="--ssl-verify-server-cert"
|
||||
fi
|
||||
ssl_opts="--ssl --ssl-ca=${ZBX_DBTLSCAFILE} --ssl-key=${ZBX_DBTLSKEYFILE} --ssl-cert=${ZBX_DBTLSCERTFILE} $verify_cert"
|
||||
fi
|
||||
ssl_opts="$(db_tls_params)"
|
||||
|
||||
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" $ssl_opts)
|
||||
@ -317,12 +333,7 @@ create_db_schema_mysql() {
|
||||
if [ -z "${ZBX_DB_VERSION}" ]; then
|
||||
echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL"
|
||||
|
||||
if [ -n "${ZBX_DBTLSCONNECT}" ]; then
|
||||
if [ "${ZBX_DBTLSCONNECT}" != "required" ]; then
|
||||
verify_cert="--ssl-verify-server-cert"
|
||||
fi
|
||||
ssl_opts="--ssl --ssl-ca=${ZBX_DBTLSCAFILE} --ssl-key=${ZBX_DBTLSKEYFILE} --ssl-cert=${ZBX_DBTLSCERTFILE} $verify_cert"
|
||||
fi
|
||||
ssl_opts="$(db_tls_params)"
|
||||
|
||||
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql --silent --skip-column-names \
|
||||
-h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
|
||||
|
Loading…
x
Reference in New Issue
Block a user