2016-09-02 15:11:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
2017-01-13 10:31:57 +01:00
|
|
|
declare -A cmd=(
|
|
|
|
[apache]='apache2-foreground'
|
|
|
|
[fpm]='php-fpm'
|
2018-02-11 02:58:17 +01:00
|
|
|
[fpm-alpine]='php-fpm'
|
|
|
|
)
|
|
|
|
|
|
|
|
declare -A base=(
|
|
|
|
[apache]='debian'
|
|
|
|
[fpm]='debian'
|
|
|
|
[fpm-alpine]='alpine'
|
2017-01-13 10:31:57 +01:00
|
|
|
)
|
|
|
|
|
2018-01-04 22:35:31 +01:00
|
|
|
declare -A extras=(
|
|
|
|
[apache]='\nRUN a2enmod rewrite'
|
|
|
|
[fpm]=''
|
2018-02-11 02:58:17 +01:00
|
|
|
[fpm-alpine]=''
|
2018-01-04 22:35:31 +01:00
|
|
|
)
|
|
|
|
|
2018-03-08 09:38:24 +01:00
|
|
|
declare -A pecl_versions=(
|
|
|
|
[APCu]='5.1.10'
|
|
|
|
[memcached]='3.0.4'
|
|
|
|
[redis]='3.1.6'
|
|
|
|
)
|
|
|
|
|
2017-03-07 15:33:57 +01: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-06-06 15:24:08 +02:00
|
|
|
latests=( $( curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(.[[:digit:]]+)+' | \
|
2017-06-03 13:56:18 +02:00
|
|
|
grep -oE '[[:digit:]]+(.[[:digit:]]+)+' | \
|
2017-06-23 16:12:44 +02:00
|
|
|
sort -urV ) )
|
2017-01-13 10:31:57 +01:00
|
|
|
|
2017-06-23 16:12:44 +02:00
|
|
|
find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\.[[:digit:]]\+' -exec rm -r '{}' \;
|
2017-06-10 23:15:01 +02:00
|
|
|
|
2017-03-14 10:48:58 +01:00
|
|
|
travisEnv=
|
2017-01-13 10:31:57 +01:00
|
|
|
for latest in "${latests[@]}"; do
|
|
|
|
version=$(echo "$latest" | cut -d. -f1-2)
|
|
|
|
|
2017-06-23 16:12:44 +02:00
|
|
|
if [ -d "$version" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2017-08-27 10:58:21 +02:00
|
|
|
# Only add versions >= 11
|
|
|
|
if version_greater_or_equal "$version" "11.0"; then
|
2017-06-10 23:15:01 +02:00
|
|
|
|
2018-02-11 02:58:17 +01:00
|
|
|
for variant in apache fpm fpm-alpine; do
|
2017-06-10 23:15:01 +02:00
|
|
|
# Create the version+variant directory with a Dockerfile.
|
|
|
|
mkdir -p "$version/$variant"
|
2017-03-07 15:33:57 +01:00
|
|
|
|
2018-02-11 02:58:17 +01:00
|
|
|
template="Dockerfile-${base[$variant]}.template"
|
2017-06-10 23:15:01 +02:00
|
|
|
cp "$template" "$version/$variant/Dockerfile"
|
2017-01-13 10:31:57 +01:00
|
|
|
|
2017-06-10 23:15:01 +02:00
|
|
|
echo "updating $latest [$version] $variant"
|
2017-01-13 10:31:57 +01:00
|
|
|
|
2017-06-10 23:15:01 +02:00
|
|
|
# Replace the variables.
|
|
|
|
sed -ri -e '
|
|
|
|
s/%%VARIANT%%/'"$variant"'/g;
|
|
|
|
s/%%VERSION%%/'"$latest"'/g;
|
|
|
|
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
2018-01-04 22:35:31 +01:00
|
|
|
s/%%VARIANT_EXTRAS%%/'"${extras[$variant]}"'/g;
|
2018-03-08 09:38:24 +01:00
|
|
|
s/%%APCU_VERSION%%/'"${pecl_versions[APCu]}"'/g;
|
|
|
|
s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g;
|
|
|
|
s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g;
|
2017-06-10 23:15:01 +02:00
|
|
|
' "$version/$variant/Dockerfile"
|
2017-01-13 10:31:57 +01:00
|
|
|
|
2018-01-30 13:11:04 +01:00
|
|
|
# Copy the shell scripts
|
|
|
|
for name in entrypoint cron; do
|
|
|
|
cp "docker-$name.sh" "$version/$variant/$name.sh"
|
|
|
|
done
|
2017-03-14 10:48:58 +01:00
|
|
|
|
2017-07-01 14:31:06 +02:00
|
|
|
# Copy the config directory
|
|
|
|
cp -rT .config "$version/$variant/config"
|
2017-04-17 23:02:25 +02:00
|
|
|
|
2018-01-04 22:35:31 +01:00
|
|
|
# Remove Apache config if we're not an Apache variant.
|
2017-09-14 10:23:46 +02:00
|
|
|
if [ "$variant" != "apache" ]; then
|
|
|
|
rm "$version/$variant/config/apache-pretty-urls.config.php"
|
|
|
|
fi
|
|
|
|
|
2017-06-29 12:57:03 +02:00
|
|
|
for arch in i386 amd64; do
|
|
|
|
travisEnv='\n - env: VERSION='"$version"' VARIANT='"$variant"' ARCH='"$arch$travisEnv"
|
|
|
|
done
|
2017-06-10 23:15:01 +02:00
|
|
|
done
|
|
|
|
fi
|
2017-01-13 10:31:57 +01:00
|
|
|
done
|
2017-03-14 10:48:58 +01:00
|
|
|
|
2017-06-23 16:12:44 +02:00
|
|
|
# replace the fist '-' with ' '
|
|
|
|
travisEnv="$(echo "$travisEnv" | sed '0,/-/{s/-/ /}')"
|
|
|
|
|
2017-03-14 10:48:58 +01:00
|
|
|
# update .travis.yml
|
2017-06-23 16:12:44 +02:00
|
|
|
travis="$(awk -v 'RS=\n\n' '$1 == "-" && $2 == "stage:" && $3 == "test" && $4 == "images" { $0 = " - stage: test images'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
2017-03-14 10:48:58 +01:00
|
|
|
echo "$travis" > .travis.yml
|