Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change health check call in AIO unify #1043

Merged
merged 9 commits into from
Dec 9, 2021
7 changes: 7 additions & 0 deletions unattended_scripts/install_functions/opendistro/common.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Copyright (C) 2015-2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

repogpg="https://packages.wazuh.com/key/GPG-KEY-WAZUH"
repobaseurl="https://packages.wazuh.com/4.x"

Expand Down
11 changes: 9 additions & 2 deletions unattended_scripts/install_functions/opendistro/elasticsearch.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# Copyright (C) 2015-2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

installElasticsearch() {

logger "Installing Open Distro for Elasticsearch..."

if [ ${sys_type} == "yum" ]; then
eval "yum install opendistroforelasticsearch-${OD_VER}-${OD_REV} -y ${debug}"
eval "yum install opendistroforelasticsearch-${opendistro_version}-${opendistro_revision} -y ${debug}"
elif [ ${sys_type} == "zypper" ]; then
eval "zypper -n install opendistroforelasticsearch=${OD_VER}-${OD_REV} ${debug}"
eval "zypper -n install opendistroforelasticsearch=${opendistro_version}-${opendistro_revision} ${debug}"
elif [ ${sys_type} == "apt-get" ]; then
eval "apt install elasticsearch-oss opendistroforelasticsearch -y ${debug}"
fi
Expand Down
11 changes: 9 additions & 2 deletions unattended_scripts/install_functions/opendistro/filebeat.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Copyright (C) 2015-2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

installFilebeat() {

if [[ -f /etc/filebeat/filebeat.yml ]]; then
Expand All @@ -8,9 +15,9 @@ installFilebeat() {
logger "Installing Filebeat..."

if [ ${sys_type} == "zypper" ]; then
eval "zypper -n install filebeat-${ELK_VER} ${debug}"
eval "zypper -n install filebeat-${elastic_oss_version} ${debug}"
else
eval "${sys_type} install filebeat${sep}${ELK_VER} -y -q ${debug}"
eval "${sys_type} install filebeat${sep}${elastic_oss_version} -y -q ${debug}"
fi
if [ "$?" != 0 ]
then
Expand Down
15 changes: 11 additions & 4 deletions unattended_scripts/install_functions/opendistro/kibana.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Copyright (C) 2015-2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

installKibana() {

logger "Installing Open Distro for Kibana..."
if [ ${sys_type} == "zypper" ]; then
eval "zypper -n install opendistroforelasticsearch-kibana=${OD_VER} ${debug}"
eval "zypper -n install opendistroforelasticsearch-kibana=${opendistro_version} ${debug}"
else
eval "${sys_type} install opendistroforelasticsearch-kibana${sep}${OD_VER} -y ${debug}"
eval "${sys_type} install opendistroforelasticsearch-kibana${sep}${opendistro_version} -y ${debug}"
fi
if [ "$?" != 0 ]; then
logger -e "Kibana installation failed"
Expand All @@ -22,7 +29,7 @@ configureKibanaAIO() {
eval "mkdir /usr/share/kibana/data ${debug}"
eval "chown -R kibana:kibana /usr/share/kibana/ ${debug}"
eval "cd /usr/share/kibana ${debug}"
eval "sudo -u kibana /usr/share/kibana/bin/kibana-plugin install '${repobaseurl}'/ui/kibana/wazuh_kibana-${WAZUH_VER}_${ELK_VER}-${WAZUH_KIB_PLUG_REV}.zip ${debug}"
eval "sudo -u kibana /usr/share/kibana/bin/kibana-plugin install '${repobaseurl}'/ui/kibana/wazuh_kibana-${wazuh_version}_${elastic_oss_version}-${wazuh_kibana_plugin_revision}.zip ${debug}"
eval "cd ${base_path} ${debug}"
if [ "$?" != 0 ]; then
logger -e "Wazuh Kibana plugin could not be installed."
Expand All @@ -46,7 +53,7 @@ configureKibana() {
eval "mkdir /usr/share/kibana/data ${debug}"
eval "chown -R kibana:kibana /usr/share/kibana/ ${debug}"
eval "cd /usr/share/kibana ${debug}"
eval "sudo -u kibana /usr/share/kibana/bin/kibana-plugin install '${repobaseurl}'/ui/kibana/wazuh_kibana-${WAZUH_VER}_${ELK_VER}-${WAZUH_KIB_PLUG_REV}.zip ${debug}"
eval "sudo -u kibana /usr/share/kibana/bin/kibana-plugin install '${repobaseurl}'/ui/kibana/wazuh_kibana-${wazuh_version}_${elastic_oss_version}-${wazuh_kibana_plugin_revision}.zip ${debug}"
if [ "$?" != 0 ]; then
logger -e "Wazuh Kibana plugin could not be installed."
exit 1;
Expand Down
96 changes: 51 additions & 45 deletions unattended_scripts/install_functions/opendistro/wazuh-cert-tool.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash

# Program to generate the certificates necessary for Wazuh installation
# Copyright (C) 2015-2020, Wazuh Inc.
# Copyright (C) 2015-2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

debug='> /dev/null 2>&1'
ELASTICINSTANCES="elasticsearch-nodes:"
FILEBEATINSTANCES="wazuh-servers:"
KIBANAINSTANCES="kibana:"
ELASTICHEAD='# Elasticsearch nodes'
FILEBEATHEAD='# Wazuh server nodes'
KIBANAHEAD='# Kibana node'
elasticinstances="elasticsearch-nodes:"
filebeatinstances="wazuh-servers:"
kibanainstances="kibana:"
elastichead='# Elasticsearch nodes'
filebeathead='# Wazuh server nodes'
kibanahead='# Kibana node'

## Prints information
logger() {
Expand Down Expand Up @@ -53,69 +53,75 @@ readInstances() {

getHelp() {
echo ""
echo "Usage: $0 arguments"
echo -e "\t-a | --admin-certificates Creates the admin certificates."
echo -e "\t-ca | --root-ca-certificates Creates the root-ca certificates."
echo -e "\t-a | --elasticsearch-certificates Creates the Elasticsearch certificates."
echo -e "\t-w | --wazuh-certificates Creates the Wazuh server certificates."
echo -e "\t-k | --kibana-certificates Creates the Kibana certificates."
echo -e "\t-d | --debug Enables verbose mode."
echo "Usage: $0 options"
echo -e " -a, --admin-certificates"
echo -e " Creates the admin certificates."
echo -e " -ca, --root-ca-certificates"
echo -e " Creates the root-ca certificates."
echo -e " -e, --elasticsearch-certificates"
echo -e " Creates the Elasticsearch certificates."
echo -e " -w, --wazuh-certificates"
echo -e " Creates the Wazuh server certificates."
echo -e " -k, --kibana-certificates"
echo -e " Creates the Kibana certificates."
echo -e " -d, --debug"
echo -e " Enables verbose mode."
exit 1 # Exit script after printing help
}

readFile() {

IFS=$'\r\n' GLOBIGNORE='*' command eval 'INSTANCES=($(cat ${base_path}/instances.yml))'
for i in "${!INSTANCES[@]}"; do
if [[ "${INSTANCES[$i]}" == "${ELASTICINSTANCES}" ]]; then
ELASTICLIMITT=${i}
IFS=$'\r\n' GLOBIGNORE='*' command eval 'instances=($(cat ${base_path}/instances.yml))'
for i in "${!instances[@]}"; do
if [[ "${instances[$i]}" == "${elasticinstances}" ]]; then
elasticlimitt=${i}
fi
if [[ "${INSTANCES[$i]}" == "${FILEBEATINSTANCES}" ]]; then
ELASTICLIMIB=${i}
if [[ "${instances[$i]}" == "${filebeatinstances}" ]]; then
elasticlimib=${i}
fi

if [[ "${INSTANCES[$i]}" == "${FILEBEATINSTANCES}" ]]; then
FILEBEATLIMITT=${i}
if [[ "${instances[$i]}" == "${filebeatinstances}" ]]; then
filebeatlimitt=${i}
fi

if [[ "${INSTANCES[$i]}" == "${KIBANAINSTANCES}" ]]; then
FILEBEATLIMIB=${i}
if [[ "${instances[$i]}" == "${kibanainstances}" ]]; then
filebeatlimib=${i}
fi
done

## Read Elasticsearch nodes
counter=${ELASTICLIMITT}
counter=${elasticlimitt}
i=0
while [ "${counter}" -le "${ELASTICLIMIB}" ]
while [ "${counter}" -le "${elasticlimib}" ]
do
if [ "${INSTANCES[counter]}" != "${ELASTICINSTANCES}" ] && [ "${INSTANCES[counter]}" != "${FILEBEATINSTANCES}" ] && [ "${INSTANCES[counter]}" != "${FILEBEATHEAD}" ] && [ "${INSTANCES[counter]}" != " ip:" ] && [ -n "${INSTANCES[counter]}" ]; then
ELASTICNODES[i]+="$(echo "${INSTANCES[counter]}" | tr -d '\011\012\013\014\015\040')"
if [ "${instances[counter]}" != "${elasticinstances}" ] && [ "${instances[counter]}" != "${filebeatinstances}" ] && [ "${instances[counter]}" != "${filebeathead}" ] && [ "${instances[counter]}" != " ip:" ] && [ -n "${instances[counter]}" ]; then
elasticnodes[i]+="$(echo "${instances[counter]}" | tr -d '\011\012\013\014\015\040')"
((i++))
fi

((counter++))
done

## Read Filebeat nodes
counter=${FILEBEATLIMITT}
counter=${filebeatlimitt}
i=0
while [ "${counter}" -le "${FILEBEATLIMIB}" ]
while [ "${counter}" -le "${filebeatlimib}" ]
do
if [ "${INSTANCES[counter]}" != "${FILEBEATINSTANCES}" ] && [ "${INSTANCES[counter]}" != "${KIBANAINSTANCES}" ] && [ "${INSTANCES[counter]}" != "${KIBANAHEAD}" ] && [ "${INSTANCES[counter]}" != " ip:" ] && [ -n "${INSTANCES[counter]}" ]; then
FILEBEATNODES[i]+="$(echo "${INSTANCES[counter]}" | tr -d '\011\012\013\014\015\040')"
if [ "${instances[counter]}" != "${filebeatinstances}" ] && [ "${instances[counter]}" != "${kibanainstances}" ] && [ "${instances[counter]}" != "${kibanahead}" ] && [ "${instances[counter]}" != " ip:" ] && [ -n "${instances[counter]}" ]; then
filebeatnodes[i]+="$(echo "${instances[counter]}" | tr -d '\011\012\013\014\015\040')"
((i++))
fi

((counter++))
done

## Read Kibana nodes
counter=${FILEBEATLIMIB}
counter=${filebeatlimib}
i=0
while [ "${counter}" -le "${#INSTANCES[@]}" ]
while [ "${counter}" -le "${#instances[@]}" ]
do
if [ "${INSTANCES[counter]}" != "${KIBANAINSTANCES}" ] && [ "${INSTANCES[counter]}" != "${KIBANAHEAD}" ] && [ "${INSTANCES[counter]}" != " ip:" ] && [ -n "${INSTANCES[counter]}" ]; then
KIBANANODES[i]+="$(echo "${INSTANCES[counter]}" | tr -d '\011\012\013\014\015\040')"
if [ "${instances[counter]}" != "${kibanainstances}" ] && [ "${instances[counter]}" != "${kibanahead}" ] && [ "${instances[counter]}" != " ip:" ] && [ -n "${instances[counter]}" ]; then
kibananodes[i]+="$(echo "${instances[counter]}" | tr -d '\011\012\013\014\015\040')"
((i++))
fi

Expand Down Expand Up @@ -193,9 +199,9 @@ generateElasticsearchcertificates() {
logger "Creating the Elasticsearch certificates..."

i=0
while [ ${i} -lt ${#ELASTICNODES[@]} ]; do
cname=${ELASTICNODES[i]}
cip=${ELASTICNODES[i+1]}
while [ ${i} -lt ${#elasticnodes[@]} ]; do
cname=${elasticnodes[i]}
cip=${elasticnodes[i+1]}
rname="-name:"
cname="${cname//$rname}"
rip="-"
Expand All @@ -217,9 +223,9 @@ generateFilebeatcertificates() {
logger "Creating Wazuh server certificates..."

i=0
while [ ${i} -lt ${#FILEBEATNODES[@]} ]; do
cname=${FILEBEATNODES[i]}
cip=${FILEBEATNODES[i+1]}
while [ ${i} -lt ${#filebeatnodes[@]} ]; do
cname=${filebeatnodes[i]}
cip=${filebeatnodes[i+1]}
rname="-name:"
cname="${cname//$rname}"
rip="-"
Expand All @@ -240,9 +246,9 @@ generateKibanacertificates() {
logger "Creating Kibana certificate..."

i=0
while [ ${i} -lt ${#KIBANANODES[@]} ]; do
cname=${KIBANANODES[i]}
cip=${KIBANANODES[i+1]}
while [ ${i} -lt ${#kibananodes[@]} ]; do
cname=${kibananodes[i]}
cip=${kibananodes[i+1]}
rname="-name:"
cname="${cname//$rname}"
rip="-"
Expand Down
11 changes: 9 additions & 2 deletions unattended_scripts/install_functions/opendistro/wazuh.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Copyright (C) 2015-2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.

installWazuh() {

logger "Installing the Wazuh manager..."
if [ ${sys_type} == "zypper" ]; then
eval "zypper -n install wazuh-manager=${WAZUH_VER}-${WAZUH_REV} ${debug}"
eval "zypper -n install wazuh-manager=${wazuh_version}-${wazuh_revision} ${debug}"
else
eval "${sys_type} install wazuh-manager${sep}${WAZUH_VER}-${WAZUH_REV} -y ${debug}"
eval "${sys_type} install wazuh-manager${sep}${wazuh_version}-${wazuh_revision} -y ${debug}"
fi
if [ "$?" != 0 ]; then
logger -e "Wazuh installation failed"
Expand Down
2 changes: 1 addition & 1 deletion unattended_scripts/tools/wazuh-cert-tool.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Program to generate the certificates necessary for Wazuh installation
# Copyright (C) 2015-2020, Wazuh Inc.
# Copyright (C) 2015-2021, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
Expand Down
Loading