2016-09-02 13:11:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
declare -A cmd=(
|
|
|
|
[apache]='apache2-foreground'
|
|
|
|
[fpm]='php-fpm'
|
|
|
|
)
|
|
|
|
|
2017-03-07 14:33:57 +00:00
|
|
|
# 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" ]];
|
|
|
|
}
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
latests=( $(curl -sSL 'https://nextcloud.com/changelog/' |tac|tac| \
|
|
|
|
grep -o "\(Version\|Release\)\s\+[[:digit:]]\+\(\.[[:digit:]]\+\)\+" | \
|
|
|
|
awk '{ print $2 }' | sort -V ) )
|
|
|
|
|
2017-03-14 09:48:58 +00:00
|
|
|
travisEnv=
|
2017-01-13 09:31:57 +00:00
|
|
|
for latest in "${latests[@]}"; do
|
|
|
|
version=$(echo "$latest" | cut -d. -f1-2)
|
|
|
|
|
|
|
|
for variant in apache fpm; do
|
|
|
|
# Create the version+variant directory with a Dockerfile.
|
|
|
|
mkdir -p "$version/$variant"
|
2017-03-07 14:33:57 +00:00
|
|
|
|
|
|
|
template="Dockerfile.template"
|
|
|
|
if version_greater_or_equal "$version" "11.0"; then
|
|
|
|
template="Dockerfile-php7.template"
|
2017-03-03 17:23:05 +00:00
|
|
|
fi
|
2017-03-07 14:33:57 +00:00
|
|
|
cp "$template" "$version/$variant/Dockerfile"
|
2017-01-13 09:31:57 +00:00
|
|
|
|
|
|
|
echo "updating $latest [$version] $variant"
|
|
|
|
|
|
|
|
# Replace the variables.
|
|
|
|
sed -ri -e '
|
|
|
|
s/%%VARIANT%%/'"$variant"'/g;
|
|
|
|
s/%%VERSION%%/'"$latest"'/g;
|
|
|
|
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
|
|
|
' "$version/$variant/Dockerfile"
|
|
|
|
|
|
|
|
# Remove Apache commands if we're not an Apache variant.
|
|
|
|
if [ "$variant" != "apache" ]; then
|
|
|
|
sed -ri -e '/a2enmod/d' "$version/$variant/Dockerfile"
|
|
|
|
fi
|
|
|
|
|
2017-04-19 17:29:51 +00:00
|
|
|
# Remove the assets folder if version >= 10.0
|
|
|
|
if version_greater_or_equal "$version" "10.0"; then
|
|
|
|
sed -ri -e '/assets/d' "$version/$variant/Dockerfile"
|
|
|
|
fi
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
# Copy the docker-entrypoint.
|
|
|
|
cp docker-entrypoint.sh "$version/$variant/docker-entrypoint.sh"
|
2017-03-14 09:48:58 +00:00
|
|
|
|
2017-04-17 21:02:25 +00:00
|
|
|
# Copy apps.config.php
|
|
|
|
cp apps.config.php "$version/$variant/apps.config.php"
|
|
|
|
|
2017-03-14 09:48:58 +00:00
|
|
|
travisEnv='\n - VERSION='"$version"' VARIANT='"$variant$travisEnv"
|
2017-01-13 09:31:57 +00:00
|
|
|
done
|
|
|
|
done
|
2017-03-14 09:48:58 +00:00
|
|
|
|
|
|
|
# update .travis.yml
|
|
|
|
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
|
|
|
echo "$travis" > .travis.yml
|
|
|
|
|
|
|
|
# remove duplicate entries
|
|
|
|
echo "$(awk '!NF || !seen[$0]++' .travis.yml)" > .travis.yml
|