Added function for version comparison

This commit is contained in:
Tilo Spannagel 2017-03-07 15:33:57 +01:00
parent 534665db85
commit 41396747e6
No known key found for this signature in database
GPG Key ID: B89F1626A58E1429

View File

@ -6,6 +6,11 @@ declare -A cmd=(
[fpm]='php-fpm'
)
# version_greater_or_equal A B returns whether A >= B
function version_greater_or_equal() {
[[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" || "$1" == "$2" ]];
}
latests=( $(curl -sSL 'https://nextcloud.com/changelog/' |tac|tac| \
grep -o "\(Version\|Release\)\s\+[[:digit:]]\+\(\.[[:digit:]]\+\)\+" | \
awk '{ print $2 }' | sort -V ) )
@ -16,11 +21,12 @@ for latest in "${latests[@]}"; do
for variant in apache fpm; do
# Create the version+variant directory with a Dockerfile.
mkdir -p "$version/$variant"
if [ "$version" == "11.0" ]; then
cp Dockerfile-php7.template "$version/$variant/Dockerfile"
else
cp Dockerfile.template "$version/$variant/Dockerfile"
template="Dockerfile.template"
if version_greater_or_equal "$version" "11.0"; then
template="Dockerfile-php7.template"
fi
cp "$template" "$version/$variant/Dockerfile"
echo "updating $latest [$version] $variant"