Allow starting without Elasticsearch.
This commit is contained in:
parent
83438a63a4
commit
338ca514af
@ -3,6 +3,7 @@
|
||||
set -e
|
||||
|
||||
: "${AUTOWIZARD_JSON:=''}"
|
||||
: "${ELASTICSEARCH_ENABLED:=true}"
|
||||
: "${ELASTICSEARCH_HOST:=zammad-elasticsearch}"
|
||||
: "${ELASTICSEARCH_PORT:=9200}"
|
||||
: "${ELASTICSEARCH_SCHEMA:=http}"
|
||||
@ -74,32 +75,36 @@ if [ "$1" = 'zammad-init' ]; then
|
||||
else
|
||||
bundle exec rake db:migrate
|
||||
fi
|
||||
|
||||
|
||||
# es config
|
||||
echo "changing settings..."
|
||||
bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')"
|
||||
|
||||
bundle exec rails r "Setting.set('es_index', '${ELASTICSEARCH_NAMESPACE}')"
|
||||
|
||||
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_password', \"${ELASTICSEARCH_PASS}\")"
|
||||
fi
|
||||
|
||||
until (echo > /dev/tcp/${ELASTICSEARCH_HOST}/${ELASTICSEARCH_PORT}) &> /dev/null; do
|
||||
echo "zammad railsserver waiting for elasticsearch server to be ready..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ "${ELASTICSEARCH_SSL_VERIFY}" == "false" ]; then
|
||||
SSL_SKIP_VERIFY="-k"
|
||||
if [ "${ELASTICSEARCH_ENABLED}" == "false" ]; then
|
||||
bundle exec rails r "Setting.set('es_url', '')"
|
||||
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
|
||||
bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')"
|
||||
|
||||
bundle exec rails r "Setting.set('es_index', '${ELASTICSEARCH_NAMESPACE}')"
|
||||
|
||||
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_password', \"${ELASTICSEARCH_PASS}\")"
|
||||
fi
|
||||
|
||||
until (echo > /dev/tcp/${ELASTICSEARCH_HOST}/${ELASTICSEARCH_PORT}) &> /dev/null; do
|
||||
echo "zammad railsserver waiting for elasticsearch server to be ready..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
# chown everything to zammad user
|
||||
|
Loading…
Reference in New Issue
Block a user