Skip to content

Commit

Permalink
Use rake script for elasticsearch index deletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
martini committed Aug 10, 2018
1 parent 72792fa commit 101d7d9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions contrib/packager.io/functions
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,11 @@ function setup_elasticsearch () {
ES_CONNECTION="http://127.0.0.1:9200"
fi

ES_INDEX="$(zammad run rails r "puts Setting.get('es_index')" 2>> /dev/null)"

if [ -z "${ES_INDEX}" ]; then
ES_INDEX="zammad_production"
fi

if [ -n "$(/usr/share/elasticsearch/bin/elasticsearch-plugin list | grep mapper-attachments)" ]; then
REBUILD_ES_SEARCHINDEX="yes"

echo "# Deleting old ${ES_INDEX} elasticsearch index..."
curl -XDELETE "${ES_CONNECTION}/${ES_INDEX}"
echo "# Deleting old elasticsearch index..."
zammad run rake searchindex:drop

yes | /usr/share/elasticsearch/bin/elasticsearch-plugin -s remove mapper-attachments

Expand All @@ -254,7 +248,7 @@ function setup_elasticsearch () {

yes | /usr/share/elasticsearch/bin/elasticsearch-plugin -s install ingest-attachment

if [ "{ES_CONNECTION}" == "http://127.0.0.1:9200" ]; then
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}"
Expand All @@ -277,7 +271,6 @@ function elasticsearch_searchindex_rebuild () {
}

function update_or_install () {
setup_elasticsearch

if [ -f ${ZAMMAD_DIR}/config/database.yml ]; then
update_database
Expand All @@ -300,6 +293,8 @@ function update_or_install () {
initialise_database
fi

setup_elasticsearch

elasticsearch_searchindex_rebuild
}

Expand Down

0 comments on commit 101d7d9

Please sign in to comment.