Removed template. Fix _type. Fix if condition.

This commit is contained in:
Jesús Ángel
2019-05-14 15:04:20 +02:00
parent 5799998308
commit 6ff836e9fc

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Wazuh App Copyright (C) 2019 Wazuh Inc. (License GPLv2) # Wazuh Docker Copyright (C) 2019 Wazuh Inc. (License GPLv2)
set -e set -e
@@ -45,20 +45,15 @@ fi
#Insert default templates #Insert default templates
sed -i 's| "index.refresh_interval": "5s"| "index.refresh_interval": "5s", "number_of_shards" : '"${ALERTS_SHARDS}"', "number_of_replicas" : '"${ALERTS_REPLICAS}"'|' /usr/share/elasticsearch/config/wazuh-elastic6-template-alerts.json
cat /usr/share/elasticsearch/config/wazuh-elastic6-template-alerts.json | curl -XPUT "$el_url/_template/wazuh" ${auth} -H 'Content-Type: application/json' -d @-
sleep 5
API_PASS_Q=`echo "$API_PASS" | tr -d '"'` API_PASS_Q=`echo "$API_PASS" | tr -d '"'`
API_USER_Q=`echo "$API_USER" | tr -d '"'` API_USER_Q=`echo "$API_USER" | tr -d '"'`
API_PASSWORD=`echo -n $API_PASS_Q | base64` API_PASSWORD=`echo -n $API_PASS_Q | base64`
echo "Setting API credentials into Wazuh APP" echo "Setting API credentials into Wazuh APP"
CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/wazuh-configuration/1513629884013 ${auth}) CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/_doc/1513629884013 ${auth})
if [ "x$CONFIG_CODE" = "x404" ]; then
curl -s -XPOST $el_url/.wazuh/wazuh-configuration/1513629884013 ${auth} -H 'Content-Type: application/json' -d' if [ "x$CONFIG_CODE" != "x200" ]; then
curl -s -XPOST $el_url/.wazuh/_doc/1513629884013 ${auth} -H 'Content-Type: application/json' -d'
{ {
"api_user": "'"$API_USER_Q"'", "api_user": "'"$API_USER_Q"'",
"api_password": "'"$API_PASSWORD"'", "api_password": "'"$API_PASSWORD"'",