Tools download logic updated

This commit is contained in:
Gonzalo Acuña
2022-03-15 11:13:36 -03:00
parent 19ad1520c8
commit c66cdea256
5 changed files with 68 additions and 18 deletions
+22 -8
View File
@@ -5,22 +5,36 @@
# Downloading Cert Gen Tool
##############################################################################
FILE=wazuh-cert-tool.sh
## Variables
CERT_TOOL=wazuh-certs-tool.sh
PASSWORD_TOOL=wazuh-passwords-tool.sh
PACKAGES_URL=https://packages.wazuh.com/resources/4.3/
PACKAGES_DEV_URL=https://packages-dev.wazuh.com/resources/4.3/
#Download from packages.wazuh.com with first parameter
curl -o $FILE https://packages.wazuh.com/4.x/wazuh-cert-tool.sh
var=`grep NoSuchKey $FILE`
## Check if the cert tool exists in S3 buckets
CERT_TOOL_PACKAGES=$(curl --silent -I $PACKAGES_URL$CERT_TOOL | grep -E "^HTTP" | awk '{print $2}')
CERT_TOOL_PACKAGES_DEV=$(curl --silent -I $PACKAGES_DEV_URL$CERT_TOOL | grep -E "^HTTP" | awk '{print $2}')
#If the content of the file contains NoSuchKey, download from packages-dev.wazuh.com
if [ ! -z "$var" ]; then
curl -o $FILE https://packages-dev.wazuh.com/4.3/wazuh-certs-tool.sh
## If cert tool exists in some bucket, download it, if not exit 1
if [ "$CERT_TOOL_PACKAGES" = "200" ]; then
curl -o $CERT_TOOL $PACKAGES_URL$CERT_TOOL
echo "Cert tool exists in Packages bucket"
elif [ "$CERT_TOOL_PACKAGES_DEV" = "200" ]; then
curl -o $CERT_TOOL $PACKAGES_DEV_URL$CERT_TOOL
echo "Cert tool exists in Packages-dev bucket"
else
echo "Cert tool does not exist in any bucket"
echo "ERROR: certificates were not created"
exit 1
fi
chmod 700 /$CERT_TOOL
##############################################################################
# Creating Cluster certificates
##############################################################################
/wazuh-cert-tool.sh
/$CERT_TOOL
echo "Moving created certificates to destination directory"
cp /certs/* /certificates/
echo "changing certificate permissions"