From e4d5a4c661b7dc76cc0e6802adc6cf0c35fe80f3 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 16 Dec 2019 15:07:38 -0500 Subject: [PATCH] Respect ES_PATH_CONF during upgrades too (#50246) A previous commit taught Elasticsearch packages to respect ES_PATH_CONF during installs. Missed in that commit was respecting ES_PATH_CONF on upgrades. This commit does that. Additionally, while ES_PATH_CONF is not currently used in pre-install, this commit adds respect to the preinst script in case we do in the future. --- .../packages/src/common/scripts/posttrans | 15 +++++++++++---- distribution/packages/src/common/scripts/preinst | 7 +++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/distribution/packages/src/common/scripts/posttrans b/distribution/packages/src/common/scripts/posttrans index fdb9aafba38f6..ab989cf5676fd 100644 --- a/distribution/packages/src/common/scripts/posttrans +++ b/distribution/packages/src/common/scripts/posttrans @@ -1,8 +1,15 @@ -if [ ! -f /etc/elasticsearch/elasticsearch.keystore ]; then +# source the default env file +if [ -f "${path.env}" ]; then + . "${path.env}" +else + ES_PATH_CONF="${path.conf}" +fi + +if [ ! -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then /usr/share/elasticsearch/bin/elasticsearch-keystore create - chown root:elasticsearch /etc/elasticsearch/elasticsearch.keystore - chmod 660 /etc/elasticsearch/elasticsearch.keystore - md5sum /etc/elasticsearch/elasticsearch.keystore > /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum + chown root:elasticsearch "${ES_PATH_CONF}"/elasticsearch.keystore + chmod 660 "${ES_PATH_CONF}"/elasticsearch.keystore + md5sum "${ES_PATH_CONF}"/elasticsearch.keystore > "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum else /usr/share/elasticsearch/bin/elasticsearch-keystore upgrade fi diff --git a/distribution/packages/src/common/scripts/preinst b/distribution/packages/src/common/scripts/preinst index 66e5038a55daa..c3e15b632aaf7 100644 --- a/distribution/packages/src/common/scripts/preinst +++ b/distribution/packages/src/common/scripts/preinst @@ -15,6 +15,13 @@ err_exit() { exit 1 } +# source the default env file +if [ -f "${path.env}" ]; then + . "${path.env}" +else + ES_PATH_CONF="${path.conf}" +fi + case "$1" in # Debian ####################################################