forked from docker-library/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·46 lines (39 loc) · 1.05 KB
/
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
42
43
44
45
46
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
versions=( */ )
fi
versions=( "${versions[@]%/}" )
defaultDebianVariant='buster-slim'
declare -A debianVariants=(
[5.6]='stretch-slim'
)
for version in "${versions[@]}"; do
debianVariant="${debianVariants[$version]:-$defaultDebianVariant}"
debianSuite="${debianVariant%%-*}" # "buster", etc
cp -a .template.Debian/docker-entrypoint.sh "$version/docker-entrypoint.sh"
fullVersion="$(
curl -fsSL "https://repo.mysql.com/apt/debian/dists/$debianSuite/mysql-$version/binary-amd64/Packages.gz" \
| gunzip \
| awk -F ': ' '
$1 == "Package" {
pkg = $2
next
}
pkg == "mysql-server" && $1 == "Version" {
print $2
}
'
)"
(
set -x
sed -ri \
-e 's/^(ENV MYSQL_VERSION) .*/\1 '"$fullVersion"'/' \
-e 's/^(ENV MYSQL_MAJOR) .*/\1 '"$version"'/' \
-e 's/^(FROM) .*/\1 debian:'"$debianVariant"'/' \
-e 's!(http://repo.mysql.com/apt/debian/) [^ ]+!\1 '"$debianSuite"'!' \
"$version/Dockerfile"
)
done