Skip to content

Commit 43370af

Browse files
AlexRuiz7Jorgesnchz
authored andcommitted
Update ism-init script (#97)
* Update ism-init script to parametrize the path of the wazuh-template --------- Signed-off-by: Álex Ruiz <[email protected]>
1 parent 63e8a2f commit 43370af

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

distribution/src/bin/indexer-ism-init.sh

+14-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ INDEXER_URL="https://${INDEXER_HOSTNAME}:9200"
1919
# curl settings shortcuts
2020
C_AUTH="-u admin:${INDEXER_PASSWORD}"
2121

22+
ALERTS_TEMPLATE="/etc/wazuh-indexer/wazuh-template.json"
23+
2224
#########################################################################
2325
# Creates the rollover_policy ISM policy.
2426
# Globals:
@@ -127,10 +129,9 @@ function generate_ism_config() {
127129
#########################################################################
128130
function load_templates() {
129131
# Load wazuh-template.json, needed for initial indices creation.
130-
local wazuh_template_path="/etc/wazuh-indexer/wazuh-template.json"
131132
echo "Will create 'wazuh' index template"
132-
if [ -f $wazuh_template_path ]; then
133-
cat $wazuh_template_path |
133+
if [ -f "${ALERTS_TEMPLATE}" ]; then
134+
cat "${ALERTS_TEMPLATE}" |
134135
if ! curl -s -k ${C_AUTH} \
135136
-X PUT "${INDEXER_URL}/_template/wazuh" \
136137
-o "${LOG_FILE}" --create-dirs \
@@ -141,7 +142,7 @@ function load_templates() {
141142
echo " SUCC: 'wazuh' template created or updated"
142143
fi
143144
else
144-
echo " ERROR: $wazuh_template_path not found"
145+
echo " ERROR: ${ALERTS_TEMPLATE} not found"
145146
fi
146147

147148
# Load template for ISM configuration indices
@@ -403,6 +404,15 @@ function main() {
403404
shift 2
404405
fi
405406
;;
407+
"-t" | "--template")
408+
if [ -z "${2}" ]; then
409+
echo "Error on arguments. Probably missing <template> after -t|--template"
410+
show_help
411+
else
412+
ALERTS_TEMPLATE="${2}"
413+
shift 2
414+
fi
415+
;;
406416
"-v" | "--verbose")
407417
set -x
408418
shift

0 commit comments

Comments
 (0)