diff --git a/elasticsearch/config/configure_s3.sh b/elasticsearch/config/configure_s3.sh index ca5db9a6..5ec80832 100644 --- a/elasticsearch/config/configure_s3.sh +++ b/elasticsearch/config/configure_s3.sh @@ -1,18 +1,20 @@ #!/bin/bash +set -e + # Check arguments function CheckArgs() { if [ $1 != 4 ] && [ $1 != 5 ];then - echo "Use: configure_s3.sh (By default /elasticsearch/ is added to the path)" + echo "Use: configure_s3.sh (By default is added to the path and the repository name)" echo "or use: configure_s3.sh " exit 1 fi } -# Create repository from base_path /elasticsearch/ (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 / (if there is no argument, current version is added) +# Repository name would be - (if there is no 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 \ No newline at end of file +Main $# $1 $2 $3 $4 $5 \ No newline at end of file diff --git a/elasticsearch/config/load_settings.sh b/elasticsearch/config/load_settings.sh index bce7dd90..17154c29 100644 --- a/elasticsearch/config/load_settings.sh +++ b/elasticsearch/config/load_settings.sh @@ -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}"