Skip to content

Commit

Permalink
Removes check to validate presence of `OPENSEARCH_INITIAL_ADMIN_PASSW…
Browse files Browse the repository at this point in the history
…ORD` variable from preinst script of DEB distribution (#4453)

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
DarshitChanpura authored Feb 14, 2024
1 parent 0acb9ca commit a193bbd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
3 changes: 0 additions & 3 deletions scripts/components/OpenSearch/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ if [ "$DISTRIBUTION" = "tar" ]; then
elif [ "$DISTRIBUTION" = "deb" -o "$DISTRIBUTION" = "rpm" ]; then
cp -va ../../../scripts/pkg/service_templates/opensearch/* "$OUTPUT/../"
cp -va ../../../scripts/pkg/build_templates/opensearch/$DISTRIBUTION/* "$OUTPUT/../"
if [ "$DISTRIBUTION" = "deb" ]; then
sed -i "s/CHANGE_VERSION/${VERSION}/g" "$OUTPUT/../debian/preinst"
fi
elif [ "$DISTRIBUTION" = "zip" ] && [ "$PLATFORM" = "windows" ]; then
cp -v ../../../scripts/startup/zip/windows/opensearch-windows-install.bat "$OUTPUT/"
fi
26 changes: 0 additions & 26 deletions scripts/pkg/build_templates/opensearch/deb/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

set -e

OPENSEARCH_VERSION=CHANGE_VERSION

echo "Running OpenSearch Pre-Installation Script"

# Stop existing service
Expand All @@ -25,30 +23,6 @@ if command -v systemctl >/dev/null && systemctl is-active opensearch-performance
systemctl --no-reload stop opensearch-performance-analyzer.service
fi

# Check if OPENSEARCH_INITIAL_ADMIN_PASSWORD is defined
# TODO:
# 1. This check will need to be modified if there will be a min dist for deb in future (currently there is none)
# 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
if dpkg-query -W opensearch >/dev/null 2>&1; then
OPENSEARCH_ALREADY_INSTALLED=yes
else
OPENSEARCH_ALREADY_INSTALLED=no
fi

OPENSEARCH_REQUIRED_VERSION="2.12.0"
MINIMUM_OF_TWO_VERSIONS=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1`

if [ $OPENSEARCH_ALREADY_INSTALLED = no ]; then
if [ $MINIMUM_OF_TWO_VERSIONS = $OPENSEARCH_REQUIRED_VERSION ] && [ -z "$OPENSEARCH_INITIAL_ADMIN_PASSWORD" ]; then
echo "ERROR: Opensearch 2.12 and later requires the env variable OPENSEARCH_INITIAL_ADMIN_PASSWORD to be defined to setup the opensearch-security demo configuration"
echo "For more details, please visit: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/debian/"
exit 1
fi
fi


# Create user and group if they do not already exist.
getent group opensearch > /dev/null 2>&1 || groupadd -r opensearch
getent passwd opensearch > /dev/null 2>&1 || \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ fi

# Check if this is an upgrade by checking whether opensearch already exists
if rpm -q opensearch >/dev/null 2>&1 || yum list installed opensearch >/dev/null 2>&1; then
OPENSEARCH_ALREADY_INSTALLED=yes
OPENSEARCH_ALREADY_INSTALLED="yes"
else
OPENSEARCH_ALREADY_INSTALLED=no
OPENSEARCH_ALREADY_INSTALLED="no"
fi

OPENSEARCH_REQUIRED_VERSION="2.12.0"
OPENSEARCH_VERSION=%{_version}
MINIMUM_OF_TWO_VERSIONS=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1`

if [ $OPENSEARCH_ALREADY_INSTALLED = no ]; then
if [ $MINIMUM_OF_TWO_VERSIONS = $OPENSEARCH_REQUIRED_VERSION ] && [ -z "$OPENSEARCH_INITIAL_ADMIN_PASSWORD" ]; then
if [ "$OPENSEARCH_ALREADY_INSTALLED" = "no" ]; then
if [ "$MINIMUM_OF_TWO_VERSIONS" = "$OPENSEARCH_REQUIRED_VERSION" ] && [ -z "$OPENSEARCH_INITIAL_ADMIN_PASSWORD" ]; then
echo "ERROR: Opensearch 2.12 and later requires the env variable OPENSEARCH_INITIAL_ADMIN_PASSWORD to be defined to setup the opensearch-security demo configuration"
echo "For more details, please visit: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/rpm/"
exit 1
Expand Down

0 comments on commit a193bbd

Please sign in to comment.