Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect ES_PATH_CONF on package install #50158

Merged
merged 1 commit into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions distribution/packages/src/common/scripts/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
# $1=0 : indicates a removal
# $1=1 : indicates an upgrade

# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

IS_UPGRADE=false

case "$1" in
Expand Down Expand Up @@ -95,11 +102,11 @@ fi

# the equivalent code for rpm is in posttrans
if [ "$PACKAGE" = "deb" ]; then
if [ ! -f /etc/elasticsearch/elasticsearch.keystore ]; then
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
Expand Down
12 changes: 10 additions & 2 deletions distribution/packages/src/common/scripts/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
# On RedHat,
# $1=0 : indicates a removal
# $1=1 : indicates an upgrade

# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

REMOVE_DIRS=false
REMOVE_USER_AND_GROUP=false

Expand Down Expand Up @@ -73,8 +81,8 @@ if [ "$REMOVE_DIRS" = "true" ]; then
fi

# delete the conf directory if and only if empty
if [ -d /etc/elasticsearch ]; then
rmdir --ignore-fail-on-non-empty /etc/elasticsearch
if [ -d "${ES_PATH_CONF}" ]; then
rmdir --ignore-fail-on-non-empty "${ES_PATH_CONF}"
fi

fi
Expand Down
13 changes: 10 additions & 3 deletions distribution/packages/src/common/scripts/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
# $1=0 : indicates a removal
# $1=1 : indicates an upgrade

# source the default env file
if [ -f "${path.env}" ]; then
. "${path.env}"
else
ES_PATH_CONF="${path.conf}"
fi

STOP_REQUIRED=false
REMOVE_SERVICE=false

Expand Down Expand Up @@ -65,9 +72,9 @@ if [ "$STOP_REQUIRED" = "true" ]; then
echo " OK"
fi

if [ -f /etc/elasticsearch/elasticsearch.keystore ]; then
if md5sum --status -c /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum; then
rm /etc/elasticsearch/elasticsearch.keystore /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum
if [ -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then
if md5sum --status -c "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum; then
rm "${ES_PATH_CONF}"/elasticsearch.keystore "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum
fi
fi

Expand Down