2022-01-07 23:22:35 +01:00
|
|
|
#!/usr/bin/env bash
|
2016-09-02 15:11:38 +02:00
|
|
|
set -eo pipefail
|
|
|
|
|
2023-03-21 23:44:22 +01:00
|
|
|
declare -A alpine_version=(
|
2024-01-26 00:50:34 +01:00
|
|
|
[default]='3.19'
|
2023-03-21 23:44:22 +01:00
|
|
|
)
|
|
|
|
|
2023-05-31 14:13:56 +02:00
|
|
|
declare -A debian_version=(
|
2023-07-24 21:36:02 +02:00
|
|
|
[default]='bookworm'
|
2023-05-31 14:13:56 +02:00
|
|
|
)
|
|
|
|
|
2018-03-08 09:52:55 +01:00
|
|
|
declare -A php_version=(
|
2023-05-31 17:17:36 +02:00
|
|
|
[default]='8.2'
|
2018-03-08 09:52:55 +01:00
|
|
|
)
|
|
|
|
|
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=(
|
2023-09-17 00:51:45 +02:00
|
|
|
[apache]='\nRUN a2enmod headers rewrite remoteip ; \\\n { \\\n echo '\''RemoteIPHeader X-Real-IP'\''; \\\n echo '\''RemoteIPInternalProxy 10.0.0.0/8'\''; \\\n echo '\''RemoteIPInternalProxy 172.16.0.0/12'\''; \\\n echo '\''RemoteIPInternalProxy 192.168.0.0/16'\''; \\\n } > /etc/apache2/conf-available/remoteip.conf; \\\n a2enconf remoteip\n\n# set apache config LimitRequestBody\nENV APACHE_BODY_LIMIT 1073741824\nRUN { \\\n echo '\''LimitRequestBody ${APACHE_BODY_LIMIT}'\''; \\\n } > /etc/apache2/conf-available/apache-limits.conf; \\\n a2enconf apache-limits'
|
2018-01-04 22:35:31 +01:00
|
|
|
[fpm]=''
|
2018-02-11 02:58:17 +01:00
|
|
|
[fpm-alpine]=''
|
2018-01-04 22:35:31 +01:00
|
|
|
)
|
|
|
|
|
2019-09-30 19:44:55 +02:00
|
|
|
declare -A crontab_int=(
|
|
|
|
[default]='5'
|
|
|
|
)
|
|
|
|
|
2018-11-21 22:34:02 +01:00
|
|
|
apcu_version="$(
|
|
|
|
git ls-remote --tags https://github.com/krakjoe/apcu.git \
|
|
|
|
| cut -d/ -f3 \
|
2022-03-28 17:30:51 +02:00
|
|
|
| grep -viE -- 'rc|b' \
|
2018-11-21 22:34:02 +01:00
|
|
|
| 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 \
|
2022-03-28 17:30:51 +02:00
|
|
|
| grep -viE -- 'rc|b' \
|
2018-11-21 22:34:02 +01:00
|
|
|
| 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 09:38:24 +01:00
|
|
|
declare -A pecl_versions=(
|
2018-11-21 22:34:02 +01:00
|
|
|
[APCu]="$apcu_version"
|
|
|
|
[memcached]="$memcached_version"
|
2020-06-05 00:03:30 +02:00
|
|
|
[redis]="$redis_version"
|
2018-11-21 22:34:02 +01:00
|
|
|
[imagick]="$imagick_version"
|
2018-03-08 09:38:24 +01:00
|
|
|
)
|
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
variants=(
|
|
|
|
apache
|
|
|
|
fpm
|
|
|
|
fpm-alpine
|
|
|
|
)
|
|
|
|
|
2023-11-24 11:42:06 +01:00
|
|
|
min_version='26'
|
2018-03-13 10:58:19 +01:00
|
|
|
|
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" ]];
|
|
|
|
}
|
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
function create_variant() {
|
|
|
|
dir="$1/$variant"
|
2023-03-21 23:44:22 +01:00
|
|
|
alpineVersion=${alpine_version[$version]-${alpine_version[default]}}
|
2023-05-31 14:13:56 +02:00
|
|
|
debianVersion=${debian_version[$version]-${debian_version[default]}}
|
2018-12-11 00:07:49 +01:00
|
|
|
phpVersion=${php_version[$version]-${php_version[default]}}
|
2019-09-30 19:44:55 +02:00
|
|
|
crontabInt=${crontab_int[$version]-${crontab_int[default]}}
|
2023-05-31 14:13:56 +02:00
|
|
|
url="https://download.nextcloud.com/server/releases/nextcloud-$fullversion.tar.bz2"
|
|
|
|
ascUrl="https://download.nextcloud.com/server/releases/nextcloud-$fullversion.tar.bz2.asc"
|
2018-03-13 10:58:19 +01:00
|
|
|
|
|
|
|
# Create the version+variant directory with a Dockerfile.
|
|
|
|
mkdir -p "$dir"
|
|
|
|
|
2018-08-01 23:19:53 +02:00
|
|
|
template="Dockerfile-${base[$variant]}.template"
|
|
|
|
echo "# DO NOT EDIT: created by update.sh from $template" > "$dir/Dockerfile"
|
2018-03-31 11:43:55 +02:00
|
|
|
cat "$template" >> "$dir/Dockerfile"
|
2018-03-13 10:58:19 +01:00
|
|
|
|
|
|
|
echo "updating $fullversion [$1] $variant"
|
|
|
|
|
|
|
|
# Replace the variables.
|
|
|
|
sed -ri -e '
|
2023-03-21 23:44:22 +01:00
|
|
|
s/%%ALPINE_VERSION%%/'"$alpineVersion"'/g;
|
2023-05-31 14:13:56 +02:00
|
|
|
s/%%DEBIAN_VERSION%%/'"$debianVersion"'/g;
|
2018-12-11 00:07:49 +01:00
|
|
|
s/%%PHP_VERSION%%/'"$phpVersion"'/g;
|
2018-03-13 10:58:19 +01:00
|
|
|
s/%%VARIANT%%/'"$variant"'/g;
|
|
|
|
s/%%VERSION%%/'"$fullversion"'/g;
|
2023-05-31 14:13:56 +02:00
|
|
|
s/%%DOWNLOAD_URL%%/'"$(sed -e 's/[\/&]/\\&/g' <<< "$url")"'/g;
|
|
|
|
s/%%DOWNLOAD_URL_ASC%%/'"$(sed -e 's/[\/&]/\\&/g' <<< "$ascUrl")"'/g;
|
2018-03-13 10:58:19 +01:00
|
|
|
s/%%CMD%%/'"${cmd[$variant]}"'/g;
|
2018-04-01 11:37:04 +02:00
|
|
|
s|%%VARIANT_EXTRAS%%|'"${extras[$variant]}"'|g;
|
2018-03-13 10:58:19 +01: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 01:06:21 +01:00
|
|
|
s/%%IMAGICK_VERSION%%/'"${pecl_versions[imagick]}"'/g;
|
2019-09-30 19:44:55 +02:00
|
|
|
s/%%CRONTAB_INT%%/'"$crontabInt"'/g;
|
2018-03-13 10:58:19 +01:00
|
|
|
' "$dir/Dockerfile"
|
|
|
|
|
|
|
|
# Copy the shell scripts
|
|
|
|
for name in entrypoint cron; do
|
|
|
|
cp "docker-$name.sh" "$dir/$name.sh"
|
|
|
|
done
|
|
|
|
|
2018-10-01 15:28:13 +02:00
|
|
|
# Copy the upgrade.exclude
|
|
|
|
cp upgrade.exclude "$dir/"
|
|
|
|
|
2018-03-13 10:58:19 +01: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 16:12:44 +02:00
|
|
|
fi
|
2023-05-31 14:13:56 +02:00
|
|
|
|
|
|
|
# Add variant to versions.json
|
|
|
|
[ "${base[$variant]}" == "alpine" ] && baseVersion="$alpineVersion" || baseVersion="$debianVersion"
|
|
|
|
versionVariantsJson="$(jq -e \
|
|
|
|
--arg version "$version" --arg variant "$variant" --arg base "${base[$variant]}" --arg baseVersion "$baseVersion" --arg phpVersion "$phpVersion" \
|
|
|
|
'.[$version].variants[$variant] = {"variant": $variant, "base": $base, "baseVersion": $baseVersion, "phpVersion": $phpVersion}' versions.json)"
|
|
|
|
versionJson="$(jq -e \
|
|
|
|
--arg version "$version" --arg fullversion "$fullversion" --arg url "$url" --arg ascUrl "$ascUrl" --argjson variants "$versionVariantsJson" \
|
|
|
|
'.[$version] = {"branch": $version, "version": $fullversion, "url": $url, "ascUrl": $ascUrl, "variants": $variants[$version].variants}' versions.json)"
|
|
|
|
printf '%s\n' "$versionJson" > versions.json
|
2018-03-13 10:58:19 +01:00
|
|
|
}
|
2017-03-14 10:48:58 +01:00
|
|
|
|
2020-03-12 00:53:13 +01:00
|
|
|
curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \
|
|
|
|
grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | \
|
|
|
|
sort -uV | \
|
|
|
|
tail -1 > latest.txt
|
|
|
|
|
2019-03-22 14:32:11 +01:00
|
|
|
find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\.[[:digit:]]\+\(-rc\|-beta\|-alpha\)\?' -exec rm -r '{}' \;
|
2017-04-17 23:02:25 +02:00
|
|
|
|
2023-05-31 14:13:56 +02:00
|
|
|
printf '%s' "{}" > versions.json
|
|
|
|
|
2018-03-13 10:58:19 +01: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 ) )
|
2021-08-06 00:32:35 +02:00
|
|
|
versions=( $( printf '%s\n' "${fullversions[@]}" | cut -d. -f1 | sort -urV ) )
|
2023-05-31 14:13:56 +02:00
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
for version in "${versions[@]}"; do
|
|
|
|
fullversion="$( printf '%s\n' "${fullversions[@]}" | grep -E "^$version" | head -1 )"
|
2017-09-14 10:23:46 +02:00
|
|
|
|
2018-03-13 10:58:19 +01:00
|
|
|
if version_greater_or_equal "$version" "$min_version"; then
|
|
|
|
for variant in "${variants[@]}"; do
|
2023-05-31 14:13:56 +02:00
|
|
|
create_variant "$version"
|
2017-06-10 23:15:01 +02:00
|
|
|
done
|
|
|
|
fi
|
2017-01-13 10:31:57 +01:00
|
|
|
done
|