diff --git a/unattended_installer/install_functions/filebeat.sh b/unattended_installer/install_functions/filebeat.sh index 57e5e24bd2..9fef47dda6 100644 --- a/unattended_installer/install_functions/filebeat.sh +++ b/unattended_installer/install_functions/filebeat.sh @@ -6,6 +6,19 @@ # License (version 2) as published by the FSF - Free Software # Foundation. +function filebeat_checkService() { + common_logger "Checking Filebeat connection" + + if filebeat test output | grep -q -i -w "ERROR"; then + common_logger -e "Filebeat connection Error." + eval "filebeat test output x ${debug}" + installCommon_rollBack + exit 1 + else + common_logger "Filebeat connection successful" + fi +} + function filebeat_configure(){ common_logger -d "Configuring Filebeat." diff --git a/unattended_installer/install_functions/installMain.sh b/unattended_installer/install_functions/installMain.sh index 7a809bf61b..07df2d21a3 100755 --- a/unattended_installer/install_functions/installMain.sh +++ b/unattended_installer/install_functions/installMain.sh @@ -368,10 +368,12 @@ function main() { manager_startCluster fi installCommon_startService "wazuh-manager" + manager_checkService filebeat_install filebeat_configure installCommon_changePasswords installCommon_startService "filebeat" + filebeat_checkService installCommon_removeWIADependencies fi @@ -388,9 +390,11 @@ function main() { manager_install manager_configure installCommon_startService "wazuh-manager" + manager_checkService filebeat_install filebeat_configure installCommon_startService "filebeat" + filebeat_checkService common_logger "--- Wazuh dashboard ---" dashboard_install dashboard_configure diff --git a/unattended_installer/install_functions/manager.sh b/unattended_installer/install_functions/manager.sh index 7ff35ffb3d..a33e564de2 100644 --- a/unattended_installer/install_functions/manager.sh +++ b/unattended_installer/install_functions/manager.sh @@ -42,6 +42,21 @@ function manager_startCluster() { } +function manager_checkService() { + common_logger "Checking Wazuh API connection" + eval "TOKEN=$(curl -k -s -X POST -u "wazuh-wui:wazuh-wui" https://127.0.0.1:55000/security/user/authenticate/run_as?raw=true -d '{"user_name":"wzread"}' -H "content-type:application/json")" + wm_error=$(curl -k -s -X GET "https://127.0.0.1:55000/agents/outdated?pretty=true" -H "Authorization: Bearer ${TOKEN}") + + if [[ ${wm_error,,} = '"error": 0' ]]; then + common_logger "Wazuh API connection successful" + else + common_logger -e "Wazuh API connection Error. $wm_error" + eval "/var/ossec/bin/wazuh-control status ${debug}" + installCommon_rollBack + exit 1 + fi +} + function manager_configure(){ common_logger -d "Configuring Wazuh manager."