diff --git a/plugin/bin/x-pack/certgen b/plugin/bin/x-pack/certgen index 44dd405713a..163a8c645ad 100644 --- a/plugin/bin/x-pack/certgen +++ b/plugin/bin/x-pack/certgen @@ -4,76 +4,15 @@ # 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" +source "`dirname "$0"`"/../elasticsearch-env -# 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` - -source "$ES_HOME/bin/elasticsearch.in.sh" - -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 - -if [ -z "$CONF_DIR" ]; then - # Try to read package config files - if [ -f "/etc/sysconfig/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/sysconfig/elasticsearch" - elif [ -f "/etc/default/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/default/elasticsearch" - fi -fi - -# include x-pack jars in classpath -ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*" - -# 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 +source "`dirname "$0"`"/x-pack-env declare -a args=("$@") - -if [ -e "$CONF_DIR" ]; then - args=("${args[@]}" --path.conf "$CONF_DIR") -fi +args=("${args[@]}" --path.conf "$CONF_DIR") cd "$ES_HOME" > /dev/null -"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" org.elasticsearch.xpack.ssl.CertificateTool "${args[@]}" +"$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.xpack.ssl.CertificateTool "${args[@]}" status=$? cd - > /dev/null exit $status diff --git a/plugin/bin/x-pack/croneval b/plugin/bin/x-pack/croneval index 3aac27dc75d..56629de521c 100755 --- a/plugin/bin/x-pack/croneval +++ b/plugin/bin/x-pack/croneval @@ -4,76 +4,12 @@ # 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" +source "`dirname "$0"`"/../elasticsearch-env -# 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` - -source "$ES_HOME/bin/elasticsearch.in.sh" - -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 - -if [ -z "$CONF_DIR" ]; then - # Try to read package config files - if [ -f "/etc/sysconfig/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/sysconfig/elasticsearch" - elif [ -f "/etc/default/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/default/elasticsearch" - fi -fi - -# include watcher jars in classpath -ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*" - -# 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 - -declare -a args=("$@") - -if [ -e "$CONF_DIR" ]; then - args=("${args[@]}" --path.conf "$CONF_DIR") -fi +source "`dirname "$0"`"/x-pack-env cd "$ES_HOME" > /dev/null -"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool "${args[@]}" +"$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool "$@" status=$? cd - > /dev/null exit $status diff --git a/plugin/bin/x-pack/extension b/plugin/bin/x-pack/extension index b2154191bbc..0bbfaf7afa0 100755 --- a/plugin/bin/x-pack/extension +++ b/plugin/bin/x-pack/extension @@ -4,66 +4,15 @@ # 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" +source "`dirname "$0"`"/../elasticsearch-env -# 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` - -source "$ES_HOME/bin/elasticsearch.in.sh" - -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 - -# Try to read package config files -if [ -f "/etc/sysconfig/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/sysconfig/elasticsearch" -elif [ -f "/etc/default/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/default/elasticsearch" -fi - -# include x-pack jars in classpath -ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*" +source "`dirname "$0"`"/x-pack-env declare -a args=("$@") - -if [ -e "$CONF_DIR" ]; then - args=("${args[@]}" --path.conf "$CONF_DIR") -fi +args=("${args[@]}" --path.conf "$CONF_DIR") cd "$ES_HOME" > /dev/null -"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" org.elasticsearch.xpack.extensions.XPackExtensionCli "${args[@]}" +"$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.xpack.extensions.XPackExtensionCli "${args[@]}" status=$? cd - > /dev/null exit $status diff --git a/plugin/bin/x-pack/migrate b/plugin/bin/x-pack/migrate index c559b9ab734..ded08408c8c 100755 --- a/plugin/bin/x-pack/migrate +++ b/plugin/bin/x-pack/migrate @@ -4,76 +4,15 @@ # 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" +source "`dirname "$0"`"/../elasticsearch-env -# 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` - -source "$ES_HOME/bin/elasticsearch.in.sh" - -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 - -if [ -z "$CONF_DIR" ]; then - # Try to read package config files - if [ -f "/etc/sysconfig/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/sysconfig/elasticsearch" - elif [ -f "/etc/default/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/default/elasticsearch" - fi -fi - -# include x-pack jars in classpath -ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*" - -# 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 +source "`dirname "$0"`"/x-pack-env declare -a args=("$@") - -if [ -e "$CONF_DIR" ]; then - args=("${args[@]}" --path.conf "$CONF_DIR") -fi +args=("${args[@]}" --path.conf "$CONF_DIR") cd "$ES_HOME" > /dev/null -"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool "${args[@]}" +"$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool "${args[@]}" status=$? cd - > /dev/null exit $status diff --git a/plugin/bin/x-pack/setup-passwords b/plugin/bin/x-pack/setup-passwords index 193ed9908a8..e9daa0813b6 100644 --- a/plugin/bin/x-pack/setup-passwords +++ b/plugin/bin/x-pack/setup-passwords @@ -4,76 +4,15 @@ # 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" +source "`dirname "$0"`"/../elasticsearch-env -# 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` - -source "$ES_HOME/bin/elasticsearch.in.sh" - -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 - -if [ -z "$CONF_DIR" ]; then - # Try to read package config files - if [ -f "/etc/sysconfig/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/sysconfig/elasticsearch" - elif [ -f "/etc/default/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/default/elasticsearch" - fi -fi - -# include x-pack jars in classpath -ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*" - -# 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 +source "`dirname "$0"`"/x-pack-env declare -a args=("$@") - -if [ -e "$CONF_DIR" ]; then - args=("${args[@]}" --path.conf "$CONF_DIR") -fi +args=("${args[@]}" --path.conf "$CONF_DIR") cd "$ES_HOME" > /dev/null -"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool "${args[@]}" +"$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool "${args[@]}" status=$? cd - > /dev/null exit $status diff --git a/plugin/bin/x-pack/syskeygen b/plugin/bin/x-pack/syskeygen index 85b1075d7ea..4f6661460d0 100755 --- a/plugin/bin/x-pack/syskeygen +++ b/plugin/bin/x-pack/syskeygen @@ -4,73 +4,12 @@ # 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" +source "`dirname "$0"`"/../elasticsearch-env -# 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` - -source "$ES_HOME/bin/elasticsearch.in.sh" - -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 - -if [ -z "$CONF_DIR" ]; then - # Try to read package config files - if [ -f "/etc/sysconfig/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/sysconfig/elasticsearch" - elif [ -f "/etc/default/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/default/elasticsearch" - fi -fi - -# include x-pack jars in classpath -ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*" - -# 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 +source "`dirname "$0"`"/x-pack-env declare -a args=("$@") - -if [ -e "$CONF_DIR" ]; then - args=("${args[@]}" --path.conf "$CONF_DIR") -fi +args=("${args[@]}" --path.conf "$CONF_DIR") cd "$ES_HOME" > /dev/null "$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.common.settings.EncKeyTool $properties "${args[@]}" diff --git a/plugin/bin/x-pack/users b/plugin/bin/x-pack/users index a6b4bc71251..2ff978feb12 100755 --- a/plugin/bin/x-pack/users +++ b/plugin/bin/x-pack/users @@ -4,76 +4,15 @@ # 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" +source "`dirname "$0"`"/../elasticsearch-env -# 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` - -source "$ES_HOME/bin/elasticsearch.in.sh" - -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 - -if [ -z "$CONF_DIR" ]; then - # Try to read package config files - if [ -f "/etc/sysconfig/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/sysconfig/elasticsearch" - elif [ -f "/etc/default/elasticsearch" ]; then - CONF_DIR=/etc/elasticsearch - - . "/etc/default/elasticsearch" - fi -fi - -# include x-pack jars in classpath -ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*" - -# 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 +source "`dirname "$0"`"/x-pack-env declare -a args=("$@") - -if [ -e "$CONF_DIR" ]; then - args=("${args[@]}" --path.conf "$CONF_DIR") -fi +args=("${args[@]}" --path.conf "$CONF_DIR") cd "$ES_HOME" > /dev/null -"$JAVA" $ES_JAVA_OPTS -cp "$ES_CLASSPATH" -Des.path.home="$ES_HOME" org.elasticsearch.xpack.security.authc.file.tool.UsersTool "${args[@]}" +"$JAVA" $ES_JAVA_OPTS -Des.path.home="$ES_HOME" -cp "$ES_CLASSPATH" org.elasticsearch.xpack.security.authc.file.tool.UsersTool "${args[@]}" status=$? cd - > /dev/null exit $status diff --git a/plugin/bin/x-pack/x-pack-env b/plugin/bin/x-pack/x-pack-env new file mode 100644 index 00000000000..db28c03d1fd --- /dev/null +++ b/plugin/bin/x-pack/x-pack-env @@ -0,0 +1,7 @@ +#!/bin/bash + +# 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. + +ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/plugins/x-pack/*"