cond. race for logstash and improve it for kibana

This commit is contained in:
AlfonsoRBJ
2019-03-21 16:29:48 +01:00
parent 6ce25e00c9
commit 3fdba44bfa
3 changed files with 28 additions and 4 deletions

View File

@@ -10,11 +10,13 @@ else
fi fi
until curl -XGET $el_url; do until curl -XGET $el_url; do
>&2 echo "Elastic is unavailable - sleeping" >&2 echo "Elastic is unavailable - sleeping."
sleep 5 sleep 5
done done
>&2 echo "Elastic is up - executing command" sleep 10
>&2 echo "Elasticsearch is up."
./wazuh_app_config.sh ./wazuh_app_config.sh

View File

@@ -9,4 +9,4 @@ USER root
COPY config/run.sh /run.sh COPY config/run.sh /run.sh
RUN chmod +x /run.sh RUN chmod +x /run.sh
ENTRYPOINT ["/run.sh"] ENTRYPOINT /entrypoint.sh

View File

@@ -1,24 +1,46 @@
#!/bin/bash -e #!/bin/bash
# Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2) # Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2)
# #
# OSSEC container bootstrap. See the README for information of the environment # OSSEC container bootstrap. See the README for information of the environment
# variables expected by this script. # variables expected by this script.
# #
set -e
##############################################################################
# Waiting for elasticsearch
##############################################################################
if [ "x${ELASTICSEARCH_URL}" = "x" ]; then
el_url="http://elasticsearch:9200"
else
el_url="${ELASTICSEARCH_URL}"
fi
until curl -XGET $el_url; do
>&2 echo "Elastic is unavailable - sleeping."
sleep 5
done
sleep 10
>&2 echo "Elasticsearch is up."
############################################################################## ##############################################################################
# Customize logstash output ip # Customize logstash output ip
############################################################################## ##############################################################################
if [ "$LOGSTASH_OUTPUT" != "" ]; then if [ "$LOGSTASH_OUTPUT" != "" ]; then
echo "Customize Logstash ouput ip."
sed -i "s/elasticsearch:9200/$LOGSTASH_OUTPUT:9200/" /usr/share/logstash/pipeline/01-wazuh.conf sed -i "s/elasticsearch:9200/$LOGSTASH_OUTPUT:9200/" /usr/share/logstash/pipeline/01-wazuh.conf
sed -i "s/elasticsearch:9200/$LOGSTASH_OUTPUT:9200/" /usr/share/logstash/config/logstash.yml sed -i "s/elasticsearch:9200/$LOGSTASH_OUTPUT:9200/" /usr/share/logstash/config/logstash.yml
fi fi
##############################################################################
# Map environment variables to entries in logstash.yml. # Map environment variables to entries in logstash.yml.
# Note that this will mutate logstash.yml in place if any such settings are found. # Note that this will mutate logstash.yml in place if any such settings are found.
# This may be undesirable, especially if logstash.yml is bind-mounted from the # This may be undesirable, especially if logstash.yml is bind-mounted from the
# host system. # host system.
##############################################################################
env2yaml /usr/share/logstash/config/logstash.yml env2yaml /usr/share/logstash/config/logstash.yml