Skip to content

Commit ea10008

Browse files
jasontedorSivagurunathanV
authored andcommitted
Respect ES_PATH_CONF on package install (elastic#50158)
We respect ES_PATH_CONF everywhere except package install. This commit addresses this by respecting ES_PATH_CONF when installing the RPM/Debian packages.
1 parent 33af9c5 commit ea10008

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

distribution/packages/src/common/scripts/postinst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
# $1=0 : indicates a removal
99
# $1=1 : indicates an upgrade
1010

11+
# source the default env file
12+
if [ -f "${path.env}" ]; then
13+
. "${path.env}"
14+
else
15+
ES_PATH_CONF="${path.conf}"
16+
fi
17+
1118
IS_UPGRADE=false
1219

1320
case "$1" in
@@ -95,11 +102,11 @@ fi
95102

96103
# the equivalent code for rpm is in posttrans
97104
if [ "$PACKAGE" = "deb" ]; then
98-
if [ ! -f /etc/elasticsearch/elasticsearch.keystore ]; then
105+
if [ ! -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then
99106
/usr/share/elasticsearch/bin/elasticsearch-keystore create
100-
chown root:elasticsearch /etc/elasticsearch/elasticsearch.keystore
101-
chmod 660 /etc/elasticsearch/elasticsearch.keystore
102-
md5sum /etc/elasticsearch/elasticsearch.keystore > /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum
107+
chown root:elasticsearch "${ES_PATH_CONF}"/elasticsearch.keystore
108+
chmod 660 "${ES_PATH_CONF}"/elasticsearch.keystore
109+
md5sum "${ES_PATH_CONF}"/elasticsearch.keystore > "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum
103110
else
104111
/usr/share/elasticsearch/bin/elasticsearch-keystore upgrade
105112
fi

distribution/packages/src/common/scripts/postrm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
# On RedHat,
99
# $1=0 : indicates a removal
1010
# $1=1 : indicates an upgrade
11+
12+
# source the default env file
13+
if [ -f "${path.env}" ]; then
14+
. "${path.env}"
15+
else
16+
ES_PATH_CONF="${path.conf}"
17+
fi
18+
1119
REMOVE_DIRS=false
1220
REMOVE_USER_AND_GROUP=false
1321

@@ -73,8 +81,8 @@ if [ "$REMOVE_DIRS" = "true" ]; then
7381
fi
7482

7583
# delete the conf directory if and only if empty
76-
if [ -d /etc/elasticsearch ]; then
77-
rmdir --ignore-fail-on-non-empty /etc/elasticsearch
84+
if [ -d "${ES_PATH_CONF}" ]; then
85+
rmdir --ignore-fail-on-non-empty "${ES_PATH_CONF}"
7886
fi
7987

8088
fi

distribution/packages/src/common/scripts/prerm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
# $1=0 : indicates a removal
1010
# $1=1 : indicates an upgrade
1111

12+
# source the default env file
13+
if [ -f "${path.env}" ]; then
14+
. "${path.env}"
15+
else
16+
ES_PATH_CONF="${path.conf}"
17+
fi
18+
1219
STOP_REQUIRED=false
1320
REMOVE_SERVICE=false
1421

@@ -65,9 +72,9 @@ if [ "$STOP_REQUIRED" = "true" ]; then
6572
echo " OK"
6673
fi
6774

68-
if [ -f /etc/elasticsearch/elasticsearch.keystore ]; then
69-
if md5sum --status -c /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum; then
70-
rm /etc/elasticsearch/elasticsearch.keystore /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum
75+
if [ -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then
76+
if md5sum --status -c "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum; then
77+
rm "${ES_PATH_CONF}"/elasticsearch.keystore "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum
7178
fi
7279
fi
7380

0 commit comments

Comments
 (0)