Fixed PostgreSQL availability check

This commit is contained in:
Alexey Pustovalov 2020-07-29 23:23:19 -04:00
commit c1a7395c8a
13 changed files with 137 additions and 57 deletions

View File

@ -27,11 +27,19 @@ RUN set -eux && \
libldap \
libcurl \
openssl-libs && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
yum -y clean all && \
rm -rf /var/cache/yum /var/lib/yum/yumdb/* /usr/lib/udev/hwdb.d/* && \

View File

@ -35,11 +35,19 @@ RUN set -eux && \
libssl1.1 \
libcurl4 \
libldap-2.4 && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
apt-get -y purge curl gpg dirmngr gpg-agent && \
apt-get -y autoremove && \

View File

@ -43,11 +43,19 @@ RUN set -eux && \
openssl-libs \
pcre \
unixODBC && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
yum -y clean all && \
rm -rf /var/cache/yum /var/lib/yum/yumdb/* /usr/lib/udev/hwdb.d/* && \

View File

@ -53,11 +53,19 @@ RUN set -eux && \
mysql-client \
snmp-mibs-downloader \
unixodbc && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
apt-get -y purge curl gpg dirmngr gpg-agent && \
apt-get -y autoremove && \

View File

@ -42,11 +42,19 @@ RUN set -eux && \
openssl-libs \
pcre \
unixODBC && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
yum -y clean all && \
rm -rf /var/cache/yum /var/lib/yum/yumdb/* /usr/lib/udev/hwdb.d/* && \

View File

@ -51,11 +51,19 @@ RUN set -eux && \
libxml2 \
snmp-mibs-downloader \
unixodbc && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
apt-get -y purge curl gpg dirmngr gpg-agent && \
apt-get -y autoremove && \

View File

@ -47,11 +47,19 @@ RUN set -eux && \
openssl-libs \
pcre \
unixODBC && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
yum -y clean all && \
rm -rf /var/cache/yum /var/lib/yum/yumdb/* /usr/lib/udev/hwdb.d/* && \

View File

@ -57,11 +57,19 @@ RUN set -eux && \
mysql-client \
snmp-mibs-downloader \
unixodbc && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
apt-get -y purge curl gpg dirmngr gpg-agent && \
apt-get -y autoremove && \

View File

@ -196,7 +196,7 @@ check_db_connect_postgresql() {
export PGSSLKEY=${ZBX_DBTLSKEYFILE}
fi
while [ ! "$(psql "$ssl_opts" --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --quiet 2>/dev/null)" ]; do
while [ ! "$(pg_isready --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --dbname ${DB_SERVER_DBNAME} --quiet 2>/dev/null && echo $?)" ]; do
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
sleep $WAIT_TIMEOUT
done

View File

@ -48,11 +48,19 @@ RUN set -eux && \
postgresql \
postgresql-libs \
unixODBC && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
yum -y clean all && \
rm -rf /var/cache/yum /var/lib/yum/yumdb/* /usr/lib/udev/hwdb.d/* && \

View File

@ -196,7 +196,7 @@ check_db_connect_postgresql() {
export PGSSLKEY=${ZBX_DBTLSKEYFILE}
fi
while [ ! "$(psql --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --quiet 2>/dev/null)" ]; do
while [ ! "$(pg_isready --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --dbname ${DB_SERVER_DBNAME} --quiet 2>/dev/null && echo $?)" ]; do
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
sleep $WAIT_TIMEOUT
done
@ -305,12 +305,12 @@ create_db_schema_postgresql() {
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
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1
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
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1
fi
unset PGPASSWORD

View File

@ -57,11 +57,19 @@ RUN set -eux && \
postgresql-client \
snmp-mibs-downloader \
unixodbc && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini -o /sbin/tini && \
curl -L https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc -o /tini.asc && \
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /sbin/tini && \
rm -rf /root/.gnupg && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" -o /sbin/tini && \
curl -L "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc" -o /tmp/tini.asc && \
export GNUPGHOME="$(mktemp -d)" && \
for server in $(shuf -e ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
ipv4.pool.sks-keyservers.net \
keyserver.ubuntu.com \
keyserver.pgp.com \
pgp.mit.edu) ; do \
gpg --keyserver "$server" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
done && \
gpg --batch --verify /tmp/tini.asc /sbin/tini && \
rm -r "$GNUPGHOME" /tmp/tini.asc && \
chmod +x /sbin/tini && \
apt-get -y purge curl gpg dirmngr gpg-agent && \
apt-get -y autoremove && \

View File

@ -196,7 +196,7 @@ check_db_connect_postgresql() {
export PGSSLKEY=${ZBX_DBTLSKEYFILE}
fi
while [ ! "$(psql --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --list --quiet 2>/dev/null)" ]; do
while [ ! "$(pg_isready --host ${DB_SERVER_HOST} --port ${DB_SERVER_PORT} --username ${DB_SERVER_ROOT_USER} --dbname ${DB_SERVER_DBNAME} --quiet 2>/dev/null && echo $?)" ]; do
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
sleep $WAIT_TIMEOUT
done
@ -305,12 +305,12 @@ create_db_schema_postgresql() {
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
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1
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
--username ${DB_SERVER_ZBX_USER} --dbname ${DB_SERVER_DBNAME} 1>/dev/null || exit 1
fi
unset PGPASSWORD