From ba3f48ea0eca306d7e229dc28228ce28d8ed0c5c Mon Sep 17 00:00:00 2001 From: Fede Tux Date: Wed, 10 Jan 2024 13:56:34 -0300 Subject: [PATCH 1/3] add remove files function to assemble.sh --- scripts/assemble.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/scripts/assemble.sh b/scripts/assemble.sh index 67c8842f85226..7ec5c34b1deaa 100755 --- a/scripts/assemble.sh +++ b/scripts/assemble.sh @@ -165,6 +165,30 @@ function add_configuration_files() { find . -name "*.bat" -exec rm -rf {} \; } +# ==== +# Remove unneeded files +# ==== +function remove_unneeded_files() { + rm $PATH_PLUGINS/opensearch-security/tools/install_demo_configuration.sh +} + +# ==== +# Set up configuration files +# ==== +function add_configuration_files() { + # swap configuration files + cp $PATH_CONF/security/* $PATH_CONF/opensearch-security/ + cp $PATH_CONF/jvm.prod.options $PATH_CONF/jvm.options + cp $PATH_CONF/opensearch.prod.yml $PATH_CONF/opensearch.yml + + rm -r $PATH_CONF/security + rm $PATH_CONF/jvm.prod.options $PATH_CONF/opensearch.prod.yml + + # Remove symbolic links and bat files + find . -type l -exec rm -rf {} \; + find . -name "*.bat" -exec rm -rf {} \; +} + # ==== # Copy performance analyzer service file # ==== @@ -246,6 +270,7 @@ function assemble_rpm() { local src_path="./usr/share/wazuh-indexer" PATH_CONF="./etc/wazuh-indexer" PATH_BIN="${src_path}/bin" + PATH_PLUGINS="${src_path}/plugins" # Extract min-package. Creates usr/, etc/ and var/ in the current directory echo "Extract ${ARTIFACT_BUILD_NAME} archive" @@ -257,6 +282,8 @@ function assemble_rpm() { # Swap configuration files add_configuration_files + remove_unneeded_files + # Generate final package local topdir local version @@ -295,6 +322,7 @@ function assemble_deb() { local src_path="./usr/share/wazuh-indexer" PATH_CONF="./etc/wazuh-indexer" PATH_BIN="${src_path}/bin" + PATH_PLUGINS="${src_path}/plugins" # Extract min-package. Creates usr/, etc/ and var/ in the current directory echo "Extract ${ARTIFACT_BUILD_NAME} archive" @@ -307,6 +335,8 @@ function assemble_deb() { # Swap configuration files add_configuration_files + remove_unneeded_files + # Generate final package local version version=$(cat ./usr/share/wazuh-indexer/VERSION) From 374c65f48e602e7cc486429a2fc9ef35375e994b Mon Sep 17 00:00:00 2001 From: Fede Tux Date: Wed, 10 Jan 2024 14:39:39 -0300 Subject: [PATCH 2/3] Remove unneeded files on assembled tar packages --- scripts/assemble.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/assemble.sh b/scripts/assemble.sh index 7ec5c34b1deaa..635d8a5fccdbe 100755 --- a/scripts/assemble.sh +++ b/scripts/assemble.sh @@ -236,6 +236,7 @@ function assemble_tar() { cd "${TMP_DIR}" PATH_CONF="./config" PATH_BIN="./bin" + PATH_BIN="./plugins" # Extract echo "Extract ${ARTIFACT_BUILD_NAME} archive" @@ -247,6 +248,8 @@ function assemble_tar() { # Swap configuration files add_configuration_files + remove_unneeded_files + # Pack archive_name="wazuh-indexer-$(cat VERSION)" cd .. From ce14ea796559c23c0bc5b1e6ae81e5b3089a6faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 11 Jan 2024 12:03:46 +0100 Subject: [PATCH 3/3] Remove duplicated function Fix wrong variable assignment --- scripts/assemble.sh | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/scripts/assemble.sh b/scripts/assemble.sh index 635d8a5fccdbe..b64d987a72a04 100755 --- a/scripts/assemble.sh +++ b/scripts/assemble.sh @@ -169,24 +169,7 @@ function add_configuration_files() { # Remove unneeded files # ==== function remove_unneeded_files() { - rm $PATH_PLUGINS/opensearch-security/tools/install_demo_configuration.sh -} - -# ==== -# Set up configuration files -# ==== -function add_configuration_files() { - # swap configuration files - cp $PATH_CONF/security/* $PATH_CONF/opensearch-security/ - cp $PATH_CONF/jvm.prod.options $PATH_CONF/jvm.options - cp $PATH_CONF/opensearch.prod.yml $PATH_CONF/opensearch.yml - - rm -r $PATH_CONF/security - rm $PATH_CONF/jvm.prod.options $PATH_CONF/opensearch.prod.yml - - # Remove symbolic links and bat files - find . -type l -exec rm -rf {} \; - find . -name "*.bat" -exec rm -rf {} \; + rm "$PATH_PLUGINS/opensearch-security/tools/install_demo_configuration.sh" } # ==== @@ -236,7 +219,7 @@ function assemble_tar() { cd "${TMP_DIR}" PATH_CONF="./config" PATH_BIN="./bin" - PATH_BIN="./plugins" + PATH_PLUGINS="./plugins" # Extract echo "Extract ${ARTIFACT_BUILD_NAME} archive" @@ -247,8 +230,7 @@ function assemble_tar() { install_plugins # Swap configuration files add_configuration_files - - remove_unneeded_files + remove_unneeded_files # Pack archive_name="wazuh-indexer-$(cat VERSION)" @@ -284,8 +266,7 @@ function assemble_rpm() { enable_performance_analyzer_rca ${src_path} # Swap configuration files add_configuration_files - - remove_unneeded_files + remove_unneeded_files # Generate final package local topdir @@ -337,8 +318,7 @@ function assemble_deb() { enable_performance_analyzer_rca ${src_path} # Swap configuration files add_configuration_files - - remove_unneeded_files + remove_unneeded_files # Generate final package local version @@ -354,7 +334,7 @@ function assemble_deb() { # Move to the root folder, copy the package and clean. cd ../../.. - package_name="wazuh-indexer_${version}_${SUFFIX}.${EXT}" + package_name="wazuh-indexer_${version}_${SUFFIX}.${EXT}" # debmake creates the package one level above cp "${TMP_DIR}/../${package_name}" "${OUTPUT}/dist/$ARTIFACT_PACKAGE_NAME" @@ -371,9 +351,7 @@ function main() { ARTIFACT_BUILD_NAME=$(ls "${OUTPUT}/dist/" | grep "wazuh-indexer-min_.*$SUFFIX.*\.$EXT") - ARTIFACT_PACKAGE_NAME=${ARTIFACT_BUILD_NAME/min_/} - - + ARTIFACT_PACKAGE_NAME=${ARTIFACT_BUILD_NAME/min_/} # Create temporal directory and copy the min package there for extraction TMP_DIR="${OUTPUT}/tmp/${TARGET}"