forked from docker-library/tomcat
-
Notifications
You must be signed in to change notification settings - Fork 4
/
update.sh
executable file
·38 lines (31 loc) · 1011 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
#!/bin/bash
set -eo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
travisEnv=
for version in "${versions[@]}"; do
majorVersion="${version%%-*}" # "6"
suffix="${version#*-}" # "jre7"
baseImage='java'
case "$suffix" in
jre*|jdk*)
baseImage+=":${suffix:3}-${suffix:0:3}" # ":7-jre"
;;
esac
fullVersion="$(curl -fsSL --compressed "https://www.apache.org/dist/tomcat/tomcat-$majorVersion/" | grep '<a href="v'"$majorVersion." | sed -r 's!.*<a href="v([^"/]+)/?".*!\1!' | sort -V | tail -1)"
(
set -x
sed -ri '
s/^(FROM) .*/\1 '"$baseImage"'/;
s/^(ENV TOMCAT_MAJOR) .*/\1 '"$majorVersion"'/;
s/^(ENV TOMCAT_VERSION) .*/\1 '"$fullVersion"'/;
' "$version/Dockerfile"
)
travisEnv='\n - VERSION='"$version$travisEnv"
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml