From b8207874a9f1ebbf70515fb89a963bd6349b7a8e Mon Sep 17 00:00:00 2001 From: Federico Gustavo Galland <99492720+f-galland@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:19:55 -0300 Subject: [PATCH] Use maven for plugin download (#139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fine tuning permissions on RPM spec file * Get plugins using maven * Rolling back changes to spec file * Format files --------- Co-authored-by: Álex Ruiz --- docker/ci/images/Dockerfile | 2 +- docker/dev/images/Dockerfile | 1 + scripts/assemble.sh | 56 ++++++++++++++++++------------------ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/docker/ci/images/Dockerfile b/docker/ci/images/Dockerfile index c84791adcb3e5..8704d1a25d83b 100644 --- a/docker/ci/images/Dockerfile +++ b/docker/ci/images/Dockerfile @@ -6,7 +6,7 @@ RUN mkdir /home/wazuh-indexer && \ echo "deb http://repo.aptly.info/ squeeze main" | tee -a /etc/apt/sources.list.d/aptly.list && \ apt-get update -y && \ apt-get upgrade -y && \ - apt-get install -y aptly build-essential cpio debhelper-compat debmake freeglut3 libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-dev libcairo2 libcairo2-dev libcups2 libdrm2 libgbm-dev libgconf-2-4 libnspr4 libnspr4-dev libnss3 libpangocairo-1.0-0 libxcomposite-dev libxdamage1 libxfixes-dev libxfixes3 libxi6 libxkbcommon-x11-0 libxrandr2 libxrender1 libxtst6 rpm rpm2cpio && \ + apt-get install -y aptly build-essential cpio debhelper-compat debmake freeglut3 libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-dev libcairo2 libcairo2-dev libcups2 libdrm2 libgbm-dev libgconf-2-4 libnspr4 libnspr4-dev libnss3 libpangocairo-1.0-0 libxcomposite-dev libxdamage1 libxfixes-dev libxfixes3 libxi6 libxkbcommon-x11-0 libxrandr2 libxrender1 libxtst6 rpm rpm2cpio maven && \ apt-get clean -y && \ dpkg -r lintian && \ addgroup --gid 1000 wazuh-indexer && \ diff --git a/docker/dev/images/Dockerfile b/docker/dev/images/Dockerfile index f49aa4b1aba6e..111f661b8e225 100644 --- a/docker/dev/images/Dockerfile +++ b/docker/dev/images/Dockerfile @@ -7,6 +7,7 @@ RUN gradle clean FROM eclipse-temurin:17-jdk-alpine RUN apk add git && \ + apk add curl && \ addgroup -g 1000 wazuh-indexer && \ adduser -u 1000 -G wazuh-indexer -D -h /home/wazuh-indexer wazuh-indexer && \ chmod 0775 /home/wazuh-indexer && \ diff --git a/scripts/assemble.sh b/scripts/assemble.sh index c2d419f299ff8..acadc71f2a5bf 100755 --- a/scripts/assemble.sh +++ b/scripts/assemble.sh @@ -14,33 +14,32 @@ set -ex TEST=${TEST:-false} -if ( $TEST ) -then - plugins=( - "performance-analyzer" - "opensearch-security" - ) +if ($TEST); then + plugins=( + "performance-analyzer" + "opensearch-security" + ) else - plugins=( - "alerting" # "opensearch-alerting" - "opensearch-job-scheduler" - "opensearch-anomaly-detection" # Requires "opensearch-job-scheduler" - "asynchronous-search" # "opensearch-asynchronous-search" - "opensearch-cross-cluster-replication" - "geospatial" # "opensearch-geospatial" - "opensearch-index-management" - "opensearch-knn" - "opensearch-ml-plugin" # "opensearch-ml" - "neural-search" # "opensearch-neural-search" - "opensearch-notifications-core" - "notifications" # "opensearch-notifications". Requires "opensearch-notifications-core" - "opensearch-observability" - "performance-analyzer" # "opensearch-performance-analyzer" - "opensearch-reports-scheduler" - "opensearch-security" - "opensearch-security-analytics" - "opensearch-sql-plugin" # "opensearch-sql" - ) + plugins=( + "alerting" # "opensearch-alerting" + "opensearch-job-scheduler" + "opensearch-anomaly-detection" # Requires "opensearch-job-scheduler" + "asynchronous-search" # "opensearch-asynchronous-search" + "opensearch-cross-cluster-replication" + "geospatial" # "opensearch-geospatial" + "opensearch-index-management" + "opensearch-knn" + "opensearch-ml-plugin" # "opensearch-ml" + "neural-search" # "opensearch-neural-search" + "opensearch-notifications-core" + "notifications" # "opensearch-notifications". Requires "opensearch-notifications-core" + "opensearch-observability" + "performance-analyzer" # "opensearch-performance-analyzer" + "opensearch-reports-scheduler" + "opensearch-security" + "opensearch-security-analytics" + "opensearch-sql-plugin" # "opensearch-sql" + ) fi # ==== @@ -214,11 +213,12 @@ function enable_performance_analyzer_rca() { # Install plugins # ==== function install_plugins() { - # Install plugins from Maven repository echo "Install plugins" + maven_repo_local="$HOME/maven" for plugin in "${plugins[@]}"; do plugin_from_maven="org.opensearch.plugin:${plugin}:$VERSION.0" - OPENSEARCH_PATH_CONF=$PATH_CONF "${PATH_BIN}/opensearch-plugin" install --batch --verbose "${plugin_from_maven}" + mvn -Dmaven.repo.local=$maven_repo_local org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=https://repo1.maven.org/maven2 -Dartifact=$plugin_from_maven:zip + OPENSEARCH_PATH_CONF=$PATH_CONF "${PATH_BIN}/opensearch-plugin" install --batch --verbose "file:${maven_repo_local}/org/opensearch/plugin/${plugin}/$VERSION.0/${plugin}-$VERSION.0.zip" done }