#!/usr/bin/with-contenv bash # Wazuh App Copyright (C) 2021 Wazuh Inc. (License GPLv2) set -e if [ "$ELASTICSEARCH_URL" != "" ]; then >&2 echo "Customize Elasticsearch ouput IP" sed -i "s|hosts:.*|hosts: ['$ELASTICSEARCH_URL']|g" /etc/filebeat/filebeat.yml fi # Configure filebeat.yml security settings if [ "$ELASTIC_USERNAME" != "" ]; then >&2 echo "Configuring username." sed -i "s|#username:.*|username: '$ELASTIC_USERNAME'|g" /etc/filebeat/filebeat.yml fi if [ "$ELASTIC_PASSWORD" != "" ]; then >&2 echo "Configuring password." sed -i "s|#password:.*|password: '$ELASTIC_PASSWORD'|g" /etc/filebeat/filebeat.yml fi if [ "$FILEBEAT_SSL_VERIFICATION_MODE" != "" ]; then >&2 echo "Configuring SSL verification mode." sed -i "s|#ssl.verification_mode:.*|ssl.verification_mode: $FILEBEAT_SSL_VERIFICATION_MODE|g" /etc/filebeat/filebeat.yml fi if [ "$SSL_CERTIFICATE_AUTHORITIES" != "" ]; then >&2 echo "Configuring Certificate Authorities." sed -i "s|#ssl.certificate_authorities:.*|ssl.certificate_authorities: ['$SSL_CERTIFICATE_AUTHORITIES']|g" /etc/filebeat/filebeat.yml fi if [ "$SSL_CERTIFICATE" != "" ]; then >&2 echo "Configuring SSL Certificate." sed -i "s|#ssl.certificate:.*|ssl.certificate: '$SSL_CERTIFICATE'|g" /etc/filebeat/filebeat.yml fi if [ "$SSL_KEY" != "" ]; then >&2 echo "Configuring SSL Key." sed -i "s|#ssl.key:.*|ssl.key: '$SSL_KEY'|g" /etc/filebeat/filebeat.yml fi chmod go-w /etc/filebeat/filebeat.yml || true chown root: /etc/filebeat/filebeat.yml || true