diff --git a/stack/indexer/base/builder.sh b/stack/indexer/base/builder.sh index f89cfb79be..eed3af3cfc 100644 --- a/stack/indexer/base/builder.sh +++ b/stack/indexer/base/builder.sh @@ -10,12 +10,13 @@ set -x # License (version 2) as published by the FSF - Free Software # Foundation. -set -e +set -ex architecture="$1" revision="$2" -future="$3" -reference="$4" +filebeat_module_reference="$3" +future="$4" +reference="$5" opensearch_version="2.10.0" base_dir=/opt/wazuh-indexer-base @@ -64,6 +65,7 @@ mkdir -p ./etc/wazuh-indexer/ cp -r ./config/* ./etc/wazuh-indexer/ rm -rf ./config cp -r /root/stack/indexer/base/files/etc/wazuh-indexer/* ./etc/wazuh-indexer/ +curl -so ./etc/wazuh-indexer/wazuh-template.json "https://github.com/wazuh/wazuh/blob/${filebeat_module_reference}/extensions/elasticsearch/7.x/wazuh-template.json" cp -r /root/stack/indexer/base/files/etc/sysconfig ./etc/ cp -r /root/stack/indexer/base/files/etc/init.d ./etc/ cp -r /root/stack/indexer/base/files/usr ./ @@ -72,6 +74,8 @@ cp -r /root/stack/indexer/indexer-init.sh bin/ rm -rf ./plugins/opensearch-security/tools/install_demo_configuration.sh cp /root/VERSION . + + # ----------------------------------------------------------------------------- # Compile systemD module diff --git a/stack/indexer/base/generate_base.sh b/stack/indexer/base/generate_base.sh index 20a224e92c..78fcf47e51 100755 --- a/stack/indexer/base/generate_base.sh +++ b/stack/indexer/base/generate_base.sh @@ -18,6 +18,7 @@ container_name="indexer_base_builder" architecture="x64" future="no" revision="1" +filebeat_module_reference="" # ----------------------------------------------------------------------------- @@ -48,11 +49,11 @@ build_base() { # Build the RPM package with a Docker container if [ "${reference}" ];then docker run -t --rm -v ${outdir}/:/tmp/output:Z \ - ${container_name} ${architecture} ${revision} ${future} ${reference} || return 1 + ${container_name} ${architecture} ${revision} ${filebeat_module_reference} ${future} ${reference} || return 1 else docker run -t --rm -v ${outdir}/:/tmp/output:Z \ -v ${current_path}/../../..:/root:Z \ - ${container_name} ${architecture} ${revision} ${future} || return 1 + ${container_name} ${architecture} ${revision} ${filebeat_module_reference} ${future} || return 1 fi echo "Base file $(ls -Art ${outdir} | tail -n 1) added to ${outdir}." @@ -66,11 +67,12 @@ help() { echo echo "Usage: $0 [OPTIONS]" echo - echo " -s, --store [Optional] Set the destination path of package. By default, an output folder will be created." - echo " --reference [Optional] wazuh-packages branch or tag" - echo " --future [Optional] Build test future package 99.99.0 Used for development purposes." - echo " -r, --revision [Optional] Package revision. By default ${revision}" - echo " -h, --help Show this help." + echo " -s, --store [Optional] Set the destination path of package. By default, an output folder will be created." + echo " --reference [Optional] wazuh-packages branch or tag." + echo " -f, --filebeat-module-reference [Optional] wazuh/wazuh Filebeat template branch or tag." + echo " --future [Optional] Build test future package 99.99.0 Used for development purposes." + echo " -r, --revision [Optional] Package revision. By default ${revision}" + echo " -h, --help Show this help." echo exit "${1}" } @@ -100,6 +102,14 @@ main() { help 1 fi ;; + "-f"|"--filebeat-module-reference") + if [ -n "${2}" ]; then + filebeat_module_reference="${2}" + shift 2 + else + help 1 + fi + ;; "--future") future="yes" shift 1 @@ -112,11 +122,16 @@ main() { help 1 fi ;; + *) help 1 esac done + if [ -z "${filebeat_module_reference}" ]; then + filebeat_module_reference=$(cat ${current_path}/../../../VERSION) + fi + build_base || clean 1 clean 0 diff --git a/stack/indexer/deb/build_package.sh b/stack/indexer/deb/build_package.sh index d67dac9f7b..cb08a00680 100755 --- a/stack/indexer/deb/build_package.sh +++ b/stack/indexer/deb/build_package.sh @@ -18,6 +18,7 @@ deb_builder_dockerfile="${current_path}/docker" future="no" base_cmd="" build_base="yes" +filebeat_module_reference="" trap ctrl_c INT @@ -40,7 +41,7 @@ build_deb() { # Copy the necessary files cp ${current_path}/builder.sh ${dockerfile_path} - + if [ "${build_base}" == "yes" ];then # Base generation if [ "${future}" == "yes" ];then @@ -49,7 +50,7 @@ build_deb() { if [ "${reference}" ];then base_cmd+="--reference ${reference}" fi - ../base/generate_base.sh -s ${outdir} -r ${revision} ${base_cmd} + ../base/generate_base.sh -s ${outdir} -r ${revision} -f ${filebeat_module_reference} ${base_cmd} else if [ "${reference}" ];then version=$(curl -sL https://raw.githubusercontent.com/wazuh/wazuh-packages/${reference}/VERSION | cat) @@ -107,14 +108,15 @@ help() { echo echo "Usage: $0 [OPTIONS]" echo - echo " -a, --architecture [Optional] Target architecture of the package [amd64]." - echo " -b, --build-base [Optional] Build a new base or use a existing one. By default, yes." - echo " -r, --revision [Optional] Package revision. By default: 1." - echo " -s, --store [Optional] Set the destination path of package. By default, an output folder will be created." - echo " --reference [Optional] wazuh-packages branch to download SPECs, not used by default." - echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one." - echo " --future [Optional] Build test future package 99.99.0 Used for development purposes." - echo " -h, --help Show this help." + echo " -a, --architecture [Optional] Target architecture of the package [amd64]." + echo " -b, --build-base [Optional] Build a new base or use a existing one. By default, yes." + echo " -r, --revision [Optional] Package revision. By default: 1." + echo " -s, --store [Optional] Set the destination path of package. By default, an output folder will be created." + echo " --reference [Optional] wazuh-packages branch to download SPECs, not used by default." + echo " -f, --filebeat-module-reference [Optional] wazuh/wazuh Filebeat template branch or tag." + echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one." + echo " --future [Optional] Build test future package 99.99.0 Used for development purposes." + echo " -h, --help Show this help." echo exit $1 } @@ -159,6 +161,14 @@ main() { help 1 fi ;; + "-f"|"--filebeat-module-reference") + if [ -n "${2}" ]; then + filebeat_module_reference="${2}" + shift 2 + else + help 1 + fi + ;; "--dont-build-docker") build_docker="no" shift 1 @@ -180,6 +190,10 @@ main() { esac done + if [ -z "${filebeat_module_reference}" ]; then + filebeat_module_reference=$(cat ${current_path}/../../../VERSION) + fi + build || clean 1 clean 0 diff --git a/stack/indexer/deb/debian/rules b/stack/indexer/deb/debian/rules index d538c46dc1..d53495b003 100644 --- a/stack/indexer/deb/debian/rules +++ b/stack/indexer/deb/debian/rules @@ -153,6 +153,7 @@ override_dh_fixperms: chmod 660 $(TARGET_DIR)$(CONFIG_DIR)/jvm.options chmod 750 $(TARGET_DIR)$(INSTALLATION_DIR)/modules/aggs-matrix-stats chmod 660 $(TARGET_DIR)$(CONFIG_DIR)/opensearch.yml + chmod 660 $(TARGET_DIR)$(CONFIG_DIR)/wazuh-template.json chmod 640 $(TARGET_DIR)$(CONFIG_DIR)/opensearch-security/roles_mapping.yml chmod 640 $(TARGET_DIR)$(CONFIG_DIR)/opensearch-security/internal_users.yml chmod 640 $(TARGET_DIR)$(CONFIG_DIR)/opensearch-security/roles.yml diff --git a/stack/indexer/rpm/build_package.sh b/stack/indexer/rpm/build_package.sh index 41abeee729..d0614c1406 100755 --- a/stack/indexer/rpm/build_package.sh +++ b/stack/indexer/rpm/build_package.sh @@ -18,6 +18,7 @@ rpm_builder_dockerfile="${current_path}/docker" future="no" base_cmd="" build_base="yes" +filebeat_module_reference="" trap ctrl_c INT @@ -49,7 +50,7 @@ build_rpm() { if [ "${reference}" ];then base_cmd+="--reference ${reference}" fi - ../base/generate_base.sh -s ${outdir} -r ${revision} ${base_cmd} + ../base/generate_base.sh -s ${outdir} -r ${revision} -f ${filebeat_module_reference} ${base_cmd} else if [ "${reference}" ];then version=$(curl -sL https://raw.githubusercontent.com/wazuh/wazuh-packages/${reference}/VERSION | cat) @@ -106,14 +107,15 @@ help() { echo echo "Usage: $0 [OPTIONS]" echo - echo " -a, --architecture [Optional] Target architecture of the package [x86_64]." - echo " -b, --build-base [Optional] Build a new base or use a existing one. By default, yes." - echo " -r, --revision [Optional] Package revision. By default: 1." - echo " -s, --store [Optional] Set the destination path of package. By default, an output folder will be created." - echo " --reference [Optional] wazuh-packages branch to download SPECs, not used by default." - echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one." - echo " --future [Optional] Build test future package 99.99.0 Used for development purposes." - echo " -h, --help Show this help." + echo " -a, --architecture [Optional] Target architecture of the package [x86_64]." + echo " -b, --build-base [Optional] Build a new base or use a existing one. By default, yes." + echo " -r, --revision [Optional] Package revision. By default: 1." + echo " -s, --store [Optional] Set the destination path of package. By default, an output folder will be created." + echo " --reference [Optional] wazuh-packages branch to download SPECs, not used by default." + echo " -f, --filebeat-module-reference [Optional] wazuh/wazuh Filebeat template branch or tag." + echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one." + echo " --future [Optional] Build test future package 99.99.0 Used for development purposes." + echo " -h, --help Show this help." echo exit $1 } @@ -158,6 +160,14 @@ main() { help 1 fi ;; + "-f"|"--filebeat-module-reference") + if [ -n "${2}" ]; then + filebeat_module_reference="${2}" + shift 2 + else + help 1 + fi + ;; "--dont-build-docker") build_docker="no" shift 1 @@ -179,7 +189,9 @@ main() { esac done - set -ex + if [ -z "${filebeat_module_reference}" ]; then + filebeat_module_reference=$(cat ${current_path}/../../../VERSION) + fi build || clean 1 diff --git a/stack/indexer/rpm/wazuh-indexer.spec b/stack/indexer/rpm/wazuh-indexer.spec index 1b68da074f..645a1daf0b 100755 --- a/stack/indexer/rpm/wazuh-indexer.spec +++ b/stack/indexer/rpm/wazuh-indexer.spec @@ -647,6 +647,7 @@ rm -fr %{buildroot} %attr(640, %{USER}, %{GROUP}) %{CONFIG_DIR}/opensearch-performance-analyzer/*.properties %attr(640, %{USER}, %{GROUP}) %{CONFIG_DIR}/opensearch-performance-analyzer/plugin-stats-metadata %attr(640, %{USER}, %{GROUP}) %{CONFIG_DIR}/opensearch-performance-analyzer/*.policy +%attr(660, %{USER}, %{GROUP}) %{CONFIG_DIR}/wazuh-template.json %dir %attr(750, %{USER}, %{GROUP}) %{INSTALL_DIR}/performance-analyzer-rca/ %dir %attr(750, %{USER}, %{GROUP}) %{INSTALL_DIR}/performance-analyzer-rca/config/ %attr(640, %{USER}, %{GROUP}) %{INSTALL_DIR}/performance-analyzer-rca/config/agent-stats-metadata