Fix using relative custom config path
Previously a user could set a custom config path to a relative directory using ES_PATH_CONF. In a previous change related to enabling GC logging by default, we forced the working directory for Elasticsearch to be ES_HOME. This had the impact of causing all relative paths to be relative to ES_HOME, against the intent of the user. This commit addresses this by making ES_PATH_CONF absolute before we switch the working directory to ES_HOME. Relates #28700
This commit is contained in:
parent
d58226be8f
commit
1fa701c18d
|
@ -74,6 +74,9 @@ if [ -z "$ES_PATH_CONF" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# now make ES_PATH_CONF absolute
|
||||||
|
ES_PATH_CONF=`cd "$ES_PATH_CONF"; pwd`
|
||||||
|
|
||||||
if [ -z "$ES_TMPDIR" ]; then
|
if [ -z "$ES_TMPDIR" ]; then
|
||||||
set +e
|
set +e
|
||||||
mktemp --version 2>&1 | grep coreutils > /dev/null
|
mktemp --version 2>&1 | grep coreutils > /dev/null
|
||||||
|
|
|
@ -50,6 +50,9 @@ if not defined ES_PATH_CONF (
|
||||||
set ES_PATH_CONF=!ES_HOME!\config
|
set ES_PATH_CONF=!ES_HOME!\config
|
||||||
)
|
)
|
||||||
|
|
||||||
|
rem now make ES_PATH_CONF absolute
|
||||||
|
for %%I in ("%ES_PATH_CONF%..") do set ES_PATH_CONF=%%~dpfI
|
||||||
|
|
||||||
if not defined ES_TMPDIR (
|
if not defined ES_TMPDIR (
|
||||||
set ES_TMPDIR=!TMP!\elasticsearch
|
set ES_TMPDIR=!TMP!\elasticsearch
|
||||||
)
|
)
|
||||||
|
|
|
@ -139,6 +139,23 @@ setup() {
|
||||||
stop_elasticsearch_service
|
stop_elasticsearch_service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "[TAR] relative ES_PATH_CONF" {
|
||||||
|
local es_path_conf=$ES_PATH_CONF
|
||||||
|
local temp=`mktemp -d`
|
||||||
|
mkdir "$temp"/config
|
||||||
|
cp "$ESCONFIG"/elasticsearch.yml "$temp"/config
|
||||||
|
cp "$ESCONFIG"/log4j2.properties "$temp"/config
|
||||||
|
cp "$ESCONFIG/jvm.options" "$temp/config"
|
||||||
|
chown -R elasticsearch:elasticsearch "$temp"
|
||||||
|
echo "node.name: relative" >> "$temp"/config/elasticsearch.yml
|
||||||
|
cd "$temp"
|
||||||
|
export ES_PATH_CONF=config
|
||||||
|
start_elasticsearch_service
|
||||||
|
curl -s -XGET localhost:9200/_nodes | fgrep '"name":"relative"'
|
||||||
|
stop_elasticsearch_service
|
||||||
|
export ES_PATH_CONF=$es_path_conf
|
||||||
|
}
|
||||||
|
|
||||||
@test "[TAR] remove tar" {
|
@test "[TAR] remove tar" {
|
||||||
rm -rf "/tmp/elasticsearch"
|
rm -rf "/tmp/elasticsearch"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue