Skip to content

Commit

Permalink
Always set default ES_PATH_CONF for package scriptlets (#51827)
Browse files Browse the repository at this point in the history
* Set default ES_PATH_CONF for package scriptlets

Our packages use scriptlets to create or update the Elasticsearch
keystore as necessary when installing or upgrading an Elasticsearch
package. If these scriptlets don't work as expected, Elasticsearch may
try and fail to create or upgrade the keystore at startup time. This
will prevent Elasticsearch from starting up at all.

These scriptlets use the Elasticsearch keystore command-line tools. Like
most of our command-line tools, the keystore tools will by default get
their value for ES_PATH_CONF from a system configuration file:
/etc/sysconfig/elasticsearch for RPMs, /etc/default/elasticsearch for
debian packages. Previously, if the user removed ES_PATH_CONF from that
system configuration file (perhaps thinking that it is obsolete when
the same variables is also defined in the systemd unit file), the
keystore command-line tools would fail. Scriptlet errors do not seem to
cause the installation to fail, and for RPMs the error message is easy
to miss in command output.

This commit adds a line of bash to scriptlets that will set ES_PATH_CONF
to a default when ES_PATH_CONF is unset, rather than only when the
system configuration file is missing.
  • Loading branch information
williamrandolph committed Feb 14, 2020
1 parent d16f92b commit da09dc2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions distribution/packages/src/common/env/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#JAVA_HOME=

# Elasticsearch configuration directory
# Note: this setting will be shared with command-line tools
ES_PATH_CONF=${path.conf}

# Elasticsearch PID directory
Expand Down
4 changes: 2 additions & 2 deletions distribution/packages/src/common/scripts/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

export ES_PATH_CONF=${ES_PATH_CONF:-${path.conf}}

IS_UPGRADE=false

case "$1" in
Expand Down
4 changes: 2 additions & 2 deletions distribution/packages/src/common/scripts/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

export ES_PATH_CONF=${ES_PATH_CONF:-${path.conf}}

REMOVE_DIRS=false
REMOVE_JVM_OPTIONS_DIRECTORY=false
REMOVE_USER_AND_GROUP=false
Expand Down
4 changes: 2 additions & 2 deletions distribution/packages/src/common/scripts/posttrans
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

export ES_PATH_CONF=${ES_PATH_CONF:-${path.conf}}

if [ ! -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then
/usr/share/elasticsearch/bin/elasticsearch-keystore create
chown root:elasticsearch "${ES_PATH_CONF}"/elasticsearch.keystore
Expand Down
4 changes: 2 additions & 2 deletions distribution/packages/src/common/scripts/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ err_exit() {
# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

export ES_PATH_CONF=${ES_PATH_CONF:-${path.conf}}

case "$1" in

# Debian ####################################################
Expand Down
4 changes: 2 additions & 2 deletions distribution/packages/src/common/scripts/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

export ES_PATH_CONF=${ES_PATH_CONF:-${path.conf}}

STOP_REQUIRED=false
REMOVE_SERVICE=false

Expand Down

0 comments on commit da09dc2

Please sign in to comment.