Fix creating keystore when upgrading (#29121)
When upgrading via the RPM package, we can run into a problem where the keystore fails to be created. This arises because the %post script on RPM runs after the new package files are installed but before the removal of the old package files. This means that the contents of the lib folder can contain files from the old package and the new package and thus running the create keystore tool can encounter JAR hell issues and fail. To solve this, we move creating the keystore to the %posttrans script which runs after the old package files are removed. We only need to do this on the RPM package, so we add a switch in the shared post-install script.
This commit is contained in:
parent
2e93a9158f
commit
b56afebad1
|
@ -96,6 +96,9 @@ Closure commonPackageConfig(String type) {
|
||||||
postInstall file("${scripts}/postinst")
|
postInstall file("${scripts}/postinst")
|
||||||
preUninstall file("${scripts}/prerm")
|
preUninstall file("${scripts}/prerm")
|
||||||
postUninstall file("${scripts}/postrm")
|
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
|
// top level "into" directive is not inherited from ospackage for some reason, so we must
|
||||||
// specify it again explicitly for copying common files
|
// specify it again explicitly for copying common files
|
||||||
|
|
|
@ -19,18 +19,22 @@ case "$1" in
|
||||||
if [ -n $2 ]; then
|
if [ -n $2 ]; then
|
||||||
IS_UPGRADE=true
|
IS_UPGRADE=true
|
||||||
fi
|
fi
|
||||||
|
PACKAGE=deb
|
||||||
;;
|
;;
|
||||||
abort-upgrade|abort-remove|abort-deconfigure)
|
abort-upgrade|abort-remove|abort-deconfigure)
|
||||||
|
PACKAGE=deb
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# RedHat ####################################################
|
# RedHat ####################################################
|
||||||
1)
|
1)
|
||||||
# If $1=1 this is an install
|
# If $1=1 this is an install
|
||||||
IS_UPGRADE=false
|
IS_UPGRADE=false
|
||||||
|
PACKAGE=rpm
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
# If $1=1 this is an upgrade
|
# If $1=1 this is an upgrade
|
||||||
IS_UPGRADE=true
|
IS_UPGRADE=true
|
||||||
|
PACKAGE=rpm
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
@ -99,7 +103,8 @@ if [ -f ${path.env} ]; then
|
||||||
chown root:elasticsearch ${path.env}
|
chown root:elasticsearch ${path.env}
|
||||||
fi
|
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
|
/usr/share/elasticsearch/bin/elasticsearch-keystore create
|
||||||
chown root:elasticsearch /etc/elasticsearch/elasticsearch.keystore
|
chown root:elasticsearch /etc/elasticsearch/elasticsearch.keystore
|
||||||
chmod 660 /etc/elasticsearch/elasticsearch.keystore
|
chmod 660 /etc/elasticsearch/elasticsearch.keystore
|
||||||
|
|
|
@ -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}
|
Loading…
Reference in New Issue