From 42738d82313ac631ef9b63728f47bcf46f9d32c7 Mon Sep 17 00:00:00 2001 From: c-bordon Date: Tue, 8 Oct 2024 08:48:57 -0300 Subject: [PATCH 1/4] Testing function check prerequisites --- install_functions/installMain.sh | 4 +- install_functions/installVariables.sh | 1 + .../wazuh-offline-installation.sh | 46 ++++++++----------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/install_functions/installMain.sh b/install_functions/installMain.sh index bc5a8a8..2f87eb1 100755 --- a/install_functions/installMain.sh +++ b/install_functions/installMain.sh @@ -123,7 +123,7 @@ function main() { bucket="packages-dev.wazuh.com" repository="${devrepo}" ;; - + "-fd"|"--force-install-dashboard") force=1 shift 1 @@ -257,7 +257,7 @@ function main() { if [ -z "${uninstall}" ] && [ -z "${offline_install}" ]; then installCommon_installCheckDependencies elif [ -n "${offline_install}" ]; then - offline_checkDependencies + offline_checkPrerequisites "${wia_offline_dependencies[@]}" "wia_offline_dependencies" fi common_checkInstalled diff --git a/install_functions/installVariables.sh b/install_functions/installVariables.sh index 2427ca4..2f1b7ab 100644 --- a/install_functions/installVariables.sh +++ b/install_functions/installVariables.sh @@ -72,4 +72,5 @@ readonly indexer_yum_dependencies=( coreutils ) readonly indexer_apt_dependencies=( debconf adduser procps gnupg apt-transport-https ) readonly dashboard_yum_dependencies=( libcap ) readonly dashboard_apt_dependencies=( debhelper tar curl libcap2-bin gnupg apt-transport-https ) +readonly wia_offline_dependencies=( curl tar gnupg openssl lsof ) wia_dependencies_installed=() diff --git a/install_functions/wazuh-offline-installation.sh b/install_functions/wazuh-offline-installation.sh index 5892202..eae4bf9 100644 --- a/install_functions/wazuh-offline-installation.sh +++ b/install_functions/wazuh-offline-installation.sh @@ -8,46 +8,36 @@ # License (version 2) as published by the FSF - Free Software # Foundation. -# Checks the necessary dependencies for the installation -function offline_checkDependencies() { - - dependencies=( curl tar gnupg openssl lsof ) - - common_logger "Checking installed dependencies for Offline installation." - for dep in "${dependencies[@]}"; do - if [ "${sys_type}" == "yum" ]; then - eval "yum list installed 2>/dev/null | grep -q -E ^"${dep}"\\." - elif [ "${sys_type}" == "apt-get" ]; then - eval "apt list --installed 2>/dev/null | grep -q -E ^"${dep}"\/" - fi - - if [ "${PIPESTATUS[0]}" != 0 ]; then - common_logger -e "${dep} is necessary for the offline installation." - exit 1 - fi - done - common_logger -d "Offline dependencies are installed." - -} - # Checks the necessary packages needed for a Wazuh component function offline_checkPrerequisites(){ - dependencies=("$@") - common_logger "Checking prerequisites for Offline installation." + dependencies=("${!1}") + dependency_type="${2}" + + if [ "${2}" == "wia_offline_dependencies"]; + then + common_logger "Checking dependencies for Wazuh installation assistant." + else + common_logger "Checking prerequisites for Offline installation." + fi for dep in "${dependencies[@]}"; do if [ "${sys_type}" == "yum" ]; then eval "yum list installed 2>/dev/null | grep -q -E ^"${dep}"\\." elif [ "${sys_type}" == "apt-get" ]; then eval "apt list --installed 2>/dev/null | grep -q -E ^"${dep}"\/" fi - + if [ "${PIPESTATUS[0]}" != 0 ]; then common_logger -e "${dep} is necessary for the offline installation." exit 1 fi done - common_logger -d "Offline prerequisites are installed." + if [ "${2}" == "wia_offline_dependencies"]; + then + common_logger -d "Dependencies for Wazuh installation assistant are installed." + else + common_logger -d "Prerequisites for Offline installation are installed." + fi } # Checks the necessary files for the installation @@ -85,7 +75,7 @@ function offline_extractFiles() { "${offline_files_path}/wazuh-filebeat-*.tar.gz" "${offline_files_path}/wazuh-template.json" ) - + if [ "${sys_type}" == "apt-get" ]; then required_files+=("${offline_packages_path}/filebeat-oss-*.deb" "${offline_packages_path}/wazuh-dashboard_*.deb" "${offline_packages_path}/wazuh-indexer_*.deb" "${offline_packages_path}/wazuh-manager_*.deb") elif [ "${sys_type}" == "rpm" ]; then @@ -120,5 +110,5 @@ function offline_importGPGKey() { fi eval "chmod 644 ${offline_files_path}/GPG-KEY-WAZUH ${debug}" fi - + } From 7b9b80d53e7ed497ddf482db1ffc0f11925ced83 Mon Sep 17 00:00:00 2001 From: Enrique Araque Date: Tue, 8 Oct 2024 19:08:26 +0200 Subject: [PATCH 2/4] Fix dependences variables values in offline install --- install_functions/installMain.sh | 2 +- install_functions/wazuh-offline-installation.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/install_functions/installMain.sh b/install_functions/installMain.sh index 2f87eb1..1e27b85 100755 --- a/install_functions/installMain.sh +++ b/install_functions/installMain.sh @@ -257,7 +257,7 @@ function main() { if [ -z "${uninstall}" ] && [ -z "${offline_install}" ]; then installCommon_installCheckDependencies elif [ -n "${offline_install}" ]; then - offline_checkPrerequisites "${wia_offline_dependencies[@]}" "wia_offline_dependencies" + offline_checkPrerequisites "wia_offline_dependencies" "${wia_offline_dependencies[@]}" fi common_checkInstalled diff --git a/install_functions/wazuh-offline-installation.sh b/install_functions/wazuh-offline-installation.sh index eae4bf9..aea9a0b 100644 --- a/install_functions/wazuh-offline-installation.sh +++ b/install_functions/wazuh-offline-installation.sh @@ -11,12 +11,14 @@ # Checks the necessary packages needed for a Wazuh component function offline_checkPrerequisites(){ - dependencies=("${!1}") - dependency_type="${2}" + dependencies=( "${@}" ) + if [ $1 == "wia_offline_dependencies" ]; then + dependencies=( "${@:2}" ) + fi - if [ "${2}" == "wia_offline_dependencies"]; - then + if [ $1 == "wia_offline_dependencies" ]; then common_logger "Checking dependencies for Wazuh installation assistant." + else common_logger "Checking prerequisites for Offline installation." fi @@ -32,8 +34,7 @@ function offline_checkPrerequisites(){ exit 1 fi done - if [ "${2}" == "wia_offline_dependencies"]; - then + if [ $1 == "wia_offline_dependencies" ]; then common_logger -d "Dependencies for Wazuh installation assistant are installed." else common_logger -d "Prerequisites for Offline installation are installed." From 65c96850c08965e7e585236648fd8840a0926caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Anguita=20L=C3=B3pez?= Date: Wed, 9 Oct 2024 11:49:18 +0200 Subject: [PATCH 3/4] unified ifs --- install_functions/wazuh-offline-installation.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/install_functions/wazuh-offline-installation.sh b/install_functions/wazuh-offline-installation.sh index aea9a0b..86457f0 100644 --- a/install_functions/wazuh-offline-installation.sh +++ b/install_functions/wazuh-offline-installation.sh @@ -14,14 +14,11 @@ function offline_checkPrerequisites(){ dependencies=( "${@}" ) if [ $1 == "wia_offline_dependencies" ]; then dependencies=( "${@:2}" ) - fi - - if [ $1 == "wia_offline_dependencies" ]; then common_logger "Checking dependencies for Wazuh installation assistant." - else common_logger "Checking prerequisites for Offline installation." fi + for dep in "${dependencies[@]}"; do if [ "${sys_type}" == "yum" ]; then eval "yum list installed 2>/dev/null | grep -q -E ^"${dep}"\\." From ef980f5fde268a9cfb84465b6289f087c39b2fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Anguita=20L=C3=B3pez?= Date: Wed, 9 Oct 2024 13:15:22 +0200 Subject: [PATCH 4/4] updated the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ddf7f4..3df7873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Changed +- Deleted the offline_checkDependencies function and unified logic in offline_checkPrerequisites function. ([#99](https://github.com/wazuh/wazuh-installation-assistant/pull/99)) - Create GHA workflow to build Wazuh Installation Assistant files. ([#77](https://github.com/wazuh/wazuh-installation-assistant/pull/77)) - Installation assistant distributed test rework and migration. ([#60](https://github.com/wazuh/wazuh-installation-assistant/pull/60)) - Installation assistant test and tier workflow migration ([#46](https://github.com/wazuh/wazuh-installation-assistant/pull/46/))