2016-09-02 13:11:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
|
2018-03-08 08:52:55 +00:00
|
|
|
declare -A php_version=(
|
2019-04-08 12:13:52 +00:00
|
|
|
[default]='7.3'
|
2018-03-08 08:52:55 +00:00
|
|
|
)
|
|
|
|
|
2017-01-13 09:31:57 +00:00
|
|
|
declare -A cmd=(
|
|
|
|
[apache]='apache2-foreground'
|
|
|
|
[fpm]='php-fpm'
|
2018-02-11 01:58:17 +00:00
|
|
|
[fpm-alpine]='php-fpm'
|
|
|
|
)
|
|
|
|
|
|
|
|
declare -A base=(
|
|
|
|
[apache]='debian'
|
|
|
|
[fpm]='debian'
|
|
|
|
[fpm-alpine]='alpine'
|
2017-01-13 09:31:57 +00:00
|
|
|
)
|
|
|
|
|
2018-01-04 21:35:31 +00:00
|
|
|
declare -A extras=(
|
2018-04-01 09:37:04 +00:00
|
|
|
[apache]='\nRUN a2enmod rewrite remoteip ;\\\n {\\\n echo RemoteIPHeader X-Real-IP ;\\\n echo RemoteIPTrustedProxy 10.0.0.0/8 ;\\\n echo RemoteIPTrustedProxy 172.16.0.0/12 ;\\\n echo RemoteIPTrustedProxy 192.168.0.0/16 ;\\\n } > /etc/apache2/conf-available/remoteip.conf;\\\n a2enconf remoteip'
|
2018-01-04 21:35:31 +00:00
|
|
|
[fpm]=''
|
2018-02-11 01:58:17 +00:00
|
|
|
[fpm-alpine]=''
|
2018-01-04 21:35:31 +00:00
|
|
|
)
|
|
|
|
|
2019-09-30 17:44:55 +00:00
|
|
|
declare -A crontab_int=(
|
|
|
|
[default]='5'
|
|
|
|
[16.0]='15'
|
|
|
|
)
|
|
|
|
|
2018-11-21 21:34:02 +00:00
|
|
|
apcu_version="$(
|
|
|
|
git ls-remote --tags https://github.com/krakjoe/apcu.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -vE -- '-rc|-b' \
|
|
|
|
| sed -E 's/^v//' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
|
|
|
)"
|
|
|
|
|
|
|
|
memcached_version="$(
|
|
|
|
git ls-remote --tags https://github.com/php-memcached-dev/php-memcached.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -vE -- '-rc|-b' \
|
|
|
|
| sed -E 's/^[rv]//' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
|
|
|
)"
|
|
|
|
|
|
|
|
redis_version="$(
|
|
|
|
git ls-remote --tags https://github.com/phpredis/phpredis.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -viE '[a-z]' \
|
|
|
|
| tr -d '^{}' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
|
|
|
)"
|
|
|
|
|
|
|
|
imagick_version="$(
|
|
|
|
git ls-remote --tags https://github.com/mkoppanen/imagick.git \
|
|
|
|
| cut -d/ -f3 \
|
|
|
|
| grep -viE '[a-z]' \
|
|
|
|
| tr -d '^{}' \
|
|
|
|
| sort -V \
|
|
|
|
| tail -1
|
|
|
|
)"
|
|
|
|
|
2018-03-08 08:38:24 +00:00
|
|
|
declare -A pecl_versions=(
|
2018-11-21 21:34:02 +00:00
|
|
|
[APCu]="$apcu_version"
|
|
|
|
[memcached]="$memcached_version"
|
2019-07-06 10:50:44 +00:00
|
|
|
[redis]="4.3.0"
|
2018-11-21 21:34:02 +00:00
|
|
|
[imagick]="$imagick_version"
|
2018-03-08 08:38:24 +00:00
|
|
|
)
|
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
variants=(
|
|
|
|
apache
|
|
|
|
fpm
|
|
|
|
fpm-alpine
|
|
|
|
)
|
|
|
|
|
2020-02-06 11:17:29 +00:00
|
|
|
min_version='16.0'
|
2018-03-13 09:58:19 +00:00
|
|
|
|
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" ]];
|
|
|
|
}
|
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
# checks if the the rc is already released
|
|
|
|
function check_released() {
|
|
|
|
printf '%s\n' "${fullversions[@]}" | grep -qE "^$( echo "$1" | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' )"
|
|
|
|
}
|
2017-06-10 21:15:01 +00:00
|
|
|
|
2018-07-26 16:12:44 +00:00
|
|
|
# checks if the the beta has already a rc
|
|
|
|
function check_rc_released() {
|
|
|
|
printf '%s\n' "${fullversions_rc[@]}" | grep -qE "^$( echo "$1" | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' )"
|
|
|
|
}
|
|
|
|
|
2019-03-12 12:47:17 +00:00
|
|
|
# checks if the the alpha has already a beta
|
|
|
|
function check_beta_released() {
|
|
|
|
printf '%s\n' "${fullversions_beta[@]}" | grep -qE "^$( echo "$1" | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' )"
|
|
|
|
}
|
|
|
|
|
2017-03-14 09:48:58 +00:00
|
|
|
travisEnv=
|
2017-01-13 09:31:57 +00:00
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
function create_variant() {
|
|
|
|
dir="$1/$variant"
|
2018-12-10 23:07:49 +00:00
|
|
|
phpVersion=${php_version[$version]-${php_version[default]}}
|
2019-09-30 17:44:55 +00:00
|
|
|
crontabInt=${crontab_int[$version]-${crontab_int[default]}}
|
2018-03-13 09:58:19 +00:00
|
|
|
|
|
|
|
# Create the version+variant directory with a Dockerfile.
|
|
|
|
mkdir -p "$dir"
|
|
|
|
|
2018-08-01 21:19:53 +00:00
|
|
|
template="Dockerfile-${base[$variant]}.template"
|
|
|
|
echo "# DO NOT EDIT: created by update.sh from $template" > "$dir/Dockerfile"
|
2018-03-31 09:43:55 +00:00
|
|
|
cat "$template" >> "$dir/Dockerfile"
|
2018-03-13 09:58:19 +00:00
|
|
|
|
|
|
|
echo "updating $fullversion [$1] $variant"
|
|
|
|
|
|
|
|
# Replace the variables.
|
|
|
|
sed -ri -e '
|
2018-12-10 23:07:49 +00:00
|
|
|
s/%%PHP_VERSION%%/'"$phpVersion"'/g;
|
2018-03-13 09:58:19 +00:00
|
|
|
s/%%VARIANT%%/'"$variant"'/g;
|
|
|
|
s/%%VERSION%%/'"$fullversion"'/g;
|
|
|
|
s/%%BASE_DOWNLOAD_URL%%/'"$2"'/g;
|
|
|
|
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
2018-04-01 09:37:04 +00:00
|
|
|
s|%%VARIANT_EXTRAS%%|'"${extras[$variant]}"'|g;
|
2018-03-13 09:58:19 +00:00
|
|
|
s/%%APCU_VERSION%%/'"${pecl_versions[APCu]}"'/g;
|
|
|
|
s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g;
|
|
|
|
s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g;
|
2018-12-11 00:06:21 +00:00
|
|
|
s/%%IMAGICK_VERSION%%/'"${pecl_versions[imagick]}"'/g;
|
2019-09-30 17:44:55 +00:00
|
|
|
s/%%CRONTAB_INT%%/'"$crontabInt"'/g;
|
2018-03-13 09:58:19 +00:00
|
|
|
' "$dir/Dockerfile"
|
|
|
|
|
2018-12-10 23:07:49 +00:00
|
|
|
if [[ "$phpVersion" != 7.3 ]]; then
|
|
|
|
sed -ri \
|
|
|
|
-e '/libzip-dev/d' \
|
|
|
|
"$dir/Dockerfile"
|
|
|
|
fi
|
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
# Copy the shell scripts
|
|
|
|
for name in entrypoint cron; do
|
|
|
|
cp "docker-$name.sh" "$dir/$name.sh"
|
|
|
|
done
|
|
|
|
|
2018-10-01 13:28:13 +00:00
|
|
|
# Copy the upgrade.exclude
|
|
|
|
cp upgrade.exclude "$dir/"
|
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
# Copy the config directory
|
|
|
|
cp -rT .config "$dir/config"
|
|
|
|
|
|
|
|
# Remove Apache config if we're not an Apache variant.
|
|
|
|
if [ "$variant" != "apache" ]; then
|
|
|
|
rm "$dir/config/apache-pretty-urls.config.php"
|
2017-06-23 14:12:44 +00:00
|
|
|
fi
|
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
for arch in i386 amd64; do
|
2018-11-15 21:11:34 +00:00
|
|
|
travisEnv=' - env: VERSION='"$1"' VARIANT='"$variant"' ARCH='"$arch"'\n'"$travisEnv"
|
2018-03-13 09:58:19 +00:00
|
|
|
done
|
|
|
|
}
|
2017-03-14 09:48:58 +00:00
|
|
|
|
2019-03-22 13:32:11 +00:00
|
|
|
find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\.[[:digit:]]\+\(-rc\|-beta\|-alpha\)\?' -exec rm -r '{}' \;
|
2017-04-17 21:02:25 +00:00
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
fullversions=( $( curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
sort -urV ) )
|
|
|
|
versions=( $( printf '%s\n' "${fullversions[@]}" | cut -d. -f1-2 | sort -urV ) )
|
|
|
|
for version in "${versions[@]}"; do
|
|
|
|
fullversion="$( printf '%s\n' "${fullversions[@]}" | grep -E "^$version" | head -1 )"
|
2017-09-14 08:23:46 +00:00
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
|
|
|
|
for variant in "${variants[@]}"; do
|
2018-08-01 20:55:25 +00:00
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
create_variant "$version" "https:\/\/download.nextcloud.com\/server\/releases"
|
2017-06-10 21:15:01 +00:00
|
|
|
done
|
|
|
|
fi
|
2017-01-13 09:31:57 +00:00
|
|
|
done
|
2017-03-14 09:48:58 +00:00
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
fullversions_rc=( $( curl -fsSL 'https://download.nextcloud.com/server/prereleases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}RC[[:digit:]]+' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}RC[[:digit:]]+' | \
|
|
|
|
sort -urV ) )
|
|
|
|
versions_rc=( $( printf '%s\n' "${fullversions_rc[@]}" | cut -d. -f1-2 | sort -urV ) )
|
|
|
|
for version in "${versions_rc[@]}"; do
|
|
|
|
fullversion="$( printf '%s\n' "${fullversions_rc[@]}" | grep -E "^$version" | head -1 )"
|
|
|
|
|
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
|
|
|
|
if ! check_released "$fullversion"; then
|
|
|
|
|
|
|
|
for variant in "${variants[@]}"; do
|
2018-08-01 20:55:25 +00:00
|
|
|
|
2018-03-13 09:58:19 +00:00
|
|
|
create_variant "$version-rc" "https:\/\/download.nextcloud.com\/server\/prereleases"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-07-26 16:12:44 +00:00
|
|
|
fullversions_beta=( $( curl -fsSL 'https://download.nextcloud.com/server/prereleases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}beta[[:digit:]]+' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}beta[[:digit:]]+' | \
|
|
|
|
sort -urV ) )
|
2018-07-31 09:33:45 +00:00
|
|
|
versions_beta=( $( printf '%s\n' "${fullversions_beta[@]}" | cut -d. -f1-2 | sort -urV ) )
|
|
|
|
for version in "${versions_beta[@]}"; do
|
2018-07-26 16:12:44 +00:00
|
|
|
fullversion="$( printf '%s\n' "${fullversions_beta[@]}" | grep -E "^$version" | head -1 )"
|
|
|
|
|
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
|
|
|
|
if ! check_rc_released "$fullversion"; then
|
|
|
|
|
|
|
|
for variant in "${variants[@]}"; do
|
2018-08-01 20:55:25 +00:00
|
|
|
|
2018-07-26 16:12:44 +00:00
|
|
|
create_variant "$version-beta" "https:\/\/download.nextcloud.com\/server\/prereleases"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2019-03-12 12:47:17 +00:00
|
|
|
fullversions_alpha=( $( curl -fsSL 'https://download.nextcloud.com/server/prereleases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}alpha[[:digit:]]+' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}alpha[[:digit:]]+' | \
|
|
|
|
sort -urV ) )
|
|
|
|
versions_alpha=( $( printf '%s\n' "${fullversions_alpha[@]}" | cut -d. -f1-2 | sort -urV ) )
|
|
|
|
for version in "${versions_alpha[@]}"; do
|
|
|
|
fullversion="$( printf '%s\n' "${fullversions_alpha[@]}" | grep -E "^$version" | head -1 )"
|
|
|
|
|
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
|
|
|
|
if ! check_beta_released "$fullversion"; then
|
|
|
|
|
|
|
|
for variant in "${variants[@]}"; do
|
|
|
|
|
|
|
|
create_variant "$version-alpha" "https:\/\/download.nextcloud.com\/server\/prereleases"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-11-15 21:11:34 +00:00
|
|
|
# remove everything after '- stage: test images'
|
|
|
|
travis="$(awk '!p; /- stage: test images/ {p=1}' .travis.yml)"
|
|
|
|
echo "$travis" > .travis.yml
|
|
|
|
|
2017-06-23 14:12:44 +00:00
|
|
|
# replace the fist '-' with ' '
|
|
|
|
travisEnv="$(echo "$travisEnv" | sed '0,/-/{s/-/ /}')"
|
2018-11-15 21:11:34 +00:00
|
|
|
printf "$travisEnv" >> .travis.yml
|