Files
fk-wazuh/build-docker-images/wazuh-dashboard/config/wazuh_app_config.sh
T
2025-12-04 16:27:09 -03:00

73 lines
1.9 KiB
Bash

#!/bin/bash
# Wazuh Docker Copyright (C) 2017, Wazuh Inc. (License GPLv2)
set -x
wazuh_url="${WAZUH_API_URL:-https://wazuh}"
wazuh_port="${API_PORT:-55000}"
api_username="${API_USERNAME:-wazuh-wui}"
api_password="${API_PASSWORD:-wazuh-wui}"
api_run_as="${RUN_AS:-false}"
export DH_OPTIONS
export NAME=wazuh-dashboard
export INSTALLATION_DIR=/usr/share/${NAME}
export CONFIG_DIR=${INSTALLATION_DIR}/config
dashboard_config_file="${CONFIG_DIR}/opensearch_dashboards.yml"
printf "Modifying Wazuh App configuration file: %s\n" "$dashboard_config_file"
ls -la ${CONFIG_DIR}
printf "/etc/wazuh-dashboard contents:\n"
ls -la /etc/wazuh-dashboard
# Modify opensearch_dashboards.yml config paths
if [ -d "/etc/wazuh-dashboard" ]; then
mkdir -p ${CONFIG_DIR}
mkdir -p ${CONFIG_DIR}/certs
mv /etc/wazuh-dashboard/* ${CONFIG_DIR}/
rmdir /etc/wazuh-dashboard
fi
sed -i "s|/etc/wazuh-dashboard|${CONFIG_DIR}|g" ${dashboard_config_file}
declare -A CONFIG_MAP=(
[pattern]=$PATTERN
[checks.pattern]=$CHECKS_PATTERN
[checks.template]=$CHECKS_TEMPLATE
[checks.api]=$CHECKS_API
[checks.setup]=$CHECKS_SETUP
[timeout]=$APP_TIMEOUT
[api.selector]=$API_SELECTOR
[ip.selector]=$IP_SELECTOR
[ip.ignore]=$IP_IGNORE
[wazuh.monitoring.enabled]=$WAZUH_MONITORING_ENABLED
[wazuh.monitoring.frequency]=$WAZUH_MONITORING_FREQUENCY
[wazuh.monitoring.shards]=$WAZUH_MONITORING_SHARDS
[wazuh.monitoring.replicas]=$WAZUH_MONITORING_REPLICAS
)
for i in "${!CONFIG_MAP[@]}"
do
if [ "${CONFIG_MAP[$i]}" != "" ]; then
sed -i 's/.*#'"$i"'.*/'"$i"': '"${CONFIG_MAP[$i]}"'/' $dashboard_config_file
fi
done
grep -q wazuh_core.hosts $dashboard_config_file
_config_exists=$?
if [[ $_config_exists -ne 0 ]]; then
cat << EOF >> $dashboard_config_file
wazuh_core.hosts:
default:
url: $wazuh_url
port: $wazuh_port
username: $api_username
password: $api_password
run_as: $api_run_as
EOF
else
echo "Wazuh APP already configured"
fi
set +x