mirror of
https://github.com/wazuh/wazuh-docker.git
synced 2025-10-28 18:43:32 +00:00
Elasticsearch major version checked and repository base path changed
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Check arguments
|
||||
function CheckArgs()
|
||||
{
|
||||
if [ $1 != 4 ] && [ $1 != 5 ];then
|
||||
echo "Use: configure_s3.sh <Elastic_Server_IP:Port> <Bucket> <Path> <RepositoryName> (By default /elasticsearch/<current_elasticsearch_major_version> is added to the path)"
|
||||
echo "Use: configure_s3.sh <Elastic_Server_IP:Port> <Bucket> <Path> <RepositoryName> (By default <current_elasticsearch_major_version> is added to the path and the repository name)"
|
||||
echo "or use: configure_s3.sh <Elastic_Server_IP:Port> <Bucket> <Path> <RepositoryName> <Elasticsearch major version>"
|
||||
exit 1
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
# Create repository from base_path <path>/elasticsearch/<current_elasticsearch_major_version> (this last one is automatically added by the script itself, no arg version needed)
|
||||
# Repository name would be "s3-repository-" plus the current elasticsearch_major_version
|
||||
# Create repository from base_path <path>/<elasticsearch_major_version> (if there is no <Elasticsearch major version> argument, current version is added)
|
||||
# Repository name would be <RepositoryName>-<elasticsearch_major_version> (if there is no <Elasticsearch major version> argument, current version is added)
|
||||
function CreateRepo()
|
||||
{
|
||||
|
||||
@@ -27,8 +29,13 @@ function CreateRepo()
|
||||
version=`curl -s $elastic_ip_port | grep number | cut -d"\"" -f4 | cut -c1`
|
||||
fi
|
||||
|
||||
if ! [[ "$version" =~ ^[0-9]+$ ]];then
|
||||
echo "Elasticsearch major version must be an integer"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
repository="$repository_name-$version"
|
||||
s3_path="$path/elasticsearch/$version"
|
||||
s3_path="$path/$version"
|
||||
|
||||
curl -X PUT "$elastic_ip_port/_snapshot/$repository" -H 'Content-Type: application/json' -d'
|
||||
{
|
||||
@@ -50,4 +57,4 @@ function Main()
|
||||
CreateRepo $1 $2 $3 $4 $5 $6
|
||||
}
|
||||
|
||||
Main $# $1 $2 $3 $4 $5
|
||||
Main $# $1 $2 $3 $4 $5
|
||||
@@ -24,7 +24,7 @@ done
|
||||
>&2 echo "Elastic is up - executing command"
|
||||
|
||||
if [ $ENABLE_CONFIGURE_S3 ]; then
|
||||
|
||||
#Wait for Elasticsearch to be ready to create the repository
|
||||
sleep 10
|
||||
IP_PORT="${ELASTICSEARCH_IP}:${ELASTICSEARCH_PORT}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user