diff --git a/proxy-mysql/alpine/docker-entrypoint.sh b/proxy-mysql/alpine/docker-entrypoint.sh index b9f568348..b63fed074 100755 --- a/proxy-mysql/alpine/docker-entrypoint.sh +++ b/proxy-mysql/alpine/docker-entrypoint.sh @@ -194,19 +194,27 @@ check_db_connect_mysql() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } mysql_query() { query=$1 local result="" + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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} -e "$query") + + unset MYSQL_PWD echo $result } @@ -251,10 +259,14 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" + 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} --password="${DB_SERVER_ROOT_PASS}" \ + -u ${DB_SERVER_ROOT_USER} \ ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD fi } diff --git a/proxy-mysql/centos/docker-entrypoint.sh b/proxy-mysql/centos/docker-entrypoint.sh index b9f568348..2df57fdd5 100755 --- a/proxy-mysql/centos/docker-entrypoint.sh +++ b/proxy-mysql/centos/docker-entrypoint.sh @@ -194,20 +194,28 @@ check_db_connect_mysql() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } mysql_query() { query=$1 local result="" + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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") + unset MYSQL_PWD + echo $result } @@ -251,10 +259,14 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" + 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} --password="${DB_SERVER_ROOT_PASS}" \ + -u ${DB_SERVER_ROOT_USER} \ ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD fi } diff --git a/proxy-mysql/ubuntu/docker-entrypoint.sh b/proxy-mysql/ubuntu/docker-entrypoint.sh index aab315429..4c48053e0 100755 --- a/proxy-mysql/ubuntu/docker-entrypoint.sh +++ b/proxy-mysql/ubuntu/docker-entrypoint.sh @@ -194,19 +194,27 @@ check_db_connect_mysql() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } mysql_query() { query=$1 local result="" + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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} -e "$query") + + unset MYSQL_PWD echo $result } @@ -251,10 +259,14 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" + 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} --password="${DB_SERVER_ROOT_PASS}" \ + -u ${DB_SERVER_ROOT_USER} \ ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD fi } diff --git a/server-mysql/alpine/docker-entrypoint.sh b/server-mysql/alpine/docker-entrypoint.sh index e50f21316..77ed8206d 100755 --- a/server-mysql/alpine/docker-entrypoint.sh +++ b/server-mysql/alpine/docker-entrypoint.sh @@ -189,19 +189,27 @@ check_db_connect_mysql() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } mysql_query() { query=$1 local result="" + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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} -e "$query") + + unset MYSQL_PWD echo $result } @@ -246,10 +254,14 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" + 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} --password="${DB_SERVER_ROOT_PASS}" \ + -u ${DB_SERVER_ROOT_USER} \ ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD fi } diff --git a/server-mysql/centos/docker-entrypoint.sh b/server-mysql/centos/docker-entrypoint.sh index e50f21316..77ed8206d 100755 --- a/server-mysql/centos/docker-entrypoint.sh +++ b/server-mysql/centos/docker-entrypoint.sh @@ -189,19 +189,27 @@ check_db_connect_mysql() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } mysql_query() { query=$1 local result="" + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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} -e "$query") + + unset MYSQL_PWD echo $result } @@ -246,10 +254,14 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" + 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} --password="${DB_SERVER_ROOT_PASS}" \ + -u ${DB_SERVER_ROOT_USER} \ ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD fi } diff --git a/server-mysql/ubuntu/docker-entrypoint.sh b/server-mysql/ubuntu/docker-entrypoint.sh index 9f3b31490..15d5eebea 100755 --- a/server-mysql/ubuntu/docker-entrypoint.sh +++ b/server-mysql/ubuntu/docker-entrypoint.sh @@ -189,19 +189,27 @@ check_db_connect_mysql() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } mysql_query() { query=$1 local result="" + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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} -e "$query") + + unset MYSQL_PWD echo $result } @@ -246,10 +254,14 @@ create_db_schema_mysql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in MySQL" + 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} --password="${DB_SERVER_ROOT_PASS}" \ + -u ${DB_SERVER_ROOT_USER} \ ${DB_SERVER_DBNAME} 1>/dev/null + + unset MYSQL_PWD fi } diff --git a/web-apache-mysql/alpine/docker-entrypoint.sh b/web-apache-mysql/alpine/docker-entrypoint.sh index f10c16b9e..2eadc7af9 100755 --- a/web-apache-mysql/alpine/docker-entrypoint.sh +++ b/web-apache-mysql/alpine/docker-entrypoint.sh @@ -171,11 +171,15 @@ check_db_connect() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } prepare_web_server() { diff --git a/web-apache-mysql/centos/docker-entrypoint.sh b/web-apache-mysql/centos/docker-entrypoint.sh index 1e556658b..e964c8b3d 100755 --- a/web-apache-mysql/centos/docker-entrypoint.sh +++ b/web-apache-mysql/centos/docker-entrypoint.sh @@ -171,11 +171,15 @@ check_db_connect() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } prepare_web_server() { diff --git a/web-apache-mysql/ubuntu/docker-entrypoint.sh b/web-apache-mysql/ubuntu/docker-entrypoint.sh index 1abd0b211..578fd538b 100755 --- a/web-apache-mysql/ubuntu/docker-entrypoint.sh +++ b/web-apache-mysql/ubuntu/docker-entrypoint.sh @@ -171,11 +171,15 @@ check_db_connect() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } prepare_web_server() { diff --git a/web-nginx-mysql/alpine/docker-entrypoint.sh b/web-nginx-mysql/alpine/docker-entrypoint.sh index d9e7650df..b4d47f914 100755 --- a/web-nginx-mysql/alpine/docker-entrypoint.sh +++ b/web-nginx-mysql/alpine/docker-entrypoint.sh @@ -190,11 +190,15 @@ check_db_connect() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } prepare_web_server() { diff --git a/web-nginx-mysql/centos/docker-entrypoint.sh b/web-nginx-mysql/centos/docker-entrypoint.sh index c022ef887..51a89110f 100755 --- a/web-nginx-mysql/centos/docker-entrypoint.sh +++ b/web-nginx-mysql/centos/docker-entrypoint.sh @@ -190,11 +190,15 @@ check_db_connect() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } prepare_web_server() { diff --git a/web-nginx-mysql/ubuntu/docker-entrypoint.sh b/web-nginx-mysql/ubuntu/docker-entrypoint.sh index 7b00ff08d..dd6257e3f 100755 --- a/web-nginx-mysql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-mysql/ubuntu/docker-entrypoint.sh @@ -190,11 +190,15 @@ check_db_connect() { WAIT_TIMEOUT=5 + export MYSQL_PWD="${DB_SERVER_ROOT_PASS}" + 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 + --silent --connect_timeout=10)" ]; do echo "**** MySQL server is not available. Waiting $WAIT_TIMEOUT seconds..." sleep $WAIT_TIMEOUT done + + unset MYSQL_PWD } prepare_web_server() {