diff options
author | Tilo Spannagel <development@tilosp.de> | 2017-03-07 15:33:57 +0100 |
---|---|---|
committer | Tilo Spannagel <development@tilosp.de> | 2017-03-07 15:33:57 +0100 |
commit | 41396747e617f7f1bc71d40a1fd87d5693819aa6 (patch) | |
tree | ba2d9607059e542c603fdf6c642bed0f7ca317c0 | |
parent | 534665db850902068eca461cf1e67c2309e8ebaa (diff) |
Added function for version comparison
-rwxr-xr-x | update.sh | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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" |