Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ism-init script #97

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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