From 54683715ff751bea28f809aefa2b312db4d06970 Mon Sep 17 00:00:00 2001 From: Fede Tux <federico.galland@wazuh.com> Date: Tue, 21 May 2024 12:00:06 -0300 Subject: [PATCH] Add OPENSEARCH_TMPDIR variable to service and create directory in packages accordingly --- .../packages/src/common/systemd/wazuh-indexer.service | 1 + distribution/packages/src/deb/debian/postinst | 5 +++++ distribution/packages/src/rpm/wazuh-indexer.rpm.spec | 2 ++ docker/ci/ci.yml | 3 ++- packaging_scripts/upstream_version.sh | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/distribution/packages/src/common/systemd/wazuh-indexer.service b/distribution/packages/src/common/systemd/wazuh-indexer.service index 130f22472d2e4..093890ac0e79c 100644 --- a/distribution/packages/src/common/systemd/wazuh-indexer.service +++ b/distribution/packages/src/common/systemd/wazuh-indexer.service @@ -9,6 +9,7 @@ Type=notify RuntimeDirectory=wazuh-indexer PrivateTmp=true Environment=OPENSEARCH_HOME=/usr/share/wazuh-indexer +Environment=OPENSEARCH_TMPDIR=/var/log/wazuh-indexer/tmp Environment=OPENSEARCH_PATH_CONF=${path.conf} Environment=PID_DIR=/run/wazuh-indexer Environment=OPENSEARCH_SD_NOTIFY=true diff --git a/distribution/packages/src/deb/debian/postinst b/distribution/packages/src/deb/debian/postinst index da4cbf62be703..235075824aa45 100644 --- a/distribution/packages/src/deb/debian/postinst +++ b/distribution/packages/src/deb/debian/postinst @@ -18,14 +18,19 @@ config_dir=/etc/wazuh-indexer data_dir=/var/lib/wazuh-indexer log_dir=/var/log/wazuh-indexer pid_dir=/var/run/wazuh-indexer +tmp_dir=/var/log/wazuh-indexer/tmp +# Create needed directories +mkdir -p ${tmp_dir} + # Set owner chown -R wazuh-indexer.wazuh-indexer ${product_dir} chown -R wazuh-indexer.wazuh-indexer ${config_dir} chown -R wazuh-indexer.wazuh-indexer ${log_dir} chown -R wazuh-indexer.wazuh-indexer ${data_dir} chown -R wazuh-indexer.wazuh-indexer ${pid_dir} +chown -R wazuh-indexer.wazuh-indexer ${tmp_dir} # Reload systemctl daemon if command -v systemctl > /dev/null; then diff --git a/distribution/packages/src/rpm/wazuh-indexer.rpm.spec b/distribution/packages/src/rpm/wazuh-indexer.rpm.spec index c7516f539a6e2..15f33988385c7 100644 --- a/distribution/packages/src/rpm/wazuh-indexer.rpm.spec +++ b/distribution/packages/src/rpm/wazuh-indexer.rpm.spec @@ -27,6 +27,7 @@ %define data_dir %{_sharedstatedir}/%{name} %define log_dir %{_localstatedir}/log/%{name} %define pid_dir %{_localstatedir}/run/%{name} +%define tmp_dir %{log_dir}/tmp %{!?_version: %define _version 0.0.0 } %{!?_architecture: %define _architecture x86_64 } @@ -65,6 +66,7 @@ cd %{_topdir} && pwd # Create necessary directories mkdir -p %{buildroot}%{pid_dir} mkdir -p %{buildroot}%{product_dir}/plugins +mkdir -p %{buildroot}%{tmp_dir} # Install directories/files cp -a etc usr var %{buildroot} diff --git a/docker/ci/ci.yml b/docker/ci/ci.yml index a18ca915302f0..11a05b79a5c18 100644 --- a/docker/ci/ci.yml +++ b/docker/ci/ci.yml @@ -21,9 +21,10 @@ services: context: ./../.. dockerfile: ${REPO_PATH}/docker/ci/images/Dockerfile volumes: - - ${REPO_PATH}/scripts:/home/wazuh-indexer/scripts + - ${REPO_PATH}/packaging_scripts:/home/wazuh-indexer/packaging_scripts - ${REPO_PATH}/artifacts:/home/wazuh-indexer/artifacts - ${REPO_PATH}/distribution/packages/src:/home/wazuh-indexer/distribution/packages/src + - ${REPO_PATH}/buildSrc:/home/wazuh-indexer/buildSrc entrypoint: ["tail", "-f", "/dev/null"] user: "1000:1000" working_dir: /home/wazuh-indexer diff --git a/packaging_scripts/upstream_version.sh b/packaging_scripts/upstream_version.sh index 424165b9e53b9..63b6cce9a421d 100644 --- a/packaging_scripts/upstream_version.sh +++ b/packaging_scripts/upstream_version.sh @@ -3,4 +3,4 @@ set -e -< buildSrc/version.properties grep opensearch | grep -Eo '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}' \ No newline at end of file +< buildSrc/version.properties grep opensearch | grep -Eo '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}'