Skip to content

Fix creating keystore when upgrading #29121

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

Merged
merged 1 commit into from
Mar 17, 2018
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
3 changes: 3 additions & 0 deletions distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ Closure commonPackageConfig(String type) {
postInstall file("${scripts}/postinst")
preUninstall file("${scripts}/prerm")
postUninstall file("${scripts}/postrm")
if (type == 'rpm') {
postTrans file("${scripts}/posttrans")
}

// top level "into" directive is not inherited from ospackage for some reason, so we must
// specify it again explicitly for copying common files
Expand Down
7 changes: 6 additions & 1 deletion distribution/packages/src/common/scripts/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ case "$1" in
if [ -n $2 ]; then
IS_UPGRADE=true
fi
PACKAGE=deb
;;
abort-upgrade|abort-remove|abort-deconfigure)
PACKAGE=deb
;;

# RedHat ####################################################
1)
# If $1=1 this is an install
IS_UPGRADE=false
PACKAGE=rpm
;;
2)
# If $1=1 this is an upgrade
IS_UPGRADE=true
PACKAGE=rpm
;;

*)
Expand Down Expand Up @@ -99,7 +103,8 @@ if [ -f ${path.env} ]; then
chown root:elasticsearch ${path.env}
fi

if [ ! -f /etc/elasticsearch/elasticsearch.keystore ]; then
# the equivalent code for rpm is in posttrans
if [ "$PACKAGE" = "deb" -a ! -f /etc/elasticsearch/elasticsearch.keystore ]; then
/usr/share/elasticsearch/bin/elasticsearch-keystore create
chown root:elasticsearch /etc/elasticsearch/elasticsearch.keystore
chmod 660 /etc/elasticsearch/elasticsearch.keystore
Expand Down
8 changes: 8 additions & 0 deletions distribution/packages/src/common/scripts/posttrans
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if [ ! -f /etc/elasticsearch/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
fi

${scripts.footer}