Skip to content

Commit

Permalink
Updates install check logic
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
DarshitChanpura committed Jan 17, 2024
1 parent dcaf6d8 commit 8bc4be6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 3 additions & 7 deletions scripts/pkg/build_templates/opensearch/deb/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
10 changes: 3 additions & 7 deletions scripts/pkg/build_templates/opensearch/rpm/opensearch.rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 8bc4be6

Please sign in to comment.