From c9f379d02e287c7f5e3561df162ae2ffdf951087 Mon Sep 17 00:00:00 2001 From: Victor Carlos Erenu Date: Tue, 11 Nov 2025 21:44:08 +0700 Subject: [PATCH] Add download check --- .../wazuh-dashboard/config/config.sh | 15 +++++++++++++-- .../wazuh-indexer/config/config.sh | 15 +++++++++++++-- .../wazuh-manager/config/config.sh | 15 +++++++++++++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/build-docker-images/wazuh-dashboard/config/config.sh b/build-docker-images/wazuh-dashboard/config/config.sh index 4b6a2fcd..2d1d0ee4 100644 --- a/build-docker-images/wazuh-dashboard/config/config.sh +++ b/build-docker-images/wazuh-dashboard/config/config.sh @@ -13,12 +13,23 @@ export CONFIG_DIR=${INSTALLATION_DIR}/config # Variables for certificate generation CERT_TOOL="wazuh-certs-tool.sh" CERT_CONFIG_FILE="config.yml" +download_package() { + local url=$1 + local package=$2 + if curl -fsL "$url" -o "$package"; then + echo "Downloaded $package" + return 0 + else + echo "Error downloading $package from $url" + return 1 + fi +} # Download the tool to create the certificates echo "Downloading the tool to create the certificates..." -curl -fsL "$wazuh_cert_tool" -o $CERT_TOOL +download_package "$wazuh_cert_tool" $CERT_TOOL # Download the config file for the certificate tool echo "Downloading the config file for the certificate tool..." -curl -fsL "$wazuh_config_yml" -o $CERT_CONFIG_FILE +download_package "$wazuh_config_yml" $CERT_CONFIG_FILE # Modify the config file to set the IP to localhost sed -i 's/ ip:.*/ ip: "127.0.0.1"/' $CERT_CONFIG_FILE diff --git a/build-docker-images/wazuh-indexer/config/config.sh b/build-docker-images/wazuh-indexer/config/config.sh index 7bcd68de..abcf257b 100644 --- a/build-docker-images/wazuh-indexer/config/config.sh +++ b/build-docker-images/wazuh-indexer/config/config.sh @@ -21,12 +21,23 @@ export CONFIG_DIR=${INSTALLATION_DIR}/config # Variables for certificate generation CERT_TOOL="wazuh-certs-tool.sh" CERT_CONFIG_FILE="config.yml" +download_package() { + local url=$1 + local package=$2 + if curl -fsL "$url" -o "$package"; then + echo "Downloaded $package" + return 0 + else + echo "Error downloading $package from $url" + return 1 + fi +} # Download the tool to create the certificates echo "Downloading the tool to create the certificates..." -curl -fsL "$wazuh_cert_tool" -o $CERT_TOOL +download_package "$wazuh_cert_tool" $CERT_TOOL # Download the config file for the certificate tool echo "Downloading the config file for the certificate tool..." -curl -fsL "$wazuh_config_yml" -o $CERT_CONFIG_FILE +download_package "$wazuh_config_yml" $CERT_CONFIG_FILE # Modify the config file to set the IP to localhost sed -i 's/ ip:.*/ ip: "127.0.0.1"/' $CERT_CONFIG_FILE diff --git a/build-docker-images/wazuh-manager/config/config.sh b/build-docker-images/wazuh-manager/config/config.sh index 5bfd2d4c..d5359904 100644 --- a/build-docker-images/wazuh-manager/config/config.sh +++ b/build-docker-images/wazuh-manager/config/config.sh @@ -5,12 +5,23 @@ CERT_TOOL="wazuh-certs-tool.sh" CERT_CONFIG_FILE="config.yml" CERT_DIR=/var/ossec/etc/certs/ +download_package() { + local url=$1 + local package=$2 + if curl -fsL "$url" -o "$package"; then + echo "Downloaded $package" + return 0 + else + echo "Error downloading $package from $url" + return 1 + fi +} # Download the tool to create the certificates echo "Downloading the tool to create the certificates..." -curl -fsL "$wazuh_cert_tool" -o $CERT_TOOL +download_package "$wazuh_cert_tool" $CERT_TOOL # Download the config file for the certificate tool echo "Downloading the config file for the certificate tool..." -curl -fsL "$wazuh_config_yml" -o $CERT_CONFIG_FILE +download_package "$wazuh_config_yml" $CERT_CONFIG_FILE # Modify the config file to set the IP to localhost sed -i 's/ ip:.*/ ip: "127.0.0.1"/' $CERT_CONFIG_FILE