Skip to content

Commit

Permalink
Update ism-init script (#97)
Browse files Browse the repository at this point in the history
* Update ism-init script to parametrize the path of the wazuh-template

---------

Signed-off-by: Álex Ruiz <alejandro.ruiz.becerra@wazuh.com>
  • Loading branch information
AlexRuiz7 committed Sep 9, 2024
1 parent 458c7ee commit 62d4295
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions distribution/src/bin/indexer-ism-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ INDEXER_URL="https://${INDEXER_HOSTNAME}:9200"
# curl settings shortcuts
C_AUTH="-u admin:${INDEXER_PASSWORD}"

ALERTS_TEMPLATE="/etc/wazuh-indexer/wazuh-template.json"

#########################################################################
# Creates the rollover_policy ISM policy.
# Globals:
Expand Down Expand Up @@ -127,10 +129,9 @@ function generate_ism_config() {
#########################################################################
function load_templates() {
# Load wazuh-template.json, needed for initial indices creation.
local wazuh_template_path="/etc/wazuh-indexer/wazuh-template.json"
echo "Will create 'wazuh' index template"
if [ -f $wazuh_template_path ]; then
cat $wazuh_template_path |
if [ -f "${ALERTS_TEMPLATE}" ]; then
cat "${ALERTS_TEMPLATE}" |
if ! curl -s -k ${C_AUTH} \
-X PUT "${INDEXER_URL}/_template/wazuh" \
-o "${LOG_FILE}" --create-dirs \
Expand All @@ -141,7 +142,7 @@ function load_templates() {
echo " SUCC: 'wazuh' template created or updated"
fi
else
echo " ERROR: $wazuh_template_path not found"
echo " ERROR: ${ALERTS_TEMPLATE} not found"
fi

# Load template for ISM configuration indices
Expand Down Expand Up @@ -403,6 +404,15 @@ function main() {
shift 2
fi
;;
"-t" | "--template")
if [ -z "${2}" ]; then
echo "Error on arguments. Probably missing <template> after -t|--template"
show_help
else
ALERTS_TEMPLATE="${2}"
shift 2
fi
;;
"-v" | "--verbose")
set -x
shift
Expand Down

0 comments on commit 62d4295

Please sign in to comment.