mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-10 11:12:51 +01:00
Revise Elastalert index check deletion logic
This commit is contained in:
@@ -852,13 +852,33 @@ up_to_2.3.140() {
|
||||
fi
|
||||
|
||||
# Delete Elastalert indices
|
||||
for i in $(so-elasticsearch-query _cat/indices | grep elastalert | awk '{print $3}'); do so-elasticsearch-query $i -XDELETE; done
|
||||
# Check to ensure Elastalert indices have been deleted
|
||||
RESPONSE=$(so-elasticsearch-query elastalert*)
|
||||
if [[ "$RESPONSE" == "{}" ]]; then
|
||||
echo "Elastalert indices have been deleted."
|
||||
else
|
||||
fail "Something went wrong. Could not delete the Elastalert indices. Exiting."
|
||||
for i in $(so-elasticsearch-query _cat/indices | grep elastalert | awk '{print $3}');
|
||||
do
|
||||
so-elasticsearch-query $i -XDELETE;
|
||||
done
|
||||
|
||||
# Check to ensure Elastalert indices are deleted
|
||||
COUNT=0
|
||||
ELASTALERT_INDICES_DELETED="no"
|
||||
while [[ "$COUNT" -le 240 ]]; do
|
||||
RESPONSE=$(so-elasticsearch-query elastalert*)
|
||||
if [[ "$RESPONSE" == "{}" ]]; then
|
||||
ELASTALERT_INDICES_DELETED="yes"
|
||||
echo "Elastalert indices successfully deleted."
|
||||
break
|
||||
else
|
||||
((COUNT+=1))
|
||||
sleep 1
|
||||
echo -n "."
|
||||
fi
|
||||
done
|
||||
|
||||
# If we were unable to delete the Elastalert indices, exit the script
|
||||
if [ "$ELASTALERT_INDICES_DELETED" == "no" ]; then
|
||||
echo
|
||||
echo -e "Unable to connect to delete Elastalert indices. Exiting."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
##
|
||||
INSTALLEDVERSION=2.3.140
|
||||
|
||||
Reference in New Issue
Block a user