From 12670a4b6ea0eaf260b36feabbb7d349ddb00394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Wed, 3 Jan 2024 17:56:41 +0100 Subject: [PATCH] Update ism-init script (#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update ism-init script to parametrize the path of the wazuh-template --------- Signed-off-by: Álex Ruiz --- distribution/src/bin/indexer-ism-init.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/distribution/src/bin/indexer-ism-init.sh b/distribution/src/bin/indexer-ism-init.sh index b30531cb0a713..3e9e4a3f278f3 100644 --- a/distribution/src/bin/indexer-ism-init.sh +++ b/distribution/src/bin/indexer-ism-init.sh @@ -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: @@ -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 \ @@ -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 @@ -403,6 +404,15 @@ function main() { shift 2 fi ;; + "-t" | "--template") + if [ -z "${2}" ]; then + echo "Error on arguments. Probably missing