From 8c85381ffa2314399f0c33293ad282ce632bd789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Mon, 22 Jan 2024 16:32:48 +0100 Subject: [PATCH 1/2] Managed special dependencies for AL2023 --- unattended_installer/install_functions/checks.sh | 16 ++++++++++++++++ .../install_functions/installMain.sh | 8 ++++---- .../install_functions/installVariables.sh | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/unattended_installer/install_functions/checks.sh b/unattended_installer/install_functions/checks.sh index b7c3dcdb4f..a4c3df44a9 100644 --- a/unattended_installer/install_functions/checks.sh +++ b/unattended_installer/install_functions/checks.sh @@ -208,6 +208,10 @@ function check_dist() { fi if [ "${DIST_NAME}" == "amzn" ] && [ "${DIST_VER}" -ne "2" ]; then notsupported=1 + + if [ "${DIST_VER}" -eq "2023" ]; then + checks_specialDepsAL2023 + fi fi if [ "${DIST_NAME}" == "ubuntu" ]; then if [ "${DIST_VER}" == "16" ] || [ "${DIST_VER}" == "18" ] || @@ -338,6 +342,18 @@ function checks_previousCertificate() { fi } +# Manages the special dependencies in case of AL2023 +function checks_specialDepsAL2023() { + + # Change curl for curl-minimal + wia_yum_dependencies=( "${wia_yum_dependencies[@]/curl/curl-minimal}" ) + + # In containers, coreutils is replaced for coreutils-single + if [ -f "/.dockerenv" ]; then + wia_yum_dependencies=( "${wia_yum_dependencies[@]/coreutils/coreutils-single}" ) + fi +} + function checks_specifications() { cores=$(grep -c processor /proc/cpuinfo) diff --git a/unattended_installer/install_functions/installMain.sh b/unattended_installer/install_functions/installMain.sh index cd6f6bf6c6..93e0795868 100755 --- a/unattended_installer/install_functions/installMain.sh +++ b/unattended_installer/install_functions/installMain.sh @@ -224,16 +224,16 @@ function main() { common_checkSystem + if [ -z "${download}" ]; then + check_dist + fi + if [ -z "${uninstall}" ] && [ -z "${offline_install}" ]; then installCommon_installCheckDependencies elif [ -n "${offline_install}" ]; then offline_checkDependencies fi - if [ -z "${download}" ]; then - check_dist - fi - common_checkInstalled checks_arguments if [ -n "${uninstall}" ]; then diff --git a/unattended_installer/install_functions/installVariables.sh b/unattended_installer/install_functions/installVariables.sh index ef79da9371..a0f481ce49 100644 --- a/unattended_installer/install_functions/installVariables.sh +++ b/unattended_installer/install_functions/installVariables.sh @@ -56,7 +56,7 @@ wazuh_aio_ports=( 9200 9300 1514 1515 1516 55000 "${http_port}") readonly wazuh_indexer_ports=( 9200 9300 ) readonly wazuh_manager_ports=( 1514 1515 1516 55000 ) wazuh_dashboard_port="${http_port}" -readonly wia_yum_dependencies=( systemd grep tar coreutils sed procps-ng gawk lsof curl openssl ) +wia_yum_dependencies=( systemd grep tar coreutils sed procps-ng gawk lsof curl openssl ) readonly wia_apt_dependencies=( systemd grep tar coreutils sed procps gawk lsof curl openssl ) readonly wazuh_yum_dependencies=( libcap ) readonly wazuh_apt_dependencies=( apt-transport-https libcap2-bin software-properties-common gnupg ) From 7a7d90a057147a5eedf5eb63f5273d5d52d975fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Mon, 22 Jan 2024 17:28:44 +0100 Subject: [PATCH 2/2] Avoid removing systemd in WIA --- .../install_functions/installCommon.sh | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/unattended_installer/install_functions/installCommon.sh b/unattended_installer/install_functions/installCommon.sh index 7702b87844..62250751c2 100644 --- a/unattended_installer/install_functions/installCommon.sh +++ b/unattended_installer/install_functions/installCommon.sh @@ -812,14 +812,16 @@ function installCommon_yumRemoveWIADependencies(){ if [ "${#wia_dependencies_installed[@]}" -gt 0 ]; then common_logger "--- Dependencies ---" for dep in "${wia_dependencies_installed[@]}"; do - common_logger "Removing $dep." - yum_output=$(yum remove ${dep} -y 2>&1) - yum_code="${PIPESTATUS[0]}" - - eval "echo \${yum_output} ${debug}" - if [ "${yum_code}" != 0 ]; then - common_logger -e "Cannot remove dependency: ${dep}." - exit 1 + if [ "${dep}" != "systemd" ]; then + common_logger "Removing $dep." + yum_output=$(yum remove ${dep} -y 2>&1) + yum_code="${PIPESTATUS[0]}" + + eval "echo \${yum_output} ${debug}" + if [ "${yum_code}" != 0 ]; then + common_logger -e "Cannot remove dependency: ${dep}." + exit 1 + fi fi done fi @@ -831,14 +833,16 @@ function installCommon_aptRemoveWIADependencies(){ if [ "${#wia_dependencies_installed[@]}" -gt 0 ]; then common_logger "--- Dependencies ----" for dep in "${wia_dependencies_installed[@]}"; do - common_logger "Removing $dep." - apt_output=$(apt-get remove --purge ${dep} -y 2>&1) - apt_code="${PIPESTATUS[0]}" - - eval "echo \${apt_output} ${debug}" - if [ "${apt_code}" != 0 ]; then - common_logger -e "Cannot remove dependency: ${dep}." - exit 1 + if [ "${dep}" != "systemd" ]; then + common_logger "Removing $dep." + apt_output=$(apt-get remove --purge ${dep} -y 2>&1) + apt_code="${PIPESTATUS[0]}" + + eval "echo \${apt_output} ${debug}" + if [ "${apt_code}" != 0 ]; then + common_logger -e "Cannot remove dependency: ${dep}." + exit 1 + fi fi done fi