forked from cgswong/docker-elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·41 lines (35 loc) · 1017 Bytes
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/env bash
# Add files for each version.
set -e
# Set values
pkg=${0##*/}
# set colors
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
purple=$(tput setaf 5)
cyan=$(tput setaf 6)
white=$(tput setaf 7)
reset=$(tput sgr0)
# Script directory
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
VERSIONS=${VERSIONS:-"$@"}
if [ ! -z "$VERSIONS" ]; then
versions=( "$VERSIONS" )
else
versions=( ?.?.? )
fi
versions=( "${versions[@]%/}" )
versions=( $(printf '%s\n' "${versions[@]}"|sort -V) )
for version in "${versions[@]}"; do
dlVersion=$(echo $version | tr '.' '-')
if $(curl -fsSL https://www.elastic.co/downloads/past-releases/elasticsearch-$dlVersion &>/dev/null); then
echo "${yellow}Updating version: ${version}${reset}"
cp -R src $version/
sed -e 's/%%VERSION%%/'"$version"'/' < Dockerfile.tpl > "$version/Dockerfile"
else
echo "${red}WARNING: Unable to find ${dlVersion} for ${version}${reset}"
fi
done
echo "${green}Complete${reset}"