2016-05-10 15:07:04 -04:00
|
|
|
#!/bin/bash
|
2015-07-13 06:31:34 -04:00
|
|
|
|
|
|
|
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
# or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
# you may not use this file except in compliance with the Elastic License.
|
|
|
|
|
|
|
|
SCRIPT="$0"
|
|
|
|
|
|
|
|
# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path.
|
|
|
|
while [ -h "$SCRIPT" ] ; do
|
|
|
|
ls=`ls -ld "$SCRIPT"`
|
|
|
|
# Drop everything prior to ->
|
|
|
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
|
|
if expr "$link" : '/.*' > /dev/null; then
|
|
|
|
SCRIPT="$link"
|
|
|
|
else
|
|
|
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# determine elasticsearch home
|
|
|
|
ES_HOME=`dirname "$SCRIPT"`/../..
|
|
|
|
|
|
|
|
# make ELASTICSEARCH_HOME absolute
|
|
|
|
ES_HOME=`cd "$ES_HOME"; pwd`
|
|
|
|
|
2017-07-20 02:41:59 -04:00
|
|
|
source "$ES_HOME/bin/elasticsearch.in.sh"
|
2015-07-13 06:31:34 -04:00
|
|
|
|
|
|
|
if [ -x "$JAVA_HOME/bin/java" ]; then
|
|
|
|
JAVA="$JAVA_HOME/bin/java"
|
|
|
|
else
|
|
|
|
JAVA=`which java`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -x "$JAVA" ]; then
|
|
|
|
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$ES_CLASSPATH" ]; then
|
|
|
|
echo "You must set the ES_CLASSPATH var" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-07-07 07:41:48 -04:00
|
|
|
if [ -z "$CONF_DIR" ]; then
|
|
|
|
# Try to read package config files
|
|
|
|
if [ -f "/etc/sysconfig/elasticsearch" ]; then
|
|
|
|
CONF_DIR=/etc/elasticsearch
|
2015-07-13 06:31:34 -04:00
|
|
|
|
2016-07-07 07:41:48 -04:00
|
|
|
. "/etc/sysconfig/elasticsearch"
|
|
|
|
elif [ -f "/etc/default/elasticsearch" ]; then
|
|
|
|
CONF_DIR=/etc/elasticsearch
|
2015-07-13 06:31:34 -04:00
|
|
|
|
2016-07-07 07:41:48 -04:00
|
|
|
. "/etc/default/elasticsearch"
|
|
|
|
fi
|
2015-07-13 06:31:34 -04:00
|
|
|
fi
|
|
|
|
|
2016-06-17 11:53:55 -04:00
|
|
|
# include x-pack jars in classpath
|
2016-03-30 03:07:57 -04:00
|
|
|
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*"
|
2015-07-13 06:31:34 -04:00
|
|
|
|
2015-09-25 23:55:54 -04:00
|
|
|
# don't let JAVA_TOOL_OPTIONS slip in (e.g. crazy agents in ubuntu)
|
|
|
|
# works around https://bugs.launchpad.net/ubuntu/+source/jayatana/+bug/1441487
|
|
|
|
if [ "x$JAVA_TOOL_OPTIONS" != "x" ]; then
|
|
|
|
echo "Warning: Ignoring JAVA_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS"
|
|
|
|
echo "Please pass JVM parameters via ES_JAVA_OPTS instead"
|
|
|
|
unset JAVA_TOOL_OPTIONS
|
|
|
|
fi
|
|
|
|
|
2016-05-19 14:09:49 -04:00
|
|
|
declare -a args=("$@")
|
|
|
|
|
|
|
|
if [ -e "$CONF_DIR" ]; then
|
2017-06-26 15:18:49 -04:00
|
|
|
args=("${args[@]}" --path.conf "$CONF_DIR")
|
2016-05-19 14:09:49 -04:00
|
|
|
fi
|
|
|
|
|
2015-09-11 11:15:19 -04:00
|
|
|
cd "$ES_HOME" > /dev/null
|
2017-06-29 16:58:35 -04:00
|
|
|
"$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.common.settings.EncKeyTool $properties "${args[@]}"
|
2015-07-13 06:31:34 -04:00
|
|
|
status=$?
|
|
|
|
cd - > /dev/null
|
|
|
|
exit $status
|