Skip to content
This repository was archived by the owner on Nov 15, 2018. It is now read-only.

Commit b1f392c

Browse files
committed
Merge pull request #3 from caruccio/plugin-installer
Automatic plugin install
2 parents 5174f63 + 9bda92e commit b1f392c

File tree

4 files changed

+94
-7
lines changed

4 files changed

+94
-7
lines changed

bin/control

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,39 @@ source $OPENSHIFT_CARTRIDGE_SDK_BASH
44

55
PID_FILE=$OPENSHIFT_ELASTICSEARCH_DIR/run/elasticsearch.pid
66

7+
function _install_plugins()
8+
{
9+
local PLUGIN_CMD="$OPENSHIFT_ELASTICSEARCH_DIR/usr/bin/plugin -Des.path.plugins=$OPENSHIFT_DATA_DIR/elasticsearch-plugins"
10+
11+
local old_plugins=$($PLUGIN_CMD --list | awk '/-/{print $2}' | xargs)
12+
if [ -n "$old_plugins" -a "$old_plugins" != "No" ]; then #ARGH!
13+
echo "Removing old ElasticSearch plugins..."
14+
for plugin in $old_plugins; do
15+
$PLUGIN_CMD --remove $plugin
16+
done
17+
fi
18+
19+
echo "Installing ElasticSearch plugins..."
20+
21+
local plugins="$(grep -v '^#' $OPENSHIFT_REPO_DIR/plugins.txt 2>/dev/null | xargs)"
22+
23+
if [ "${plugins}" ]; then
24+
for plugin in ${plugins}; do
25+
local name=$(echo $plugin | cut -f 1 -d =)
26+
local url=$(echo $plugin | cut -f 2 -d =)
27+
if [ "$name" == "$url" ]; then
28+
$PLUGIN_CMD --install $name
29+
else
30+
$PLUGIN_CMD --url $url --install $name
31+
fi
32+
done
33+
fi
34+
}
35+
736
function _is_running() {
837
if [ -f $PID_FILE ]; then
9-
zpid=$(cat $PID_FILE 2> /dev/null)
10-
myid=$(id -u)
38+
local zpid=$(cat $PID_FILE 2> /dev/null)
39+
local myid=$(id -u)
1140
if `ps -opid,args --pid $zpid 2>&1 &> /dev/null`; then
1241
return 0
1342
fi
@@ -34,14 +63,14 @@ function stop() {
3463
fi
3564

3665
if [ -f $PID_FILE ]; then
37-
zpid=$(cat $PID_FILE 2> /dev/null)
66+
local zpid=$(cat $PID_FILE 2> /dev/null)
3867
fi
3968

4069
if [ -n $zpid ]; then
4170
/bin/kill $zpid
42-
ret=$?
71+
local ret=$?
4372
if [ $ret -eq 0 ]; then
44-
TIMEOUT=10
73+
local TIMEOUT=10
4574
while [ $TIMEOUT -gt 0 ] && _is_running ; do
4675
/bin/kill -0 "$zpid" > /dev/null 2>&1 || break
4776
sleep 1
@@ -57,17 +86,23 @@ function restart() {
5786
}
5887

5988
function status() {
89+
local output=""
6090
if output=$(curl http://$OPENSHIFT_RUBY_IP:$OPENSHIFT_RUBY_PORT/ &> /dev/null); then
6191
client_result "Application is running"
6292
else
6393
client_result "Application is either stopped or inaccessible"
6494
fi
6595
}
6696

97+
function deploy() {
98+
_install_plugins
99+
}
100+
67101
case "$1" in
68102
start) start ;;
69103
stop) stop ;;
70104
restart | reload ) restart $1 ;;
71105
status) status ;;
106+
deploy) deploy ;;
72107
*) exit 0
73108
esac

bin/install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash -e
22

3-
mkdir -p $OPENSHIFT_ELASTICSEARCH_DIR/run $OPENSHIFT_DATA_DIR/elasticsearch
3+
mkdir -p $OPENSHIFT_ELASTICSEARCH_DIR/run $OPENSHIFT_DATA_DIR/{elasticsearch,elasticsearch-plugins}
44

55
touch $OPENSHIFT_ELASTICSEARCH_DIR/env/OPENSHIFT_ELASTICSEARCH_CLUSTER

conf/elasticsearch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ path.logs: ${OPENSHIFT_ELASTICSEARCH_DIR}/logs
162162

163163
# Path to where plugins are installed:
164164
#
165-
# path.plugins: /path/to/plugins
165+
path.plugins: ${OPENSHIFT_DATA_DIR}/elasticsearch-plugins
166166

167167

168168
#################################### Plugin ###################################

template/plugins.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
##
2+
## ElasticSearch plugins to install, one per line.
3+
## Edit this file, commit and push. All plugins will be
4+
## installed inside all gears.
5+
##
6+
## To use a specific URL to download plugin code from, use:
7+
## [PLUGIN_NAME]=[URL]
8+
## Ex:
9+
## myplugin=https://mysite.com/elasticsearch/my-awesome-plugin.zip
10+
##
11+
12+
## Description:
13+
## ElasticSearch-head is a web front end for browsing and
14+
## interacting with an Elastic Search cluster.
15+
##
16+
## URL:
17+
## http://mobz.github.io/elasticsearch-head
18+
19+
## Uncomment line below to install this plugin
20+
#mobz/elasticsearch-head
21+
22+
## Description:
23+
## Paramedic is a simple yet sexy tool to monitor and inspect
24+
## ElasticSearch clusters. It displays real-time statistics and
25+
## information about your nodes and indices, as well as shard
26+
## allocation within the cluster.
27+
##
28+
## URL:
29+
## https://github.com/karmi/elasticsearch-paramedic
30+
31+
## Uncomment line below to install this plugin
32+
#karmi/elasticsearch-paramedic
33+
34+
## Description:
35+
## Site plugin for Elasticsearch to help understand and debug queries.
36+
##
37+
## URL:
38+
## https://github.com/polyfractal/elasticsearch-inquisitor
39+
40+
## Uncomment line below to install this plugin
41+
#polyfractal/elasticsearch-inquisitor
42+
43+
## Description:
44+
## SegmentSpy is a tool to watch the segments in your indices.
45+
## Segment graphs update in real-time, allowing you to watch as
46+
## ElasticSearch (Lucene) merges your segments
47+
##
48+
## URL:
49+
## https://github.com/polyfractal/elasticsearch-segmentspy
50+
51+
## Uncomment line below to install this plugin
52+
#polyfractal/elasticsearch-segmentspy

0 commit comments

Comments
 (0)