Skip to content

Commit

Permalink
installation: plugins for Elasticsearch
Browse files Browse the repository at this point in the history
* BETTER Installs plugins for Elasticsearch.  (addresses #3672)

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
  • Loading branch information
jirikuncar committed Dec 7, 2016
1 parent 8c0b0e1 commit 6ece5e4
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 27 deletions.
34 changes: 13 additions & 21 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,26 @@
# as an Intergovernmental Organization or submit itself to any jurisdiction.


# TODO: Generate this manifest file by running the following commands:
#
# git init
# git add -A
# pip install -e .[all]
# check-manifest -u

# Check manifest will not automatically add these two files:
include .dockerignore
include .editorconfig
include .inveniorc
include Vagrantfile
include docker-compose.yml
include Dockerfile
include nginx/Dockerfile

include *.rst
include *.sh
include *.txt
include .dockerignore
include .editorconfig
include .inveniorc
include .lgtm
include ABOUT-NLS
include babel.ini
include docs/requirements.txt
include COPYING
include .lgtm
include Dockerfile
include LICENSE
include MAINTAINERS
include pytest.ini
include THANKS
include Vagrantfile
include babel.ini
include docker-compose.yml
include docs/requirements.txt
include elasticsearch/Dockerfile
include nginx/Dockerfile
include pytest.ini
recursive-include docs *.bat
recursive-include docs *.css
recursive-include docs *.gif
Expand All @@ -64,6 +56,6 @@ recursive-include docs *.svg
recursive-include docs Makefile
recursive-include misc *.py
recursive-include misc *.rst
recursive-include nginx *.conf
recursive-include scripts *.sh
recursive-include tests *.py
recursive-include nginx *.conf
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ redis:

elasticsearch:
restart: "always"
image: elasticsearch:2
build: .
dockerfile: ./elasticsearch/Dockerfile
ports:
- "29200:9200"
- "29300:9300"
Expand Down
7 changes: 7 additions & 0 deletions docs/installation/installation-detailed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ Let's see in detail what the Elasticsearch provisioning script does.
:end-before: # sphinxdoc-install-elasticsearch-centos7-end
:literal:

Some packages require extra plugins to be installed.

.. include:: ../../scripts/provision-elasticsearch.sh
:start-after: # sphinxdoc-install-elasticsearch-plugins-begin
:end-before: # sphinxdoc-install-elasticsearch-plugins-end
:literal:

Finally, let's clean after ourselves:

* on Ubuntu 14.04 LTS (Trusty Tahr):
Expand Down
29 changes: 29 additions & 0 deletions elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2016 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.

# Use Elasticsearch 2.
FROM elasticsearch:2
COPY scripts/provision-elasticsearch.sh /tmp/
# Install Elasticsarch plugins:
RUN /tmp/provision-elasticsearch.sh
35 changes: 30 additions & 5 deletions scripts/provision-elasticsearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@
# quit on errors:
set -o errexit

# check environment variables:
if [ -v ${INVENIO_ELASTICSEARCH_HOST} ]; then
echo "[ERROR] Please set environment variable INVENIO_ELASTICSEARCH_HOST before runnning this script."
echo "[ERROR] Example: export INVENIO_ELASTICSEARCH_HOST=192.168.50.12"
exit 1
# runs as root or needs sudo?
if [[ "$EUID" -ne 0 ]]; then
sudo='sudo'
else
sudo=''
fi

check_environment_variables () {
# check environment variables:
if [ -v ${INVENIO_ELASTICSEARCH_HOST} ]; then
echo "[ERROR] Please set environment variable INVENIO_ELASTICSEARCH_HOST before runnning this script."
echo "[ERROR] Example: export INVENIO_ELASTICSEARCH_HOST=192.168.50.12"
exit 1
fi
}

# quit on unbound symbols:
set -o nounset

Expand Down Expand Up @@ -118,6 +127,12 @@ enabled=1" | \

}

install_plugins () {
# sphinxdoc-install-elasticsearch-plugins-begin
$sudo /usr/share/elasticsearch/bin/plugin install -b mapper-attachments
# sphinxdoc-install-elasticsearch-plugins-end
}

cleanup_elasticsearch_ubuntu14 () {
# sphinxdoc-install-elasticsearch-cleanup-ubuntu14-begin
sudo apt-get -y autoremove && sudo apt-get -y clean
Expand All @@ -139,6 +154,10 @@ main () {
elif [ -e /etc/redhat-release ]; then
os_distribution=$(cut -d ' ' -f 1 /etc/redhat-release)
os_release=$(grep -oE '[0-9]+\.' /etc/redhat-release | cut -d. -f1 | head -1)
elif [ -f /.dockerinit -o -f /.dockerenv ]; then
# running inside Docker
os_distribution="Docker"
os_release=""
else
os_distribution="UNDETECTED"
os_release="UNDETECTED"
Expand All @@ -147,18 +166,24 @@ main () {
# call appropriate provisioning functions:
if [ "$os_distribution" = "Ubuntu" ]; then
if [ "$os_release" = "14" ]; then
check_environment_variables
provision_elasticsearch_ubuntu14
install_plugins
else
echo "[ERROR] Sorry, unsupported release ${os_release}."
exit 1
fi
elif [ "$os_distribution" = "CentOS" ]; then
if [ "$os_release" = "7" ]; then
check_environment_variables
provision_elasticsearch_centos7
install_plugins
else
echo "[ERROR] Sorry, unsupported release ${os_release}."
exit 1
fi
elif [ "$os_distribution" = "Docker" ]; then
install_plugins
else
echo "[ERROR] Sorry, unsupported distribution ${os_distribution}."
exit 1
Expand Down

0 comments on commit 6ece5e4

Please sign in to comment.