From 4a610346ccee0dab0067c40bfdaf22d79da5649b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Tue, 31 Jul 2018 10:06:20 +0200 Subject: [PATCH] some additions for external elasticsearch servers --- contrib/packager.io/functions | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/contrib/packager.io/functions b/contrib/packager.io/functions index 56ac2bfb2..1000c5b64 100644 --- a/contrib/packager.io/functions +++ b/contrib/packager.io/functions @@ -230,11 +230,15 @@ function setup_elasticsearch () { ES_CONNECTION="$(zammad run rails r "puts Setting.get('es_url')" 2>> /dev/null)" + if [ -z "${ES_CONNECTION}" ]; then + ES_CONNECTION="http://127.0.0.1:9200" + fi + if [ -n "$(/usr/share/elasticsearch/bin/elasticsearch-plugin list | grep mapper-attachments)" ]; then REBUILD_ES_SEARCHINDEX="yes" echo "# Deleting old zammad_production elasticsearch index..." - curl -XDELETE "${ES_CONNECTION:-http://127.0.0.1:9200}/zammad_production" + curl -XDELETE "${ES_CONNECTION}/zammad_production" yes | /usr/share/elasticsearch/bin/elasticsearch-plugin -s remove mapper-attachments @@ -244,15 +248,24 @@ function setup_elasticsearch () { yes | /usr/share/elasticsearch/bin/elasticsearch-plugin -s install ingest-attachment - ${INIT_CMD} restart elasticsearch + if [ "{ES_CONNECTION}" == "http://127.0.0.1:9200" ]; then + ${INIT_CMD} restart elasticsearch + else + echo -e "\n It seems you're running an external Elasticsearch server on ${ES_CONNECTION}" + echo -e "Stopping local elasticsearch server..." + ${INIT_CMD} stop elasticsearch + echo -e "\n Please get sure to install the 'ingest-attachment' plugin on your Elasticsearch server by:" + echo -e "/usr/share/elasticsearch/bin/elasticsearch-plugin -s install ingest-attachment" + echo -e "\nAfter this you might need to rebuild the searchindex by:" + echo -e "zammad run rake searchindex:rebuild" + fi } function elasticsearch_searchindex_rebuild () { - zammad run rails r "Setting.set('es_url', \"${ES_CONNECTION:-http://127.0.0.1:9200}\")" + zammad run rails r "Setting.set('es_url', \"${ES_CONNECTION}\")" if [ "${REBUILD_ES_SEARCHINDEX}" == "yes" ]; then echo "# (Re)building Elasticsearch searchindex..." - nohup zammad run rake searchindex:rebuild &> ${ZAMMAD_DIR}/log/searchindex-rebuild.log & fi }