From 4f87247e614184a6f66af480fc6f54caeb9c2820 Mon Sep 17 00:00:00 2001 From: Tostti Date: Tue, 16 Apr 2024 13:30:47 -0300 Subject: [PATCH 01/12] Add debug information --- dev-tools/build-packages/base/generate_base.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 1580cf4d1d17..dace39c210ca 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -84,15 +84,21 @@ build() { clean 1 else echo "Extracting Wazuh Dashboard base" + echo "a" + ls -l . unzip -q wazuh-dashboard.zip -d ./dashboards/ rm wazuh-dashboard.zip mv ./dashboards/$(ls ./dashboards) wazuh-dashboard.tar.gz + echo "B" + ls -l . fi else if ! curl --output wazuh-dashboard.tar.gz --silent --fail "${base}"; then echo "The given URL or Path to the Wazuh Dashboard base is not working: ${base}" clean 1 fi + echo "D" + ls -l . fi else echo "The given URL or Path to the Wazuh Dashboard base is not valid: ${base}" @@ -117,9 +123,12 @@ build() { clean 1 fi + echo "c" + ls -l tar -zxf wazuh-dashboard.tar.gz directory_name=$(tar tf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) working_dir="wazuh-dashboard-$version-$revision-linux-x64" + echo $directory_name $working_dir mv $directory_name $working_dir cd $working_dir From 42f56cf1c55085cf108eb653f45905aca87c5f84 Mon Sep 17 00:00:00 2001 From: Tostti Date: Tue, 16 Apr 2024 15:23:09 -0300 Subject: [PATCH 02/12] Add more debug cases --- dev-tools/build-packages/base/generate_base.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index dace39c210ca..915294135864 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -125,8 +125,12 @@ build() { echo "c" ls -l + echo "Tar1" + tar -zxf wazuh-dashboard.tar.gz - directory_name=$(tar tf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) + + echo "Tar2" + directory_name=$(tar -tf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) working_dir="wazuh-dashboard-$version-$revision-linux-x64" echo $directory_name $working_dir mv $directory_name $working_dir From 623f2ff067f4a7e6ec0eda2e6db99b84198d279c Mon Sep 17 00:00:00 2001 From: Tostti Date: Tue, 16 Apr 2024 15:50:47 -0300 Subject: [PATCH 03/12] Add verbosity to failing tar --- dev-tools/build-packages/base/generate_base.sh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 915294135864..105c4c1fb7b5 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -84,21 +84,15 @@ build() { clean 1 else echo "Extracting Wazuh Dashboard base" - echo "a" - ls -l . unzip -q wazuh-dashboard.zip -d ./dashboards/ rm wazuh-dashboard.zip mv ./dashboards/$(ls ./dashboards) wazuh-dashboard.tar.gz - echo "B" - ls -l . fi else if ! curl --output wazuh-dashboard.tar.gz --silent --fail "${base}"; then echo "The given URL or Path to the Wazuh Dashboard base is not working: ${base}" clean 1 fi - echo "D" - ls -l . fi else echo "The given URL or Path to the Wazuh Dashboard base is not valid: ${base}" @@ -123,14 +117,10 @@ build() { clean 1 fi - echo "c" - ls -l - echo "Tar1" - tar -zxf wazuh-dashboard.tar.gz - - echo "Tar2" - directory_name=$(tar -tf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) + echo "a" $(tar -tf wazuh-dashboard.tar.gz) + echo "b" + directory_name=$(tar -tvf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) working_dir="wazuh-dashboard-$version-$revision-linux-x64" echo $directory_name $working_dir mv $directory_name $working_dir From 2673501129bd677fefe6d174ffb47f5303919761 Mon Sep 17 00:00:00 2001 From: Tostti Date: Tue, 16 Apr 2024 16:23:42 -0300 Subject: [PATCH 04/12] Try possible fix --- dev-tools/build-packages/base/generate_base.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 105c4c1fb7b5..7689edd7c8f2 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -118,11 +118,10 @@ build() { fi tar -zxf wazuh-dashboard.tar.gz - echo "a" $(tar -tf wazuh-dashboard.tar.gz) - echo "b" - directory_name=$(tar -tvf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) + a=$(tar -tzf wazuh-dashboard.tar.gz |head -1| sed 's#/.*##' | sort -u) + echo "A" $a + directory_name=$(tar -tzf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) working_dir="wazuh-dashboard-$version-$revision-linux-x64" - echo $directory_name $working_dir mv $directory_name $working_dir cd $working_dir From 36f557d9a38e0c58db3668863971811d767a8aca Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 08:47:31 -0300 Subject: [PATCH 05/12] Add workaround --- dev-tools/build-packages/base/generate_base.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 7689edd7c8f2..42c17ed0897d 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -118,9 +118,8 @@ build() { fi tar -zxf wazuh-dashboard.tar.gz - a=$(tar -tzf wazuh-dashboard.tar.gz |head -1| sed 's#/.*##' | sort -u) - echo "A" $a - directory_name=$(tar -tzf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) + tar -tzf wazuh-dashboard.tar.gz > gzContent + directory_name=$(head -1 gzContent | sed 's#/.*##' | sort -u) working_dir="wazuh-dashboard-$version-$revision-linux-x64" mv $directory_name $working_dir cd $working_dir From abe04c3db858a5cb5c5eb5bf2ed45599bca94806 Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 09:59:17 -0300 Subject: [PATCH 06/12] Add second workaround approach --- dev-tools/build-packages/base/generate_base.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 42c17ed0897d..8e78494c18bf 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -118,8 +118,7 @@ build() { fi tar -zxf wazuh-dashboard.tar.gz - tar -tzf wazuh-dashboard.tar.gz > gzContent - directory_name=$(head -1 gzContent | sed 's#/.*##' | sort -u) + directory_name=$(ls -t | head -1) working_dir="wazuh-dashboard-$version-$revision-linux-x64" mv $directory_name $working_dir cd $working_dir From 7ae6c74885a2e61b56cafe9dec0627d2c5d10577 Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 11:00:55 -0300 Subject: [PATCH 07/12] Apply working solution to all the failing places --- dev-tools/build-packages/deb/launcher.sh | 2 +- dev-tools/build-packages/rpm/launcher.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-tools/build-packages/deb/launcher.sh b/dev-tools/build-packages/deb/launcher.sh index 1ccc701f4f96..2eb463d1139e 100755 --- a/dev-tools/build-packages/deb/launcher.sh +++ b/dev-tools/build-packages/deb/launcher.sh @@ -81,8 +81,8 @@ build_deb() { echo # Prepare the package - directory_name=$(tar tf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) tar -zxf wazuh-dashboard.tar.gz + directory_name=$(ls -t | head -1) rm wazuh-dashboard.tar.gz mv $directory_name wazuh-dashboard-base jq '.wazuh.revision="'${revision}'"' wazuh-dashboard-base/package.json > pkgtmp.json && mv pkgtmp.json wazuh-dashboard-base/package.json diff --git a/dev-tools/build-packages/rpm/launcher.sh b/dev-tools/build-packages/rpm/launcher.sh index cc2996240461..0cd7fb16559e 100755 --- a/dev-tools/build-packages/rpm/launcher.sh +++ b/dev-tools/build-packages/rpm/launcher.sh @@ -82,8 +82,8 @@ build_rpm() { echo # Prepare the package - directory_name=$(tar tf wazuh-dashboard.tar.gz | head -1 | sed 's#/.*##' | sort -u) tar -zxf wazuh-dashboard.tar.gz + directory_name=$(ls -t | head -1) rm wazuh-dashboard.tar.gz mv $directory_name wazuh-dashboard-base jq '.wazuh.revision="'${revision}'"' wazuh-dashboard-base/package.json > pkgtmp.json && mv pkgtmp.json wazuh-dashboard-base/package.json From dfb5f745c76257e624c48c3656fe455f6f499a46 Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 11:23:57 -0300 Subject: [PATCH 08/12] Add error control to plugin installation --- .../build-packages/base/generate_base.sh | 23 ++++++++++--------- dev-tools/build-packages/base/plugins | 6 +++++ 2 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 dev-tools/build-packages/base/plugins diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 8e78494c18bf..8b60acb401fc 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -127,23 +127,24 @@ build() { echo Building the package... echo - # Install plugins - bin/opensearch-dashboards-plugin install alertingDashboards - bin/opensearch-dashboards-plugin install customImportMapDashboards - bin/opensearch-dashboards-plugin install ganttChartDashboards - bin/opensearch-dashboards-plugin install indexManagementDashboards - bin/opensearch-dashboards-plugin install notificationsDashboards - bin/opensearch-dashboards-plugin install reportsDashboards # Install Wazuh apps and Security app - plugins=$(ls $tmp_dir/applications) - echo $plugins + + plugins=$(ls $tmp_dir/applications)' '$(cat ../../plugins) for plugin in $plugins; do - echo $plugin if [[ $plugin =~ .*\.zip ]]; then - bin/opensearch-dashboards-plugin install file:../applications/$plugin + install='file:../applications/'$plugin + else + install=$plugin + fi + if bin/opensearch-dashboards-plugin install $install | tee /dev/tty | grep -iE 'unsuccessful|error|fail' > /dev/null; then + echo "Plugin installation failed" + clean 1 fi done + echo + echo Finished installing plugins + echo # Move installed plugins from categories after generating the package category_explore='{id:"explore",label:"Explore",order:100,euiIconType:"search"}' diff --git a/dev-tools/build-packages/base/plugins b/dev-tools/build-packages/base/plugins new file mode 100644 index 000000000000..6a31dc91f76b --- /dev/null +++ b/dev-tools/build-packages/base/plugins @@ -0,0 +1,6 @@ +alertingDashboards +customImportMapDashboards +ganttChartDashboards +indexManagementDashboards +notificationsDashboards +reportsDashboards From 18de71724972a94e4fd7d30b7b2d9f8b96e568fb Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 12:49:31 -0300 Subject: [PATCH 09/12] Change error control to be compatible with GH --- dev-tools/build-packages/base/generate_base.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 8b60acb401fc..e46fb543b0f5 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -136,7 +136,8 @@ build() { else install=$plugin fi - if bin/opensearch-dashboards-plugin install $install | tee /dev/tty | grep -iE 'unsuccessful|error|fail' > /dev/null; then + echo "Installing ${plugin%.*} plugin" + if bin/opensearch-dashboards-plugin install $install | grep -iE 'unsuccessful|error|fail'; then echo "Plugin installation failed" clean 1 fi From fb7fd5709a8acd544c71433f0c98ea887f9730c2 Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 13:28:06 -0300 Subject: [PATCH 10/12] Add break to for loop --- dev-tools/build-packages/base/generate_base.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index e46fb543b0f5..3a3daad85558 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -137,12 +137,16 @@ build() { install=$plugin fi echo "Installing ${plugin%.*} plugin" - if bin/opensearch-dashboards-plugin install $install | grep -iE 'unsuccessful|error|fail'; then + if bin/opensearch-dashboards-plugin install $install | grep -iE 'extract|unsuccessful|error|fail'; then echo "Plugin installation failed" - clean 1 + fail=1 + break fi done + if [[ $fail = 1 ]]; then + clean 1 + fi echo echo Finished installing plugins echo From c825c21f63d288b02d12e02543e1d8dba0bfb28c Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 15:20:09 -0300 Subject: [PATCH 11/12] Fix typo --- dev-tools/build-packages/base/generate_base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 3a3daad85558..97dbbed75c54 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -137,7 +137,7 @@ build() { install=$plugin fi echo "Installing ${plugin%.*} plugin" - if bin/opensearch-dashboards-plugin install $install | grep -iE 'extract|unsuccessful|error|fail'; then + if bin/opensearch-dashboards-plugin install $install | grep -ie 'unsuccessful|error|fail'; then echo "Plugin installation failed" fail=1 break From cb39a34307167c4ea909cb8232b65912404b9519 Mon Sep 17 00:00:00 2001 From: Tostti Date: Wed, 17 Apr 2024 16:24:19 -0300 Subject: [PATCH 12/12] Fix error handler --- dev-tools/build-packages/base/generate_base.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dev-tools/build-packages/base/generate_base.sh b/dev-tools/build-packages/base/generate_base.sh index 97dbbed75c54..20f1385638c3 100755 --- a/dev-tools/build-packages/base/generate_base.sh +++ b/dev-tools/build-packages/base/generate_base.sh @@ -137,16 +137,12 @@ build() { install=$plugin fi echo "Installing ${plugin%.*} plugin" - if bin/opensearch-dashboards-plugin install $install | grep -ie 'unsuccessful|error|fail'; then + if ! bin/opensearch-dashboards-plugin install $install 2>&1 > /dev/null; then echo "Plugin installation failed" - fail=1 - break + clean 1 fi done - if [[ $fail = 1 ]]; then - clean 1 - fi echo echo Finished installing plugins echo