-
Notifications
You must be signed in to change notification settings - Fork 97
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
base: unify-unattended
Are you sure you want to change the base?
Fix rollBack and uninstall improvement #1211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function Rollback must call other functions with names uninstallWazuh
, uninstallElasticsearch
, and uninstallKibana
. Those functions must be placed in their respective .sh
file, not in common.sh
. In common.sh
will be only a functions rollBack
with this appearance:
function rollBack() {
component=$1
if $1 != "all"; then
eval "uninstall$component"
else
eval "uninstallWazuh"
eval "uninstallElasticsearch"
eval "uninstallKibana"
}
Delegating the uninstall component responsibility to their corresponding module (wazuh.sh, elasticsearch.sh, etc).
Please review the other comments
@@ -111,7 +111,7 @@ function getHelp() { | |||
echo -e " -t, --tar <path-to-certs-tar>" | |||
echo -e " Path to tar containing certificate files. By default: ${base_path}/configurations.tar" | |||
echo -e "" | |||
echo -e " -u, --uninstall" | |||
echo -e " -u, --uninstall <app-module-name>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo -e " -u, --uninstall <app-module-name>" | |
echo -e " -u, --uninstall <component-name>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider the uninstall_component_name
and elasticsearchinstalled
, wazuhinstaller
, etc unification.
Improvement for parameter check in the case: --uninstall
|
|
Done! |
I'm working on this! |
Example of complete uninstall (all) in a scenario where nothing is installed.
|
Example case where the host has all packages installed (AIO). And only one package (kibana) is uninstalled.
Case with the example of removing only one component (kibana). When this component is no longer installed.
|
Example of uninstallation of the only package in the system (manager).
Example of uninstallation of the only package in the system (elasticsearch).
Example of uninstallation of the only package in the system (kibana).
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
04/02/2022 07:08:55 INFO: ------------------------------------ Uninstall ------------------------------------
04/02/2022 07:08:55 INFO: Analyzing components to uninstall and clean.
04/02/2022 07:08:55 INFO: Wazuh and Filebeat will be uninstalled.
04/02/2022 07:08:55 WARNING: Removing Wazuh packages.
04/02/2022 07:09:00 WARNING: Removing Filebeat packages.
04/02/2022 07:09:01 WARNING: Removing Wazuh files.
04/02/2022 07:09:01 WARNING: Removing Filebeat files.
04/02/2022 07:09:02 INFO: Repositories were removed.
04/02/2022 07:09:02 INFO: The uninstall process is complete.
This output says: Wazuh and Filebeat will be uninstalled. Then, all components have a WARNING message for removal. Only Filebeat and Wazuh must appear.
The Elasticsearch and Kibana examples are good.
Please review the requested changes.
elif [ "${sys_type}" == "apt-get" ]; then | ||
eval "apt remove --purge wazuh-manager -y ${debug}" | ||
fi | ||
# Uninstall case! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the !
?
# Uninstall case! | |
# Uninstall case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
c3fc835
eval "zypper -n remove filebeat ${debug}" | ||
elif [ "${sys_type}" == "apt-get" ]; then | ||
eval "apt remove --purge filebeat -y ${debug}" | ||
# rollBack case! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the !
?
# rollBack case! | |
# rollBack case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c3fc835
eval "rm -rf /usr/share/filebeat/ ${debug}" | ||
eval "rm -rf /etc/filebeat/ ${debug}" | ||
if [ -n "${wazuhinstalled}" ] || [ -n "${wazuh_remaining_files}" ] || [ -n "${filebeatinstalled}" ] || [ -n "${filebeat_remaining_files}" ] || [ -n "${elasticsearchinstalled}" ] || [ -n "${elastic_remaining_files}" ] || [ -n "${kibanainstalled}" ] || [ -n "${kibana_remaining_files}" ]; then | ||
logger -w "Some Wazuh components are still installed on this host." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When could this casuistic happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the process of uninstalling a component is done. And there are others installed.
Consider if when uninstalling a component. And there is still another one installed that should:
- be notified, hence the -w
- And also, the repository configuration will not be deleted. This should be uninstalled only when it is verified that there are no components left installed.
@@ -169,6 +170,43 @@ function installElasticsearch() { | |||
|
|||
} | |||
|
|||
function uninstallelasticsearch() { | |||
logger "Elasticsearch will be uninstalled." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a blank line separator from the first function line to function definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c3fc835
kibanainstalled="1" | ||
logger "Kibana installation finished." | ||
fi | ||
|
||
} | ||
|
||
function uninstallkibana() { | ||
logger "Kibana will be uninstalled." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c3fc835
|
||
logger "Wazuh and Filebeat will be uninstalled." | ||
|
||
# remove packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# remove packages | |
# Remove packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c3fc835
fi | ||
fi | ||
|
||
# remove files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# remove files | |
# Remove files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c3fc835
|
||
# remove packages | ||
if [[ -n "${wazuhinstalled}" ]];then | ||
logger -w "Removing Wazuh packages." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why packages? It's only one.
logger -w "Removing Wazuh packages." | |
logger -w "Removing Wazuh manager." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c3fc835
fi | ||
|
||
if [[ -n "${filebeatinstalled}" ]]; then | ||
logger -w "Removing Filebeat packages." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why packages?
logger -w "Removing Filebeat packages." | |
logger -w "Removing Filebeat." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c3fc835
…m:wazuh/wazuh-packages into unify-unatteded-uninstall-chose-component
Done d29d1ad |
Merge branch 'unify-unattended' into unify-unatteded-uninstall-chose-component It is pending testing. This merge was really hard, I want to be able to do a full install test again. |
…tteded-uninstall-chose-component
Description
The script needs to be able to run custom uninstallations: