From 380ba92708c46becc92f3606bdc655373be8b1f7 Mon Sep 17 00:00:00 2001 From: Manuel Gutierrez Date: Fri, 27 Dec 2019 15:48:49 +0100 Subject: [PATCH] Check for previous API settings on Wazuh Plugin --- kibana/config/wazuh_app_config.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/kibana/config/wazuh_app_config.sh b/kibana/config/wazuh_app_config.sh index 78679eda..db060050 100644 --- a/kibana/config/wazuh_app_config.sh +++ b/kibana/config/wazuh_app_config.sh @@ -1,6 +1,11 @@ #!/bin/bash # Wazuh Docker Copyright (C) 2019 Wazuh Inc. (License GPLv2) +wazuh_url="${WAZUH_API_URL:-https://wazuh}" +wazuh_port="${API_PORT:-55000}" +api_user="${API_USER:-foo}" +api_password="${API_PASS:-bar}" + kibana_config_file="/usr/share/kibana/plugins/wazuh/wazuh.yml" declare -A CONFIG_MAP=( @@ -39,11 +44,22 @@ do fi done +# remove default API entry (starting with 3.11.0_7.5.1) sed -ie '/- default:/,+4d' $kibana_config_file + +CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/_doc/1513629884013 ${auth}) + +grep -q 1513629884013 $kibana_config_file +_config_exists=$? + +if [[ "x$CONFIG_CODE" != "x200" && $_config_exists -ne 0 ]]; then cat << EOF >> $kibana_config_file - - default: - url: ${API_URL:-https://wazuh} - port: ${API_PORT:-55000} - user: ${API_USER:-foo} - password: ${API_PASS:-bar} + - 1513629884013: + url: $wazuh_url + port: $wazuh_port + user: $api_user + password: $api_password EOF +else + echo "Wazuh APP already configured" +fi