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
This commit is contained in:
parent
ed29aaa96c
commit
cb8b631d5e
@ -5,6 +5,8 @@ set -e
|
|||||||
: "${AUTOWIZARD_JSON:=''}"
|
: "${AUTOWIZARD_JSON:=''}"
|
||||||
: "${ELASTICSEARCH_HOST:=zammad-elasticsearch}"
|
: "${ELASTICSEARCH_HOST:=zammad-elasticsearch}"
|
||||||
: "${ELASTICSEARCH_PORT:=9200}"
|
: "${ELASTICSEARCH_PORT:=9200}"
|
||||||
|
: "${ELASTICSEARCH_SCHEMA:=http}"
|
||||||
|
: "${ELASTICSEARCH_SSL_VERIFY:=true}"
|
||||||
: "${MEMCACHED_HOST:=zammad-memcached}"
|
: "${MEMCACHED_HOST:=zammad-memcached}"
|
||||||
: "${MEMCACHED_PORT:=11211}"
|
: "${MEMCACHED_PORT:=11211}"
|
||||||
: "${POSTGRESQL_HOST:=zammad-postgresql}"
|
: "${POSTGRESQL_HOST:=zammad-postgresql}"
|
||||||
@ -56,7 +58,7 @@ if [ "$1" = 'zammad-init' ]; then
|
|||||||
|
|
||||||
# check if database is populated
|
# check if database is populated
|
||||||
if [ "${DB_MIGRATE}" == "0" ]; then
|
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="$?"
|
DB_SETTINGS="$?"
|
||||||
fi
|
fi
|
||||||
set -e
|
set -e
|
||||||
@ -79,7 +81,7 @@ if [ "$1" = 'zammad-init' ]; then
|
|||||||
|
|
||||||
# es config
|
# es config
|
||||||
echo "changing settings..."
|
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
|
if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASS}" ]; then
|
||||||
bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")"
|
bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")"
|
||||||
@ -91,7 +93,12 @@ if [ "$1" = 'zammad-init' ]; then
|
|||||||
sleep 5
|
sleep 5
|
||||||
done
|
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..."
|
echo "rebuilding es searchindex..."
|
||||||
bundle exec rake searchindex:rebuild
|
bundle exec rake searchindex:rebuild
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user