From 9d909b09b0b9e651ad6c9ea9024aaa9b0b182ea7 Mon Sep 17 00:00:00 2001 From: Fede Tux Date: Fri, 12 Jan 2024 06:30:41 -0300 Subject: [PATCH 1/5] Switch /var/run references to /run --- distribution/packages/src/common/env/wazuh-indexer | 2 +- distribution/packages/src/common/scripts/postrm | 4 ++-- distribution/packages/src/common/systemd/wazuh-indexer.conf | 2 +- .../packages/src/common/systemd/wazuh-indexer.service | 2 +- distribution/packages/src/deb/debmake_install.sh | 2 +- distribution/packages/src/rpm/init.d/wazuh-indexer | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/distribution/packages/src/common/env/wazuh-indexer b/distribution/packages/src/common/env/wazuh-indexer index 1b6f33db8a34b..553fefc3adba7 100644 --- a/distribution/packages/src/common/env/wazuh-indexer +++ b/distribution/packages/src/common/env/wazuh-indexer @@ -13,7 +13,7 @@ OPENSEARCH_PATH_CONF=${path.conf} # wazuh-indexer PID directory -#PID_DIR=/var/run/wazuh-indexer +#PID_DIR=/run/wazuh-indexer # Additional Java OPTS #OPENSEARCH_JAVA_OPTS= diff --git a/distribution/packages/src/common/scripts/postrm b/distribution/packages/src/common/scripts/postrm index 70871f9ae3004..ea5bf80944481 100644 --- a/distribution/packages/src/common/scripts/postrm +++ b/distribution/packages/src/common/scripts/postrm @@ -72,9 +72,9 @@ if [ "$REMOVE_DIRS" = "true" ]; then echo " OK" fi - if [ -d /var/run/wazuh-indexer ]; then + if [ -d /run/wazuh-indexer ]; then echo -n "Deleting PID directory..." - rm -rf /var/run/wazuh-indexer + rm -rf /run/wazuh-indexer echo " OK" fi diff --git a/distribution/packages/src/common/systemd/wazuh-indexer.conf b/distribution/packages/src/common/systemd/wazuh-indexer.conf index f9aa920e837b6..c021c7bcbb024 100644 --- a/distribution/packages/src/common/systemd/wazuh-indexer.conf +++ b/distribution/packages/src/common/systemd/wazuh-indexer.conf @@ -1 +1 @@ -d /var/run/wazuh-indexer 0750 wazuh-indexer wazuh-indexer - - +d /run/wazuh-indexer 0750 wazuh-indexer wazuh-indexer - - diff --git a/distribution/packages/src/common/systemd/wazuh-indexer.service b/distribution/packages/src/common/systemd/wazuh-indexer.service index e396257a9d5cf..130f22472d2e4 100644 --- a/distribution/packages/src/common/systemd/wazuh-indexer.service +++ b/distribution/packages/src/common/systemd/wazuh-indexer.service @@ -10,7 +10,7 @@ RuntimeDirectory=wazuh-indexer PrivateTmp=true Environment=OPENSEARCH_HOME=/usr/share/wazuh-indexer Environment=OPENSEARCH_PATH_CONF=${path.conf} -Environment=PID_DIR=/var/run/wazuh-indexer +Environment=PID_DIR=/run/wazuh-indexer Environment=OPENSEARCH_SD_NOTIFY=true EnvironmentFile=-${path.env} diff --git a/distribution/packages/src/deb/debmake_install.sh b/distribution/packages/src/deb/debmake_install.sh index 4b10a36e001c4..d9368d50ea71f 100644 --- a/distribution/packages/src/deb/debmake_install.sh +++ b/distribution/packages/src/deb/debmake_install.sh @@ -21,7 +21,7 @@ product_dir=/usr/share/wazuh-indexer # config_dir=/etc/wazuh-indexer data_dir=/var/lib/wazuh-indexer log_dir=/var/log/wazuh-indexer -pid_dir=/var/run/wazuh-indexer +pid_dir=/run/wazuh-indexer buildroot=${curdir}/debian/wazuh-indexer # Create necessary directories diff --git a/distribution/packages/src/rpm/init.d/wazuh-indexer b/distribution/packages/src/rpm/init.d/wazuh-indexer index 75b7b7ac9756f..218519f204a64 100644 --- a/distribution/packages/src/rpm/init.d/wazuh-indexer +++ b/distribution/packages/src/rpm/init.d/wazuh-indexer @@ -39,7 +39,7 @@ MAX_OPEN_FILES=65535 MAX_MAP_COUNT=262144 OPENSEARCH_PATH_CONF="${path.conf}" -PID_DIR="/var/run/wazuh-indexer" +PID_DIR="/run/wazuh-indexer" # Source the default env file OPENSEARCH_ENV_FILE="${path.env}" From efda221d1dd3656830cd9dc00076dacac6766e88 Mon Sep 17 00:00:00 2001 From: Federico Gustavo Galland <99492720+f-galland@users.noreply.github.com> Date: Fri, 12 Jan 2024 07:45:49 -0300 Subject: [PATCH 2/5] Remove unneeded files from assembled packages (#115) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add remove files function to assemble.sh * Remove unneeded files on assembled tar packages * Remove duplicated function Fix wrong variable assignment --------- Co-authored-by: Álex Ruiz --- scripts/assemble.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/assemble.sh b/scripts/assemble.sh index 67c8842f85226..b64d987a72a04 100755 --- a/scripts/assemble.sh +++ b/scripts/assemble.sh @@ -165,6 +165,13 @@ 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" +} + # ==== # Copy performance analyzer service file # ==== @@ -212,6 +219,7 @@ function assemble_tar() { cd "${TMP_DIR}" PATH_CONF="./config" PATH_BIN="./bin" + PATH_PLUGINS="./plugins" # Extract echo "Extract ${ARTIFACT_BUILD_NAME} archive" @@ -222,6 +230,7 @@ function assemble_tar() { install_plugins # Swap configuration files add_configuration_files + remove_unneeded_files # Pack archive_name="wazuh-indexer-$(cat VERSION)" @@ -246,6 +255,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" @@ -256,6 +266,7 @@ function assemble_rpm() { enable_performance_analyzer_rca ${src_path} # Swap configuration files add_configuration_files + remove_unneeded_files # Generate final package local topdir @@ -295,6 +306,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" @@ -306,6 +318,7 @@ function assemble_deb() { enable_performance_analyzer_rca ${src_path} # Swap configuration files add_configuration_files + remove_unneeded_files # Generate final package local version @@ -321,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" @@ -338,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}" From 4c96994bbc631e390623460fcbd6ceeab91511bc Mon Sep 17 00:00:00 2001 From: Federico Gustavo Galland <99492720+f-galland@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:17:17 -0300 Subject: [PATCH 3/5] Add missing tools and files back into Wazuh Indexer packages (#117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add remove files function to assemble.sh * Remove unneeded files on assembled tar packages * Remove duplicated function Fix wrong variable assignment * Adding function to package Wazuh`s tools to assemble.sh * Make the files' versions follow the repo's VERSION file * Fix download of Wazuh tools for packages assembly --------- Signed-off-by: Álex Ruiz Co-authored-by: Álex Ruiz --- scripts/assemble.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/assemble.sh b/scripts/assemble.sh index b64d987a72a04..9f25c304808b4 100755 --- a/scripts/assemble.sh +++ b/scripts/assemble.sh @@ -172,6 +172,21 @@ function remove_unneeded_files() { rm "$PATH_PLUGINS/opensearch-security/tools/install_demo_configuration.sh" } +# ==== +# Add additional tools into packages +# ==== +function add_wazuh_tools() { + local version + version=$( Date: Mon, 15 Jan 2024 14:48:27 -0300 Subject: [PATCH 4/5] Remove unneeded symbolic links from assembled packages (#121) --- distribution/packages/src/deb/debmake_install.sh | 4 ---- distribution/packages/src/rpm/wazuh-indexer.rpm.spec | 10 ++-------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/distribution/packages/src/deb/debmake_install.sh b/distribution/packages/src/deb/debmake_install.sh index d9368d50ea71f..3e0f4141c87d0 100644 --- a/distribution/packages/src/deb/debmake_install.sh +++ b/distribution/packages/src/deb/debmake_install.sh @@ -36,10 +36,6 @@ if [ -d "${buildroot}${product_dir}"/plugins/opensearch-security ]; then chmod -c 0755 "${buildroot}${product_dir}"/plugins/opensearch-security/tools/* fi -# Symlinks (do not symlink config dir as security demo installer has dependency, if no presense it will switch to rpm/deb mode) -ln -s ${data_dir} "${buildroot}${product_dir}/data" -ln -s ${log_dir} "${buildroot}${product_dir}/logs" - # Change Permissions chmod -Rf a+rX,u+w,g-w,o-w "${buildroot}"/* diff --git a/distribution/packages/src/rpm/wazuh-indexer.rpm.spec b/distribution/packages/src/rpm/wazuh-indexer.rpm.spec index c1f196577212a..28be42bbb9fc4 100644 --- a/distribution/packages/src/rpm/wazuh-indexer.rpm.spec +++ b/distribution/packages/src/rpm/wazuh-indexer.rpm.spec @@ -72,9 +72,7 @@ fi mkdir -p %{buildroot}%{config_dir}/opensearch-observability mkdir -p %{buildroot}%{config_dir}/opensearch-reports-scheduler mkdir -p %{buildroot}%{product_dir}/performance-analyzer-rca -# Symlinks (do not symlink config dir as security demo installer has dependency, if no presense it will switch to rpm/deb mode) -ln -s %{data_dir} %{buildroot}%{product_dir}/data -ln -s %{log_dir} %{buildroot}%{product_dir}/logs + # Pre-populate PA configs if not present if [ ! -f %{buildroot}%{data_dir}/rca_enabled.conf ]; then echo 'true' > %{buildroot}%{data_dir}/rca_enabled.conf @@ -204,10 +202,6 @@ exit 0 %{pid_dir} %dir %{data_dir} -# Symlinks -%{product_dir}/data -%{product_dir}/logs - # Wazuh additional files %attr(440, %{name}, %{name}) %{product_dir}/VERSION %attr(750, %{name}, %{name}) %{product_dir}/bin/indexer-security-init.sh @@ -271,4 +265,4 @@ exit 0 - More info: https://documentation.wazuh.com/current/release-notes/release-4-3-1.html * Thu May 05 2022 support - 4.3.0 - More info: https://documentation.wazuh.com/current/release-notes/release-4-3-0.html -- Initial package \ No newline at end of file +- Initial package From 3b4a1f5d45620879ef8840ce009560778c3d29cc Mon Sep 17 00:00:00 2001 From: Fede Tux Date: Tue, 16 Jan 2024 12:22:45 -0300 Subject: [PATCH 5/5] Remove reference to install_demo_configuration.sh --- distribution/packages/src/rpm/wazuh-indexer.rpm.spec | 4 ---- 1 file changed, 4 deletions(-) diff --git a/distribution/packages/src/rpm/wazuh-indexer.rpm.spec b/distribution/packages/src/rpm/wazuh-indexer.rpm.spec index 28be42bbb9fc4..ca1353142bee8 100644 --- a/distribution/packages/src/rpm/wazuh-indexer.rpm.spec +++ b/distribution/packages/src/rpm/wazuh-indexer.rpm.spec @@ -104,10 +104,6 @@ exit 0 %post set -e -# Apply Security Settings -if [ -d %{product_dir}/plugins/opensearch-security ]; then - sh %{product_dir}/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s > %{log_dir}/install_demo_configuration.log 2>&1 -fi chown -R %{name}.%{name} %{config_dir} chown -R %{name}.%{name} %{log_dir} # Apply PerformanceAnalyzer Settings