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
+21 -5
View File
@@ -1,6 +1,11 @@
#!/bin/bash #!/bin/bash
# Wazuh Docker Copyright (C) 2019 Wazuh Inc. (License GPLv2) # 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" kibana_config_file="/usr/share/kibana/plugins/wazuh/wazuh.yml"
declare -A CONFIG_MAP=( declare -A CONFIG_MAP=(
@@ -39,11 +44,22 @@ do
fi fi
done done
# remove default API entry (starting with 3.11.0_7.5.1)
sed -ie '/- default:/,+4d' $kibana_config_file 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 cat << EOF >> $kibana_config_file
- default: - 1513629884013:
url: ${API_URL:-https://wazuh} url: $wazuh_url
port: ${API_PORT:-55000} port: $wazuh_port
user: ${API_USER:-foo} user: $api_user
password: ${API_PASS:-bar} password: $api_password
EOF EOF
else
echo "Wazuh APP already configured"
fi