Skip to content

Commit

Permalink
Merge pull request #89 from wazuh/change/wazuh-packages-PR-3004
Browse files Browse the repository at this point in the history
Change apt to dpkg for better performance.
  • Loading branch information
c-bordon authored Sep 30, 2024
2 parents 4140447 + 7115212 commit 5fb2bec
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.

### Changed

- Change apt to dpkg for better performance. ([#89](https://github.com/wazuh/wazuh-installation-assistant/pull/89))
- Added check when generating certificates for multiple DNS. ([#88](https://github.com/wazuh/wazuh-installation-assistant/pull/88))
- Change cert-tool to use only one wazuh-certificates folder. ([#87](https://github.com/wazuh/wazuh-installation-assistant/pull/87))
- Solve bugs when changing passwords in the manager, indexer and dashboard services. ([#86](https://github.com/wazuh/wazuh-installation-assistant/pull/86))
Expand Down
18 changes: 13 additions & 5 deletions common_functions/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function common_checkRoot() {
fi

common_logger -d "Checking sudo package."
if ! command -v sudo > /dev/null; then
if ! command -v sudo > /dev/null; then
common_logger -e "The sudo package is not installed and it is necessary for the installation."
exit 1;
fi
Expand All @@ -91,7 +91,9 @@ function common_checkInstalled() {
if [ "${sys_type}" == "yum" ]; then
eval "rpm -q wazuh-manager --quiet && wazuh_installed=1"
elif [ "${sys_type}" == "apt-get" ]; then
wazuh_installed=$(apt list --installed 2>/dev/null | grep wazuh-manager)
if dpkg -l wazuh-manager 2>/dev/null | grep -q -E '^ii\s'; then
wazuh_installed=1
fi
fi

if [ -d "/var/ossec" ]; then
Expand All @@ -103,7 +105,9 @@ function common_checkInstalled() {
eval "rpm -q wazuh-indexer --quiet && indexer_installed=1"

elif [ "${sys_type}" == "apt-get" ]; then
indexer_installed=$(apt list --installed 2>/dev/null | grep wazuh-indexer)
if dpkg -l wazuh-indexer 2>/dev/null | grep -q -E '^ii\s'; then
indexer_installed=1
fi
fi

if [ -d "/var/lib/wazuh-indexer/" ] || [ -d "/usr/share/wazuh-indexer" ] || [ -d "/etc/wazuh-indexer" ] || [ -f "${base_path}/search-guard-tlstool*" ]; then
Expand All @@ -114,7 +118,9 @@ function common_checkInstalled() {
if [ "${sys_type}" == "yum" ]; then
eval "rpm -q filebeat --quiet && filebeat_installed=1"
elif [ "${sys_type}" == "apt-get" ]; then
filebeat_installed=$(apt list --installed 2>/dev/null | grep filebeat)
if dpkg -l filebeat 2>/dev/null | grep -q -E '^ii\s'; then
filebeat_installed=1
fi
fi

if [ -d "/var/lib/filebeat/" ] || [ -d "/usr/share/filebeat" ] || [ -d "/etc/filebeat" ]; then
Expand All @@ -125,7 +131,9 @@ function common_checkInstalled() {
if [ "${sys_type}" == "yum" ]; then
eval "rpm -q wazuh-dashboard --quiet && dashboard_installed=1"
elif [ "${sys_type}" == "apt-get" ]; then
dashboard_installed=$(apt list --installed 2>/dev/null | grep wazuh-dashboard)
if dpkg -l wazuh-dashboard 2>/dev/null | grep -q -E '^ii\s'; then
dashboard_installed=1
fi
fi

if [ -d "/var/lib/wazuh-dashboard/" ] || [ -d "/usr/share/wazuh-dashboard" ] || [ -d "/etc/wazuh-dashboard" ] || [ -d "/run/wazuh-dashboard/" ]; then
Expand Down
4 changes: 2 additions & 2 deletions install_functions/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ function checks_firewall(){
eval "rpm -q firewalld --quiet && firewalld_installed=1"
eval "rpm -q ufw --quiet && ufw_installed=1"
elif [ "${sys_type}" == "apt-get" ]; then
if apt list --installed 2>/dev/null | grep -q -E ^"firewalld"\/; then
if dpkg -l "firewalld" 2>/dev/null | grep -q -E '^ii\s'; then
firewalld_installed=1
fi
if apt list --installed 2>/dev/null | grep -q -E ^"ufw"\/; then
if dpkg -l "ufw" 2>/dev/null | grep -q -E '^ii\s'; then
ufw_installed=1
fi
fi
Expand Down
10 changes: 5 additions & 5 deletions install_functions/installCommon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function installCommon_aptInstallList(){
not_installed=()

for dep in "${dependencies[@]}"; do
if ! apt list --installed 2>/dev/null | grep -q -E ^"${dep}"\/; then
if ! dpkg -l "${dep}" 2>/dev/null | grep -q -E '^ii\s'; then
not_installed+=("${dep}")
for wia_dep in "${wia_apt_dependencies[@]}"; do
if [ "${wia_dep}" == "${dep}" ]; then
Expand Down Expand Up @@ -631,7 +631,7 @@ function installCommon_rollBack() {
elif [ "${sys_type}" == "apt-get" ]; then
common_checkAptLock
eval "apt-get remove --purge wazuh-manager -y ${debug}"
manager_installed=$(apt list --installed 2>/dev/null | grep wazuh-manager)
manager_installed=$(dpkg -l wazuh-manager 2>/dev/null | grep -E '^ii\s')
fi

if [ -n "${manager_installed}" ]; then
Expand All @@ -657,7 +657,7 @@ function installCommon_rollBack() {
elif [ "${sys_type}" == "apt-get" ]; then
common_checkAptLock
eval "apt-get remove --purge wazuh-indexer -y ${debug}"
indexer_installed=$(apt list --installed 2>/dev/null | grep wazuh-indexer)
indexer_installed=$(dpkg -l wazuh-indexer 2>/dev/null | grep -E '^ii\s')
fi

if [ -n "${indexer_installed}" ]; then
Expand All @@ -684,7 +684,7 @@ function installCommon_rollBack() {
elif [ "${sys_type}" == "apt-get" ]; then
common_checkAptLock
eval "apt-get remove --purge filebeat -y ${debug}"
filebeat_installed=$(apt list --installed 2>/dev/null | grep filebeat)
filebeat_installed=$(dpkg -l filebeat 2>/dev/null | grep -E '^ii\s')
fi

if [ -n "${filebeat_installed}" ]; then
Expand All @@ -711,7 +711,7 @@ function installCommon_rollBack() {
elif [ "${sys_type}" == "apt-get" ]; then
common_checkAptLock
eval "apt-get remove --purge wazuh-dashboard -y ${debug}"
dashboard_installed=$(apt list --installed 2>/dev/null | grep wazuh-dashboard)
dashboard_installed=$(dpkg -l wazuh-dashboard 2>/dev/null | grep -E '^ii\s')
fi

if [ -n "${dashboard_installed}" ]; then
Expand Down
10 changes: 5 additions & 5 deletions install_functions/wazuh-offline-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function offline_checkDependencies() {
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}"\/"
eval "dpkg -l "${dep}" 2>/dev/null | grep -q -E '^ii\s'"
fi

if [ "${PIPESTATUS[0]}" != 0 ]; then
common_logger -e "${dep} is necessary for the offline installation."
exit 1
Expand All @@ -39,9 +39,9 @@ function offline_checkPrerequisites(){
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}"\/"
eval "dpkg -l "${dep}" 2>/dev/null | grep -q -E '^ii\s'"
fi

if [ "${PIPESTATUS[0]}" != 0 ]; then
common_logger -e "${dep} is necessary for the offline installation."
exit 1
Expand Down Expand Up @@ -85,7 +85,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
Expand Down

0 comments on commit 5fb2bec

Please sign in to comment.