From 69824ed9084a06eba57f381d18610d3466e7c32f Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 10 May 2019 11:00:17 -0700 Subject: [PATCH] Cleanup plugin bin directories (#41907) This commit adds deletion of the bin directory to postrm cleanup. While the package's bin files are cleaned up by the package manager, plugins may have created subdirectories under bin. We already cleanup plugins, but not the extra bin dirs their installation created. closes #18109 --- distribution/packages/src/common/scripts/postrm | 8 +++++++- .../org/elasticsearch/packaging/test/PackageTestCase.java | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/distribution/packages/src/common/scripts/postrm b/distribution/packages/src/common/scripts/postrm index a3cb5e1208f..c54df43450a 100644 --- a/distribution/packages/src/common/scripts/postrm +++ b/distribution/packages/src/common/scripts/postrm @@ -8,7 +8,6 @@ # On RedHat, # $1=0 : indicates a removal # $1=1 : indicates an upgrade - REMOVE_DIRS=false REMOVE_USER_AND_GROUP=false @@ -55,6 +54,13 @@ if [ "$REMOVE_DIRS" = "true" ]; then echo " OK" fi + # plugins may have contained bin files + if [ -d /usr/share/elasticsearch/bin ]; then + echo -n "Deleting plugin bin directories..." + rm -rf /usr/share/elasticsearch/bin + echo " OK" + fi + if [ -d /var/run/elasticsearch ]; then echo -n "Deleting PID directory..." rm -rf /var/run/elasticsearch diff --git a/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/PackageTestCase.java b/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/PackageTestCase.java index b6e26672f47..193edd7c32f 100644 --- a/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/PackageTestCase.java +++ b/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/PackageTestCase.java @@ -170,6 +170,9 @@ public abstract class PackageTestCase extends PackagingTestCase { public void test50Remove() throws Exception { assumeThat(installation, is(notNullValue())); + // add fake bin directory as if a plugin was installed + Files.createDirectories(installation.bin.resolve("myplugin")); + remove(distribution()); // removing must stop the service