mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 18:22:47 +01:00
Only load if so-elastic-fleet-common exists
This commit is contained in:
@@ -15,11 +15,12 @@ default_conf_dir=/opt/so/conf
|
|||||||
# Define a default directory to load pipelines from
|
# Define a default directory to load pipelines from
|
||||||
ELASTICSEARCH_TEMPLATES="$default_conf_dir/elasticsearch/templates/"
|
ELASTICSEARCH_TEMPLATES="$default_conf_dir/elasticsearch/templates/"
|
||||||
|
|
||||||
# Wait for ElasticSearch to initialize
|
if [ -f /usr/sbin/so-elastic-fleet-common ]; then
|
||||||
echo -n "Waiting for ElasticSearch..."
|
# Wait for ElasticSearch to initialize
|
||||||
COUNT=0
|
echo -n "Waiting for ElasticSearch..."
|
||||||
ELASTICSEARCH_CONNECTED="no"
|
COUNT=0
|
||||||
while [[ "$COUNT" -le 240 ]]; do
|
ELASTICSEARCH_CONNECTED="no"
|
||||||
|
while [[ "$COUNT" -le 240 ]]; do
|
||||||
so-elasticsearch-query / -k --output /dev/null --silent --head --fail
|
so-elasticsearch-query / -k --output /dev/null --silent --head --fail
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
ELASTICSEARCH_CONNECTED="yes"
|
ELASTICSEARCH_CONNECTED="yes"
|
||||||
@@ -30,47 +31,50 @@ while [[ "$COUNT" -le 240 ]]; do
|
|||||||
sleep 1
|
sleep 1
|
||||||
echo -n "."
|
echo -n "."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$ELASTICSEARCH_CONNECTED" == "no" ]; then
|
if [ "$ELASTICSEARCH_CONNECTED" == "no" ]; then
|
||||||
echo
|
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 -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
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SESSIONCOOKIE=$(curl -s -K /opt/so/conf/elasticsearch/curl.config -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}')
|
SESSIONCOOKIE=$(curl -s -K /opt/so/conf/elasticsearch/curl.config -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}')
|
||||||
INSTALLED=$(elastic_fleet_package_is_installed {{ SUPPORTED_PACKAGES[0] }} )
|
INSTALLED=$(elastic_fleet_package_is_installed {{ SUPPORTED_PACKAGES[0] }} )
|
||||||
if [ "$INSTALLED" != "installed" ]; then
|
if [ "$INSTALLED" != "installed" ]; then
|
||||||
echo
|
echo
|
||||||
echo "Packages not yet installed."
|
echo "Packages not yet installed."
|
||||||
echo
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd ${ELASTICSEARCH_TEMPLATES}/component/ecs
|
||||||
|
|
||||||
|
echo "Loading ECS component templates..."
|
||||||
|
for i in *; do TEMPLATE=$(echo $i | cut -d '.' -f1); echo "$TEMPLATE-mappings"; so-elasticsearch-query _component_template/$TEMPLATE-mappings -d@$i -XPUT 2>/dev/null; echo; done
|
||||||
|
|
||||||
|
cd ${ELASTICSEARCH_TEMPLATES}/component/elastic-agent
|
||||||
|
|
||||||
|
echo "Loading Elastic Agent component templates..."
|
||||||
|
for i in *; do TEMPLATE=${i::-5}; echo "$TEMPLATE"; so-elasticsearch-query _component_template/$TEMPLATE -d@$i -XPUT 2>/dev/null; echo; done
|
||||||
|
|
||||||
|
# Load SO-specific component templates
|
||||||
|
cd ${ELASTICSEARCH_TEMPLATES}/component/so
|
||||||
|
|
||||||
|
echo "Loading Security Onion component templates..."
|
||||||
|
for i in *; do TEMPLATE=$(echo $i | cut -d '.' -f1); echo "$TEMPLATE"; so-elasticsearch-query _component_template/$TEMPLATE -d@$i -XPUT 2>/dev/null; echo; done
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Load SO index templates
|
||||||
|
cd ${ELASTICSEARCH_TEMPLATES}/index
|
||||||
|
|
||||||
|
echo "Loading Security Onion index templates..."
|
||||||
|
for i in *; do TEMPLATE=${i::-14}; echo "$TEMPLATE"; so-elasticsearch-query _index_template/$TEMPLATE -d@$i -XPUT 2>/dev/null; echo; done
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo "Elastic Fleet not configured. Exiting..."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
cd - >/dev/null
|
||||||
set -e
|
|
||||||
|
|
||||||
cd ${ELASTICSEARCH_TEMPLATES}/component/ecs
|
|
||||||
|
|
||||||
echo "Loading ECS component templates..."
|
|
||||||
for i in *; do TEMPLATE=$(echo $i | cut -d '.' -f1); echo "$TEMPLATE-mappings"; so-elasticsearch-query _component_template/$TEMPLATE-mappings -d@$i -XPUT 2>/dev/null; echo; done
|
|
||||||
|
|
||||||
cd ${ELASTICSEARCH_TEMPLATES}/component/elastic-agent
|
|
||||||
|
|
||||||
echo "Loading Elastic Agent component templates..."
|
|
||||||
for i in *; do TEMPLATE=${i::-5}; echo "$TEMPLATE"; so-elasticsearch-query _component_template/$TEMPLATE -d@$i -XPUT 2>/dev/null; echo; done
|
|
||||||
|
|
||||||
# Load SO-specific component templates
|
|
||||||
cd ${ELASTICSEARCH_TEMPLATES}/component/so
|
|
||||||
|
|
||||||
echo "Loading Security Onion component templates..."
|
|
||||||
for i in *; do TEMPLATE=$(echo $i | cut -d '.' -f1); echo "$TEMPLATE"; so-elasticsearch-query _component_template/$TEMPLATE -d@$i -XPUT 2>/dev/null; echo; done
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Load SO index templates
|
|
||||||
cd ${ELASTICSEARCH_TEMPLATES}/index
|
|
||||||
|
|
||||||
echo "Loading Security Onion index templates..."
|
|
||||||
for i in *; do TEMPLATE=${i::-14}; echo "$TEMPLATE"; so-elasticsearch-query _index_template/$TEMPLATE -d@$i -XPUT 2>/dev/null; echo; done
|
|
||||||
echo
|
|
||||||
|
|
||||||
cd - >/dev/null
|
|
||||||
|
|||||||
Reference in New Issue
Block a user