#!/bin/sh

<% target = (dockerfile.split("/").last.split("-").last) %>
<% if target == "elasticsearch" %>

set -e

if [ -z ${FLUENT_ELASTICSEARCH_USER} ] ; then
   sed -i  '/FLUENT_ELASTICSEARCH_USER/d' /fluentd/etc/${FLUENTD_CONF}
fi

if [ -z ${FLUENT_ELASTICSEARCH_PASSWORD} ] ; then
   sed -i  '/FLUENT_ELASTICSEARCH_PASSWORD/d' /fluentd/etc/${FLUENTD_CONF}
fi
<% end %>

exec fluentd -c /fluentd/etc/${FLUENTD_CONF} -p /fluentd/plugins --gemfile /fluentd/Gemfile ${FLUENTD_OPT}

#!/bin/sh

<% target = (dockerfile.split("/").last.split("-").last) %>
<% if target == "elasticsearch" %>

set -e

if [ -z ${FLUENT_ELASTICSEARCH_SED_DISABLE} ] ; then
  if [ -z ${FLUENT_ELASTICSEARCH_USER} ] ; then
    sed -i  '/FLUENT_ELASTICSEARCH_USER/d' /fluentd/etc/${FLUENTD_CONF}
  fi

  if [ -z ${FLUENT_ELASTICSEARCH_PASSWORD} ] ; then
    sed -i  '/FLUENT_ELASTICSEARCH_PASSWORD/d' /fluentd/etc/${FLUENTD_CONF}
  fi
fi
<% end %>

exec fluentd -c /fluentd/etc/${FLUENTD_CONF} -p /fluentd/plugins --gemfile /fluentd/Gemfile ${FLUENTD_OPT}

Add FLUENT_ELASTICSEARCH_SED_DISABLE envvar to disable sed execution
Add FLUENT_ELASTICSEARCH_SED_DISABLE envvar to disable sed execution

Signed-off-by: Masahiro Nakagawa <0f51a8c574c157b13d3ee3d2579e24fcb2f5df0d@gmail.com>
