Skip to content

Commit

Permalink
Fixed manager check in distributed deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcr01 committed Sep 11, 2024
1 parent 1dc9cb4 commit 6ea27ae
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions install_functions/manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,20 @@ function manager_startCluster() {

function manager_checkService() {
common_logger "Checking Wazuh API connection"
token_command="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\""
set -x
api_password="wazuh-wui"
token_command="curl -k -s -X POST -u \"wazuh-wui:${api_password}\" https://127.0.0.1:55000/security/user/authenticate/run_as?raw=true -d '{\"user_name\":\"wzread\"}' -H \"content-type:application/json\""
TOKEN=$(eval "${token_command}")
set +x
max_attempts=5

# Change curl credentials in case the master node has changed the passwords
if [[ "${TOKEN}" =~ "Invalid credentials" && "${server_node_types[pos]}" == "worker" ]]; then
api_password=$(tar -axf "${tar_file}" wazuh-install-files/wazuh-passwords.txt -O | grep -P "'wazuh-wui'" -A 1 | awk 'NR==2 { print $2 }' | sed "s/'//g")
token_command="curl -k -s -X POST -u \"wazuh-wui:${api_password}\" https://127.0.0.1:55000/security/user/authenticate/run_as?raw=true -d '{\"user_name\":\"wzread\"}' -H \"content-type:application/json\""
TOKEN=$(eval "${token_command}")
fi

max_attempts=15
attempt=0
seconds=3
seconds=5

while [[ -z "${TOKEN}" && "${attempt}" -lt "${max_attempts}" ]]; do
attempt=$((attempt+1))
Expand All @@ -77,6 +84,7 @@ function manager_checkService() {
fi
}


function manager_configure(){

common_logger -d "Configuring Wazuh manager."
Expand Down

0 comments on commit 6ea27ae

Please sign in to comment.