Change realpath to readlink command - Unify unattended #1056
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The realpath command is not a native GNU command and is added in the coreutils-8.22 package, this is a problem since older systems like OL6 have coreutils-8.4, which does not provide this command.
The solution is to use a native GNU command, which is
readlink -f
Logs example
Added echo to debug path for readlink command
CentOS 7
[root@centos7 unattended_scripts]# bash unattended_installation.sh -A -l
readlink: /home/vagrant/wazuh-packages/unattended_scripts
12/09/2021 13:40:51 INFO: Configuration file found. Creating certificates...
12/09/2021 13:40:51 INFO: Creating the Elasticsearch certificates...
12/09/2021 13:40:51 INFO: Creating Wazuh server certificates...
12/09/2021 13:40:51 INFO: Creating Kibana certificate...
12/09/2021 13:40:51 INFO: Certificates creation finished. They can be found in /home/vagrant/wazuh-packages/unattended_scripts/certs.
12/09/2021 13:40:51 INFO: Starting the installation...
12/09/2021 13:40:51 INFO: Starting the installation...
12/09/2021 13:40:51 INFO: Starting the installation...
12/09/2021 13:40:51 INFO: Installing all necessary utilities for the installation...
12/09/2021 13:40:52 INFO: Done
12/09/2021 13:40:52 INFO: Adding the Wazuh repository...
12/09/2021 13:40:53 INFO: Done
12/09/2021 13:40:53 INFO: Installing the Wazuh manager...
12/09/2021 13:41:27 INFO: Done
12/09/2021 13:41:44 INFO: Wazuh-manager started
12/09/2021 13:41:44 INFO: Installing Open Distro for Elasticsearch...
12/09/2021 13:42:24 INFO: Done
12/09/2021 13:42:24 INFO: Configuring Elasticsearch...
12/09/2021 13:42:32 INFO: Elasticsearch started
12/09/2021 13:42:32 INFO: Initializing Elasticsearch...
12/09/2021 13:42:41 INFO: Done
12/09/2021 13:42:41 INFO: Installing Filebeat...
12/09/2021 13:42:44 INFO: Filebeat started
12/09/2021 13:42:44 INFO: Done
12/09/2021 13:42:44 INFO: Installing Open Distro for Kibana...
12/09/2021 13:43:47 INFO: Done
12/09/2021 13:43:56 INFO: Kibana started
Oracle Linux 6 (fails due to elasticsearch, not related to readlink)
[root@ip-172-31-17-15 unattended_scripts]# bash unattended_installation.sh -A -l
readlink: /home/ec2-user/wazuh-packages/unattended_scripts
12/09/2021 13:38:28 INFO: Configuration file found. Creating certificates...
12/09/2021 13:38:28 INFO: Creating the Elasticsearch certificates...
12/09/2021 13:38:28 INFO: Creating Wazuh server certificates...
12/09/2021 13:38:29 INFO: Creating Kibana certificate...
12/09/2021 13:38:29 INFO: Certificates creation finished. They can be found in /home/ec2-user/wazuh-packages/unattended_scripts/certs.
12/09/2021 13:38:29 INFO: Starting the installation...
12/09/2021 13:38:29 INFO: Starting the installation...
12/09/2021 13:38:29 INFO: Starting the installation...
12/09/2021 13:38:29 INFO: Installing all necessary utilities for the installation...
12/09/2021 13:38:29 INFO: Done
12/09/2021 13:38:29 INFO: Adding the Wazuh repository...
12/09/2021 13:38:29 INFO: Wazuh repository already exists skipping
12/09/2021 13:38:29 INFO: Done
12/09/2021 13:38:29 INFO: Installing the Wazuh manager...
12/09/2021 13:39:38 INFO: Done
12/09/2021 13:39:59 INFO: Wazuh-manager started
12/09/2021 13:39:59 INFO: Installing Open Distro for Elasticsearch...
Elasticsearch installation failed
12/09/2021 13:40:00 WARNING: Cleaning the installation
12/09/2021 13:40:00 WARNING: Removing the Wazuh manager...
12/09/2021 13:40:32 WARNING: Installation cleaned. Check the /var/log/wazuh-unattended-installation.log file to learn more about the issue.
Tests