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

Fix rollBack and uninstall improvement #1211

Open
wants to merge 34 commits into
base: unify-unattended
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fa9939f
Fix rollBack and uninstall improvement
myu1d157h0u54nd Jan 27, 2022
039d2df
Change app-module-name for component-name
myu1d157h0u54nd Feb 2, 2022
f6f3406
Merge branch 'unify-unattended' into unify-unatteded-uninstall-chose-…
myu1d157h0u54nd Feb 2, 2022
064cb16
Fix rollBack and uninstall
myu1d157h0u54nd Feb 2, 2022
6d224d3
Removed trims and help output rework
alberpilot Feb 2, 2022
a0c00c0
Style minor change
alberpilot Feb 2, 2022
5387d9b
Fix rollBack (rework)
myu1d157h0u54nd Feb 3, 2022
76e3e1b
Fix checkArguments.
myu1d157h0u54nd Feb 3, 2022
4c1261b
Fix function uninstallelasticsearch, uninstallkibana, uninstallmanager.
myu1d157h0u54nd Feb 3, 2022
5c15e06
Fix function rollBack.
myu1d157h0u54nd Feb 3, 2022
9e78493
Fix work flow in wazuh-install for uninstall case.
myu1d157h0u54nd Feb 3, 2022
98253de
Fix rollBack for overwrite case.
myu1d157h0u54nd Feb 3, 2022
a72f607
Fix function uninstallelasticsearch, uninstallkibana, uninstallmanager.
myu1d157h0u54nd Feb 3, 2022
51af2ab
Fix function uninstall*
myu1d157h0u54nd Feb 8, 2022
fb60732
Fix logger and call to rollBack from wazuh_install*
myu1d157h0u54nd Feb 8, 2022
5d1267f
Big rework in function rollBack (uninstall case, overwrite case and r…
myu1d157h0u54nd Feb 8, 2022
b819306
Improved array definition
alberpilot Feb 8, 2022
c3fc835
Minor change fix.
myu1d157h0u54nd Feb 8, 2022
6654ab1
Merge branch 'unify-unatteded-uninstall-chose-component' of github.co…
myu1d157h0u54nd Feb 8, 2022
d29d1ad
Fix logger for uninstallmanager case.
myu1d157h0u54nd Feb 8, 2022
641d6aa
Merge branch 'unify-unattended' into unify-unatteded-uninstall-chose-…
myu1d157h0u54nd Feb 9, 2022
7b5b465
Fix merge, change elasticsearch>wazuh-indexer, change kibana>wazuh-da…
myu1d157h0u54nd Feb 9, 2022
c777d90
Fix merge, call to functions.
myu1d157h0u54nd Feb 9, 2022
1338351
Fix checks_arguments
myu1d157h0u54nd Feb 10, 2022
4a0eebe
Fix common_rollBack
myu1d157h0u54nd Feb 10, 2022
5a57fb7
Fix call to common_rollBack, for installation failed
myu1d157h0u54nd Feb 10, 2022
ea3e3ad
Fix functions import, Uninstall and Overwrite
myu1d157h0u54nd Feb 10, 2022
ba07f87
Fix wazuh-dashboards to wazuh-dashboard
myu1d157h0u54nd Feb 10, 2022
999ffa3
Fix wazuh-dashboards renames
myu1d157h0u54nd Feb 10, 2022
17f67c7
Fix wazuh-dashboards to wazuh-dashboard in yml files
myu1d157h0u54nd Feb 10, 2022
5c362fe
Fix logger
myu1d157h0u54nd Feb 10, 2022
8d5ed5f
Changed dashboards for dashboard in unattended pytest
verdx Feb 11, 2022
524b366
Merge remote-tracking branch 'origin/unify-unattended' into unify-una…
verdx Feb 11, 2022
7af196b
Removed accidentally added file
alberpilot Feb 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 52 additions & 41 deletions unattended_installer/install_functions/opendistro/checks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Wazuh installer - checks.sh functions.
# Wazuh installer - checks.sh functions.
# Copyright (C) 2015, Wazuh Inc.
#
# This program is a free software; you can redistribute it
Expand All @@ -21,8 +21,8 @@ function checkArguments() {
# -------------- Configurations ---------------------------------

if [[ ( -n "${AIO}" || -n "${configurations}" ) && -f "${tar_file}" ]]; then
logger -e "File ${tar_file} exists. Please remove it if you want to use a new configuration."
exit 1
logger -e "File ${tar_file} exists. Please remove it if you want to use a new configuration."
exit 1
fi

if [[ -n "${configurations}" && ( -n "${AIO}" || -n "${elasticsearch}" || -n "${kibana}" || -n "${wazuh}" || -n "${overwrite}" || -n "${start_elastic_cluster}" || -n "${tar_conf}" || -n "${uninstall}" ) ]]; then
Expand All @@ -32,35 +32,25 @@ function checkArguments() {

# -------------- Overwrite --------------------------------------

if [ -n "${overwrite}" ] && [ -z "${AIO}" ] && [ -z "${elasticsearch}" ] && [ -z "${kibana}" ] && [ -z "${wazuh}" ]; then
logger -e "The argument -o|--overwrite must be used with -a, -k, -e or -w. If you want to uninstall all the components use -u|--uninstall"
if [ -n "${overwrite}" ] && [ -z "${AIO}" ] && [ -z "${elasticsearch}" ] && [ -z "${kibana}" ] && [ -z "${wazuh}" ]; then
logger -e "The argument -o|--overwrite must be used with -a, -k, -e or -w. If you want to uninstall all the components use -u|--uninstall."
exit 1
fi

# -------------- Uninstall --------------------------------------

if [ -n "${uninstall}" ]; then

if [ -z "${wazuhinstalled}" ] && [ -z "${wazuh_remaining_files}" ]; then
logger "Wazuh manager components were not found on the system so it was not uninstalled."
fi

if [ -z "${filebeatinstalled}" ] && [ -z "${filebeat_remaining_files}" ]; then
logger "Filebeat components were not found on the system so it was not uninstalled."
fi

if [ -z "${elasticsearchinstalled}" ] && [ -z "${elastic_remaining_files}" ]; then
logger "Elasticsearch components were not found on the system so it was not uninstalled."
fi

if [ -z "${kibanainstalled}" ] && [ -z "${kibana_remaining_files}" ]; then
logger "Kibana components were found on the system so it was not uninstalled."
if [ -n "$AIO" ] || [ -n "$elasticsearch" ] || [ -n "$kibana" ] || [ -n "$wazuh" ]; then
logger -e "The argument -u|--uninstall can't be used with -a, -k, -e or -w. If you want to overwrite the components use -o|--overwrite."
exit 1
fi

if [ -n "$AIO" ] || [ -n "$elasticsearch" ] || [ -n "$kibana" ] || [ -n "$wazuh" ]; then
logger -e "The argument -u|--uninstall can't be used with -a, -k, -e or -w. If you want to overwrite the components use -o|--overwrite"
if ! [ ${uninstall_component_name} == "all" -o ${uninstall_component_name} == "manager" -o ${uninstall_component_name} == "elasticsearch" -o ${uninstall_component_name} == "kibana" ]; then
logger -e "The argument -u|--uninstall only accepts the following parameters: all, manager, elasticsearch or kibana."
exit 1
fi

fi

# -------------- All-In-One -------------------------------------
Expand Down Expand Up @@ -89,7 +79,7 @@ function checkArguments() {
if [ -n "${elasticsearchinstalled}" ] || [ -n "${elastic_remaining_files}" ]; then
if [ -n "${overwrite}" ]; then
rollBack
else
else
logger -e "Elasticsearch is already installed in this node or some of its files haven't been erased. Use option -o|--overwrite to overwrite all components."
exit 1
fi
Expand All @@ -102,7 +92,7 @@ function checkArguments() {
if [ -n "${kibanainstalled}" ] || [ -n "${kibana_remaining_files}" ]; then
if [ -n "${overwrite}" ]; then
rollBack
else
else
logger -e "Kibana is already installed in this node or some of its files haven't been erased. Use option -o|--overwrite to overwrite all components."
exit 1
fi
Expand All @@ -115,7 +105,7 @@ function checkArguments() {
if [ -n "${wazuhinstalled}" ] || [ -n "${wazuh_remaining_files}" ]; then
if [ -n "${overwrite}" ]; then
rollBack
else
else
logger -e "Wazuh is already installed in this node or some of its files haven't been erased. Use option -o|--overwrite to overwrite all components."
exit 1
fi
Expand All @@ -140,10 +130,10 @@ function checkArguments() {

# -------------- Global -----------------------------------------

if [ -z "${AIO}" ] && [ -z "${elasticsearch}" ] && [ -z "${kibana}" ] && [ -z "${wazuh}" ] && [ -z "${start_elastic_cluster}" ] && [ -z "${configurations}" ] && [ -z "${uninstall}"]; then
if [[ -z "${AIO}" && -z "${elasticsearch}" && -z "${kibana}" && -z "${wazuh}" && -z "${start_elastic_cluster}" && -z "${configurations}" && -z "${uninstall}" ]]; then
logger -e "At least one of these arguments is necessary -a|--all-in-one, -c|--create-configurations, -e|--elasticsearch <elasticsearch-node-name>, -k|--kibana <kibana-node-name>, -s|--start-cluster, -w|--wazuh-server <wazuh-node-name>, -u|--uninstall"
exit 1
fi
fi

}

Expand Down Expand Up @@ -198,10 +188,6 @@ function checkIfInstalled() {
wazuhinstalled=$(apt list --installed 2>/dev/null | grep wazuh-manager)
fi

if [ -d "/var/ossec" ]; then
wazuh_remaining_files=1
fi

if [ "${sys_type}" == "yum" ]; then
elasticsearchinstalled=$(yum list installed 2>/dev/null | grep opendistroforelasticsearch | grep -v kibana)
elif [ "${sys_type}" == "zypper" ]; then
Expand All @@ -210,10 +196,6 @@ function checkIfInstalled() {
elasticsearchinstalled=$(apt list --installed 2>/dev/null | grep opendistroforelasticsearch | grep -v kibana)
fi

if [ -d "/var/lib/elasticsearch/" ] || [ -d "/usr/share/elasticsearch" ] || [ -d "/etc/elasticsearch" ] || [ -f "${base_path}/search-guard-tlstool*" ]; then
elastic_remaining_files=1
fi

if [ "${sys_type}" == "yum" ]; then
filebeatinstalled=$(yum list installed 2>/dev/null | grep filebeat)
elif [ "${sys_type}" == "zypper" ]; then
Expand All @@ -222,10 +204,6 @@ function checkIfInstalled() {
filebeatinstalled=$(apt list --installed 2>/dev/null | grep filebeat)
fi

if [ -d "/var/lib/filebeat/" ] || [ -d "/usr/share/filebeat" ] || [ -d "/etc/filebeat" ]; then
filebeat_remaining_files=1
fi

if [ "${sys_type}" == "yum" ]; then
kibanainstalled=$(yum list installed 2>/dev/null | grep opendistroforelasticsearch-kibana)
elif [ "${sys_type}" == "zypper" ]; then
Expand All @@ -234,13 +212,46 @@ function checkIfInstalled() {
kibanainstalled=$(apt list --installed 2>/dev/null | grep opendistroforelasticsearch-kibana)
fi

checkWazuhRemainingFiles
checkFilebeatRemainingFiles
checkElasticRemainingFiles
checkKibanaRemainingFiles

}

function checkWazuhRemainingFiles() {
if [ -d "/var/ossec" ]; then
wazuh_remaining_files=1
else
wazuh_remaining_files=""
fi
}

function checkFilebeatRemainingFiles() {
if [ -d "/var/lib/filebeat/" ] || [ -d "/usr/share/filebeat" ] || [ -d "/etc/filebeat" ]; then
filebeat_remaining_files=1
else
filebeat_remaining_files=""
fi
}

function checkElasticRemainingFiles() {
if [ -d "/var/lib/elasticsearch/" ] || [ -d "/usr/share/elasticsearch" ] || [ -d "/etc/elasticsearch" ] || [ -f "${base_path}/search-guard-tlstool*" ]; then
elastic_remaining_files=1
else
elastic_remaining_files=""
fi
}

function checkKibanaRemainingFiles() {
if [ -d "/var/lib/kibana/" ] || [ -d "/usr/share/kibana" ] || [ -d "/etc/kibana" ]; then
kibana_remaining_files=1
else
kibana_remaining_files=""
fi

}

# This function ensures different names in the config.yml file.
# This function ensures different names in the config.yml file.
function checkNames() {

if [ -n "${einame}" ] && [ -n "${kiname}" ] && [ "${einame}" == "${kiname}" ]; then
Expand All @@ -261,7 +272,7 @@ function checkNames() {
if [ -n "${winame}" ] && [ -z "$(echo "${wazuh_servers_node_names[@]}" | grep -w "${winame}")" ]; then
logger -e "The Wazuh server node name ${winame} does not appear on the configuration file."
exit 1
fi
fi

if [ -n "${einame}" ] && [ -z "$(echo "${elasticsearch_node_names[@]}" | grep -w "${einame}")" ]; then
logger -e "The Elasticsearch node name ${einame} does not appear on the configuration file."
Expand Down
Loading