diff --git a/scripts/pkg/build_templates/opensearch/deb/debian/preinst b/scripts/pkg/build_templates/opensearch/deb/debian/preinst index 6f0a1451b8..e1a5056e5a 100755 --- a/scripts/pkg/build_templates/opensearch/deb/debian/preinst +++ b/scripts/pkg/build_templates/opensearch/deb/debian/preinst @@ -31,15 +31,11 @@ fi # 2. Currently, the demo config setup is defined to run, in postinst, if `opensearch-security` is present. Cannot apply the same check here since the plugins folder is not available yet. # Check if this is an upgrade by checking whether opensearch already exists -set +e -dpkg-query -l opensearch 2>&1 | grep ^ii >/dev/null -EX_CODE=$? -if [ $EX_CODE -eq 0 ]; then - OPENSEARCH_ALREADY_INSTALLED=yes +if [ -f /lib/systemd/system/opensearch.service ] || [ -f /etc/systemd/system/opensearch.service ]; then + OPENSEARCH_ALREADY_INSTALLED=yes else - OPENSEARCH_ALREADY_INSTALLED=no + OPENSEARCH_ALREADY_INSTALLED=no fi -set -e OPENSEARCH_REQUIRED_VERSION="2.12.0" MINIMUM_OF_TWO_VERSIONS=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` diff --git a/scripts/pkg/build_templates/opensearch/rpm/opensearch.rpm.spec b/scripts/pkg/build_templates/opensearch/rpm/opensearch.rpm.spec index ed092a24e5..179a246bde 100644 --- a/scripts/pkg/build_templates/opensearch/rpm/opensearch.rpm.spec +++ b/scripts/pkg/build_templates/opensearch/rpm/opensearch.rpm.spec @@ -96,15 +96,11 @@ fi # 2. Currently, the demo config setup is defined to run, in postinst, if `opensearch-security` is present. Cannot apply the same check here since the plugins folder is not available yet. # Check if this is an upgrade by checking whether opensearch already exists -set +e -rpm -q opensearch > /dev/null 2>&1 || yum list installed opensearch > /dev/null 2>&1 -EX_CODE=$? -if [ $EX_CODE -eq 0 ]; then - OPENSEARCH_ALREADY_INSTALLED=yes +if rpm -q opensearch >/dev/null 2>&1 || yum list installed opensearch >/dev/null 2>&1; then + OPENSEARCH_ALREADY_INSTALLED=yes else - OPENSEARCH_ALREADY_INSTALLED=no + OPENSEARCH_ALREADY_INSTALLED=no fi -set -e OPENSEARCH_REQUIRED_VERSION="2.12.0" OPENSEARCH_VERSION=%{_version}