Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conditional to save service status if its running
Browse files Browse the repository at this point in the history
QU3B1M committed Oct 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 4fad7ba commit d1cc4c9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions distribution/packages/src/common/scripts/preinst
Original file line number Diff line number Diff line change
@@ -24,6 +24,17 @@ fi

export OPENSEARCH_PATH_CONF=${OPENSEARCH_PATH_CONF:-${path.conf}}

# Temp directory to save service status
TMP_DIR="/tmp/wazuh-indexer"

# environment configuration
if [ ! -d ${TMP_DIR} ]; then
mkdir -p ${TMP_DIR}
else
rm -rf ${TMP_DIR}
mkdir -p ${TMP_DIR}
fi

case "$1" in

# Debian ####################################################
@@ -49,6 +60,14 @@ case "$1" in
wazuh-indexer
echo " OK"
fi

# Save service expected status if its running
if [ "$1" = "upgrade" ]; then
if (command -v systemctl > /dev/null 2>&1 && systemctl > /dev/null 2>&1 && systemctl is-active --quiet wazuh-indexer > /dev/null 2>&1) || \
(command -v service > /dev/null 2>&1 && service wazuh-indexer status 2>/dev/null | grep "is running" > /dev/null 2>&1); then
touch ${TMP_DIR}/wazuh.restart
fi
fi
;;
abort-deconfigure|abort-upgrade|abort-remove)
;;
@@ -75,6 +94,14 @@ case "$1" in
wazuh-indexer
echo " OK"
fi

# Save service expected status if its running
if [ "$1" = "upgrade" ]; then
if (command -v systemctl > /dev/null 2>&1 && systemctl > /dev/null 2>&1 && systemctl is-active --quiet wazuh-indexer > /dev/null 2>&1) || \
(command -v service > /dev/null 2>&1 && service wazuh-indexer status 2>/dev/null | grep "is running" > /dev/null 2>&1); then
touch ${TMP_DIR}/wazuh.restart
fi
fi
;;

*)

0 comments on commit d1cc4c9

Please sign in to comment.