Skip to content

Commit 07668aa

Browse files
authored
Merge pull request #209 from wazuh/bug/202-wazuh-dashboard-shows-errors-in-4110-beta-1-ova
Fix Wazuh dashboard errors in OVA
2 parents f84fb3f + b15520c commit 07668aa

File tree

6 files changed

+165
-1
lines changed

6 files changed

+165
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
1616

1717
### Fixed
1818

19+
- Fix Wazuh dashboard errors in OVA. ([#209](https://github.com/wazuh/wazuh-virtual-machines/pull/209))
1920
- Fixed local build for OVA. ([#208](https://github.com/wazuh/wazuh-virtual-machines/pull/208))
2021
- Fixed Wazuh Dashboard issues when the AMI boots up. ([#205](https://github.com/wazuh/wazuh-virtual-machines/pull/205))
2122
- Fix Wazuh dashboard certificate verification failure ([#198](https://github.com/wazuh/wazuh-virtual-machines/pull/198))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Wazuh AMI Customizer Service - Used to customize the Wazuh AMI with custom certificates and passwords
2+
# Copyright (C) 2015, Wazuh Inc.
3+
#
4+
# This program is a free software; you can redistribute it
5+
# and/or modify it under the terms of the GNU General Public
6+
# License (version 2) as published by the FSF - Free Software
7+
# Foundation.
8+
#
9+
10+
[Unit]
11+
Description=Starts Wazuh services in order
12+
Wants=wazuh-starter.timer
13+
14+
[Service]
15+
Type=oneshot
16+
ExecStart=/etc/.wazuh-starter.sh
17+
18+
[Install]
19+
WantedBy=multi-user.target
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
# This script is used to configure the Wazuh environment after the installation
3+
4+
# Variables
5+
logfile="/var/log/wazuh-starter.log"
6+
debug="| tee -a ${logfile}"
7+
8+
###########################################
9+
# Utility Functions
10+
###########################################
11+
function logger(){
12+
now=$(date +'%d/%m/%Y %H:%M:%S')
13+
mtype="INFO:"
14+
if [ -n "${1}" ]; then
15+
while [ -n "${1}" ]; do
16+
case ${1} in
17+
"-e")
18+
mtype="ERROR:"
19+
shift 1
20+
;;
21+
"-w")
22+
mtype="WARNING:"
23+
shift 1
24+
;;
25+
*)
26+
message="${1}"
27+
shift 1
28+
;;
29+
esac
30+
done
31+
fi
32+
printf "%s\n" "${now} ${mtype} ${message}" | tee -a "${logfile}"
33+
}
34+
35+
36+
###########################################
37+
# Configuration Functions
38+
###########################################
39+
40+
function starter_service() {
41+
logger "Starting $1 service"
42+
systemctl start $1
43+
}
44+
45+
function verify_indexer() {
46+
logger "Waiting for Wazuh indexer to be ready"
47+
indexer_security_admin_comm="curl -XGET https://localhost:9200/ -uadmin:admin -k --max-time 120 --silent -w \"%{http_code}\" --output /dev/null"
48+
http_status=$(eval "${indexer_security_admin_comm}")
49+
retries=0
50+
max_retries=5
51+
while [ "${http_status}" -ne 200 ]; do
52+
logger -w "Wazuh indexer is not ready yet, waiting 5 seconds"
53+
sleep 5
54+
retries=$((retries+1))
55+
if [ "${retries}" -eq "${max_retries}" ]; then
56+
logger -e "Wazuh indexer is not ready yet, trying to configure it again"
57+
configure_indexer
58+
fi
59+
http_status=$(eval "${indexer_security_admin_comm}")
60+
done
61+
}
62+
63+
function verify_filebeat() {
64+
logger "Waiting for Filebeat to be ready"
65+
if filebeat test output | grep -q -i -w "ERROR"; then
66+
logger -e "Filebeat is not ready yet, trying to configure it again"
67+
eval "filebeat test output x ${debug}"
68+
configure_filebeat
69+
fi
70+
}
71+
72+
function verify_dashboard() {
73+
logger "Waiting for Wazuh dashboard to be ready"
74+
dashboard_check_comm="curl -XGET https://localhost:443/status -uadmin:admin -k -w \"%{http_code}\" -s -o /dev/null"
75+
http_code=$(eval "${dashboard_check_comm}")
76+
retries=0
77+
max_dashboard_initialize_retries=20
78+
while [ "${http_code}" -ne "200" ];do
79+
logger -w "Wazuh dashboard is not ready yet, waiting 15 seconds"
80+
retries=$((retries+1))
81+
sleep 15
82+
if [ "${retries}" -eq "${max_dashboard_initialize_retries}" ]; then
83+
logger -e "Wazuh dashboard is not ready yet, trying to configure it again"
84+
configure_dashboard
85+
fi
86+
http_code=$(eval "${dashboard_check_comm}")
87+
done
88+
}
89+
90+
function clean_configuration(){
91+
logger "Cleaning configuration files"
92+
eval "rm -rf /var/log/wazuh-starter.log"
93+
eval "rm -f /etc/.wazuh-starter.sh /etc/systemd/system/wazuh-starter.service /etc/systemd/system/wazuh-starter.timer"
94+
}
95+
96+
97+
###########################################
98+
# Main
99+
###########################################
100+
101+
logger "Starting Wazuh services in order"
102+
103+
104+
starter_service wazuh-indexer
105+
verify_indexer
106+
107+
starter_service wazuh-manager
108+
starter_service filebeat
109+
verify_filebeat
110+
111+
starter_service wazuh-dashboard
112+
verify_dashboard
113+
systemctl enable wazuh-manager
114+
systemctl enable wazuh-dashboard
115+
116+
clean_configuration
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Wazuh AMI Customizer Service - Used to customize the Wazuh AMI with custom certificates and passwords
2+
# Copyright (C) 2015, Wazuh Inc.
3+
#
4+
# This program is a free software; you can redistribute it
5+
# and/or modify it under the terms of the GNU General Public
6+
# License (version 2) as published by the FSF - Free Software
7+
# Foundation.
8+
#
9+
10+
[Unit]
11+
Description=Starts Wazuh services in order
12+
Requires=wazuh-starter.service
13+
14+
[Timer]
15+
Unit=wazuh-starter.service
16+
OnBootSec=10s
17+
18+
[Install]
19+
WantedBy=timers.target

ova/assets/steps.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ systemConfig() {
3434
systemctl daemon-reload
3535
systemctl enable updateIndexerHeap.service
3636

37+
# Add Wazuh starter service
38+
mv ${CUSTOM_PATH}/wazuh-starter/wazuh-starter.service /etc/systemd/system/
39+
mv ${CUSTOM_PATH}/wazuh-starter/wazuh-starter.timer /etc/systemd/system/
40+
mv ${CUSTOM_PATH}/wazuh-starter/wazuh-starter.sh /etc/.wazuh-starter.sh
41+
chmod 755 /etc/.wazuh-starter.sh
42+
systemctl daemon-reload
43+
systemctl enable wazuh-starter.timer
44+
systemctl enable wazuh-starter.service
3745

3846
# Change root password (root:wazuh)
3947
sed -i "s/root:.*:/root:\$1\$pNjjEA7K\$USjdNwjfh7A\.vHCf8suK41::0:99999:7:::/g" /etc/shadow

ova/provision.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ bash /usr/share/wazuh-indexer/bin/indexer-security-init.sh -ho 127.0.0.1
5656

5757
echo "Stopping Wazuh indexer and Wazuh dashboard"
5858
systemctl stop wazuh-indexer wazuh-dashboard
59-
systemctl enable wazuh-manager
59+
systemctl disable wazuh-manager
60+
systemctl disable wazuh-dashboard
6061

6162
echo "Cleaning system"
6263
clean

0 commit comments

Comments
 (0)