@@ -4,10 +4,39 @@ source $OPENSHIFT_CARTRIDGE_SDK_BASH
44
55PID_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+
736function _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
5988function 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+
67101case " $1 " in
68102 start) start ;;
69103 stop) stop ;;
70104 restart | reload ) restart $1 ;;
71105 status) status ;;
106+ deploy) deploy ;;
72107 * ) exit 0
73108esac
0 commit comments