mirror of
				https://github.com/wazuh/wazuh-docker.git
				synced 2025-11-04 05:53:19 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			91 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
#!/bin/bash
 | 
						|
# Wazuh Docker Copyright (C) 2019 Wazuh Inc. (License GPLv2)
 | 
						|
 | 
						|
set -e
 | 
						|
 | 
						|
el_url=${ELASTICSEARCH_URL}
 | 
						|
 | 
						|
if [ "x${WAZUH_API_URL}" = "x" ]; then
 | 
						|
  wazuh_url="https://wazuh"
 | 
						|
else
 | 
						|
  wazuh_url="${WAZUH_API_URL}"
 | 
						|
fi
 | 
						|
 | 
						|
 | 
						|
until curl -XGET $el_url; do
 | 
						|
  >&2 echo "Elastic is unavailable - sleeping"
 | 
						|
  sleep 5
 | 
						|
done
 | 
						|
 | 
						|
>&2 echo "Elastic is up - executing command"
 | 
						|
 | 
						|
if [ $ENABLE_CONFIGURE_S3 ]; then
 | 
						|
  #Wait for Elasticsearch to be ready to create the repository
 | 
						|
  sleep 10
 | 
						|
  IP_PORT="${ELASTICSEARCH_IP}:${ELASTICSEARCH_PORT}"
 | 
						|
 | 
						|
  if [ "x$S3_PATH" != "x" ]; then 
 | 
						|
 | 
						|
    if [ "x$S3_ELASTIC_MAJOR" != "x" ]; then 
 | 
						|
      ./config/configure_s3.sh $IP_PORT $S3_BUCKET_NAME $S3_PATH $S3_REPOSITORY_NAME $S3_ELASTIC_MAJOR 
 | 
						|
 | 
						|
    else
 | 
						|
      ./config/configure_s3.sh $IP_PORT $S3_BUCKET_NAME $S3_PATH $S3_REPOSITORY_NAME 
 | 
						|
 | 
						|
    fi
 | 
						|
 | 
						|
  fi
 | 
						|
 | 
						|
fi
 | 
						|
 | 
						|
#Insert default templates
 | 
						|
 | 
						|
API_PASS_Q=`echo "$API_PASS" | tr -d '"'`
 | 
						|
API_USER_Q=`echo "$API_USER" | tr -d '"'`
 | 
						|
API_PASSWORD=`echo -n $API_PASS_Q | base64`
 | 
						|
 | 
						|
echo "Setting API credentials into Wazuh APP"
 | 
						|
CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/_doc/1513629884013)
 | 
						|
 | 
						|
if [ "x$CONFIG_CODE" != "x200" ]; then
 | 
						|
  curl -s -XPOST $el_url/.wazuh/_doc/1513629884013 -H 'Content-Type: application/json' -d'
 | 
						|
  {
 | 
						|
    "api_user": "'"$API_USER_Q"'",
 | 
						|
    "api_password": "'"$API_PASSWORD"'",
 | 
						|
    "url": "'"$wazuh_url"'",
 | 
						|
    "api_port": "55000",
 | 
						|
    "insecure": "true",
 | 
						|
    "component": "API",
 | 
						|
    "cluster_info": {
 | 
						|
      "manager": "wazuh-manager",
 | 
						|
      "cluster": "Disabled",
 | 
						|
      "status": "disabled"
 | 
						|
    },
 | 
						|
    "extensions": {
 | 
						|
      "oscap": true,
 | 
						|
      "audit": true,
 | 
						|
      "pci": true,
 | 
						|
      "aws": true,
 | 
						|
      "virustotal": true,
 | 
						|
      "gdpr": true,
 | 
						|
      "ciscat": true
 | 
						|
    }
 | 
						|
  }
 | 
						|
  ' > /dev/null
 | 
						|
else
 | 
						|
  echo "Wazuh APP already configured"
 | 
						|
fi
 | 
						|
sleep 5
 | 
						|
 | 
						|
# Set cluster delayed timeout when node falls
 | 
						|
curl -X PUT "$el_url/_all/_settings" -H 'Content-Type: application/json' -d'
 | 
						|
{
 | 
						|
  "settings": {
 | 
						|
    "index.unassigned.node_left.delayed_timeout": "'"$CLUSTER_DELAYED_TIMEOUT"'"
 | 
						|
  }
 | 
						|
}
 | 
						|
'
 | 
						|
 | 
						|
 | 
						|
echo "Elasticsearch is ready."
 |