From cb8b631d5e2c061572526935682177af40c98bb7 Mon Sep 17 00:00:00 2001 From: Daniel Lohse Date: Thu, 4 Jul 2019 12:18:14 +0200 Subject: [PATCH] Allow setting Elasticsearch connection URL protocol (#105) * Honor ELASTICSEARCH_SCHEMA when accessing Elasticsearch in the Zammad entrypoint It defaults to http so it's completely backwards-compatible. In case it's https I disabled verification in the curl command via -k. * Add ELASTICSEARCH_SSL_VERIFY environment variable in Zammad entrypoint Setting it to "false" will skip TLS verification when interacting with Elasticsearch. * Add default value for ELASTICSEARCH_SSL_VERIFY env variable --- containers/zammad/docker-entrypoint.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/containers/zammad/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh index 9610541..fe847e5 100755 --- a/containers/zammad/docker-entrypoint.sh +++ b/containers/zammad/docker-entrypoint.sh @@ -5,6 +5,8 @@ set -e : "${AUTOWIZARD_JSON:=''}" : "${ELASTICSEARCH_HOST:=zammad-elasticsearch}" : "${ELASTICSEARCH_PORT:=9200}" +: "${ELASTICSEARCH_SCHEMA:=http}" +: "${ELASTICSEARCH_SSL_VERIFY:=true}" : "${MEMCACHED_HOST:=zammad-memcached}" : "${MEMCACHED_PORT:=11211}" : "${POSTGRESQL_HOST:=zammad-postgresql}" @@ -56,7 +58,7 @@ if [ "$1" = 'zammad-init' ]; then # check if database is populated if [ "${DB_MIGRATE}" == "0" ]; then - bundle exec rails r "Setting.set('es_url', 'http://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" &> /dev/null + bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" &> /dev/null DB_SETTINGS="$?" fi set -e @@ -79,7 +81,7 @@ if [ "$1" = 'zammad-init' ]; then # es config echo "changing settings..." - bundle exec rails r "Setting.set('es_url', 'http://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" + bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASS}" ]; then bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")" @@ -91,7 +93,12 @@ if [ "$1" = 'zammad-init' ]; then sleep 5 done - if ! curl -s ${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices | grep -q zammad; then + if [ "${ELASTICSEARCH_SSL_VERIFY}" == "false" ]; then + SSL_SKIP_VERIFY="-k" + else + SSL_SKIP_VERIFY="" + fi + if ! curl -s ${SSL_SKIP_VERIFY} ${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices | grep -q zammad; then echo "rebuilding es searchindex..." bundle exec rake searchindex:rebuild fi