Modify docker deployments

This commit is contained in:
Victor Carlos Erenu
2025-11-15 00:04:22 +07:00
parent b6bbd7de04
commit 1e343cf274
27 changed files with 234 additions and 1424 deletions
@@ -26,6 +26,10 @@ echo $DASHBOARD_PASSWORD | $OPENSEARCH_DASHBOARDS_HOME/bin/opensearch-dashboards
opensearch_dashboards_vars=(
opensearch.hosts
server.port
server.host
opensearch.username
opensearch.password
)
function runOpensearchDashboards {
@@ -11,6 +11,7 @@
# Export OpenSearch Home
export OPENSEARCH_HOME=/usr/share/wazuh-indexer
export OPENSEARCH_PATH_CONF=$OPENSEARCH_HOME/config
export CONFIG_FILE=${OPENSEARCH_PATH_CONF}/opensearch.yml
export PATH=$OPENSEARCH_HOME/bin:$PATH
@@ -62,8 +63,39 @@ function runOpensearch {
}
function configureOpensearch {
# Update opensearch.yml with NODES_DN if set
if [ -n "$NODES_DN" ]; then
CLEAN_NODES_DN=$(echo "$NODES_DN" | sed 's/^["'\'']//; s/["'\'']$//; s/""/"/g')
NODES_DN_YAML=$(echo $CLEAN_NODES_DN | tr ';' '\n' | sed 's/^/- "/; s/$/"/')
awk '
/^plugins\.security\.nodes_dn:/ {in_block=1; print; next}
in_block && /^[^#[:space:]-]/ {in_block=0}
!in_block || /^plugins\.security\.nodes_dn:/ {next}
{print}
' "$CONFIG_FILE" > "${CONFIG_FILE}.tmp"
awk -v repl="$NODES_DN_YAML" '
/^plugins\.security\.nodes_dn:/ {
print "plugins.security.nodes_dn:";
print repl;
skip=1; next
}
skip && /^[^#[:space:]-]/ {skip=0}
!skip
' "${CONFIG_FILE}" > "${CONFIG_FILE}.new"
mv "${CONFIG_FILE}.new" "$CONFIG_FILE"
rm -f "${CONFIG_FILE}.tmp"
fi
}
# Prepend "opensearch" command if no argument was provided or if the first
# argument looks like a flag (i.e. starts with a dash).
configureOpensearch
if [ $# -eq 0 ] || [ "${1:0:1}" = '-' ]; then
set -- opensearch "$@"
fi
@@ -4,18 +4,25 @@
# Variables for certificate generation
CERT_TOOL="wazuh-certs-tool.sh"
CERT_CONFIG_FILE="config.yml"
CERT_DIR=/var/ossec/etc/certs/
CERT_DIR=/etc/filebeat/certs
download_package() {
local url=$1
local package=$2
if curl -fsL "$url" -o "$package"; then
echo $url
cat $package
echo "Downloaded $package"
return 0
else
echo $url
cat $package
echo "Error downloading $package from $url"
return 1
fi
}
echo "pwd"
pwd
mkdir -p $CERT_DIR
# Download the tool to create the certificates
echo "Downloading the tool to create the certificates..."
download_package "$wazuh_cert_tool" $CERT_TOOL
@@ -30,6 +37,9 @@ chmod 700 "$CERT_CONFIG_FILE"
# Create the certificates
chmod 755 "$CERT_TOOL" && bash "$CERT_TOOL" -A
echo "files in pwd"
ls -la
# Copy Wazuh manager certs
cp -pr /wazuh-certificates/wazuh-1.pem ${CERT_DIR}/wazuh-1.pem
cp -pr /wazuh-certificates/wazuh-1-key.pem ${CERT_DIR}/wazuh-1-key.pem