From 8af39e3a568920ab3bfa0c2cf956ddfdb9720363 Mon Sep 17 00:00:00 2001 From: Manuel Gutierrez <1380243+xr09@users.noreply.github.com> Date: Thu, 20 Aug 2020 19:01:30 +0200 Subject: [PATCH] Export variables to share with sub-shell --- kibana-opendistro/config/entrypoint.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/kibana-opendistro/config/entrypoint.sh b/kibana-opendistro/config/entrypoint.sh index 79039afc..cca7c3da 100644 --- a/kibana-opendistro/config/entrypoint.sh +++ b/kibana-opendistro/config/entrypoint.sh @@ -7,13 +7,23 @@ set -e # Waiting for elasticsearch ############################################################################## -if [ "x${ELASTICSEARCH_URL}" = "x" ]; then - el_url="http://elasticsearch:9200" +if [ "x${ELASTICSEARCH_URL}" == "x" ]; then + if [[ ${ENABLED_SECURITY} == "false" ]]; then + export el_url="http://elasticsearch:9200" + else + export el_url="https://elasticsearch:9200" + fi else - el_url="${ELASTICSEARCH_URL}" + export el_url="${ELASTICSEARCH_URL}" fi -auth="" +if [[ ${ENABLED_SECURITY} == "false" || "x${ELASTICSEARCH_USERNAME}" == "x" || "x${ELASTICSEARCH_PASSWORD}" == "x" ]]; then + auth="" + # remove security plugin from kibana if elasticsearch is not using it either + /usr/share/kibana/bin/kibana-plugin remove opendistro_security +else + export auth="--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} -k" +fi until curl -XGET $el_url ${auth}; do >&2 echo "Elastic is unavailable - sleeping" @@ -33,7 +43,7 @@ strlen=0 while [[ $strlen -eq 0 ]] do - template=$(curl $el_url/_cat/templates/wazuh -s) + template=$(curl ${auth} $el_url/_cat/templates/wazuh -s) strlen=${#template} >&2 echo "Wazuh alerts template not loaded - sleeping." sleep 2