Check for previous API settings on Wazuh Plugin

This commit is contained in:
Manuel Gutierrez
2019-12-27 15:48:49 +01:00
parent 7e8e11bfd6
commit 380ba92708

View File

@@ -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