This repository has been archived by the owner on Apr 19, 2021. It is now read-only.
forked from dougburks/securityonion-elastic
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete old Logstash templates Security-Onion-Solutions/security-onion…
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2014,2015,2016,2017,2018,2019,2020 Security Onion Solutions, LLC | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
. /usr/sbin/so-elastic-common | ||
|
||
. /etc/nsm/securityonion.conf | ||
|
||
# Check for error conditions | ||
if [ "$ELASTICSEARCH_ENABLED" == "yes" ] && [ "$KIBANA_ENABLED" == "yes" ] && [ -f $ELASTICSEARCH_ACCOUNTS ]; then | ||
|
||
echo | ||
header "Removing old logstash templates..." | ||
echo | ||
|
||
COUNT=0 | ||
ELASTICSEARCH_CONNECTED="no" | ||
echo -n "Waiting for ElasticSearch..." | ||
while [[ "$COUNT" -le 480 ]]; do | ||
curl ${ELASTICSEARCH_AUTH} --output /dev/null --silent --head --fail http://"$ELASTICSEARCH_HOST":"$ELASTICSEARCH_PORT" | ||
if [ $? -eq 0 ]; then | ||
ELASTICSEARCH_CONNECTED="yes" | ||
echo "connected!" | ||
break | ||
else | ||
((COUNT+=1)) | ||
sleep 1 | ||
echo -n "." | ||
fi | ||
done | ||
if [ "$ELASTICSEARCH_CONNECTED" == "no" ]; then | ||
echo | ||
echo -e "Connection attempt timed out. Unable to connect to ElasticSearch. \nPlease try: \n -checking log(s) in /var/log/elasticsearch/\n -running 'sudo docker ps' \n -running 'sudo so-elastic-restart'" | ||
echo | ||
|
||
else | ||
|
||
|
||
curl -XDELETE $ELASTICSEARCH_AUTH $ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_template/logstash | ||
curl -XDELETE $ELASTICSEARCH_AUTH $ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_template/logstash-* | ||
|
||
echo; echo | ||
header "Old logstash templates removed!" | ||
echo | ||
|
||
fi | ||
|
||
fi |