Skip to content

Commit 01fbcac

Browse files
authored
Fallback to Apache server if mirror is not available (wurstmeister#476)
Fixes wurstmeister#475
1 parent c435609 commit 01fbcac

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

download-kafka.sh

+6-11
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@ source "/usr/bin/versions.sh"
55

66
FILENAME="kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz"
77

8-
## Versions prior to 0.10.2.1 are not actively mirrored
9-
echo "Downloading kafka $MAJOR_VERSION.$MINOR_VERSION"
10-
if [[ "$MAJOR_VERSION" == "0" && "$MINOR_VERSION" -lt "11" ]]; then
11-
echo "Version prior to 0.10.2.1 - downloading direct"
12-
url="https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/${FILENAME}"
13-
else
14-
url=$(curl --stderr /dev/null "https://www.apache.org/dyn/closer.cgi?path=/kafka/${KAFKA_VERSION}/${FILENAME}&as_json=1" | jq -r '"\(.preferred)\(.path_info)"')
15-
fi
8+
url=$(curl --stderr /dev/null "https://www.apache.org/dyn/closer.cgi?path=/kafka/${KAFKA_VERSION}/${FILENAME}&as_json=1" | jq -r '"\(.preferred)\(.path_info)"')
169

17-
if [[ -z "$url" ]]; then
18-
echo "Unable to determine mirror for downloading Kafka, the service may be down"
19-
exit 1
10+
# Test to see if the suggested mirror has this version, currently pre 2.1.1 versions
11+
# do not appear to be actively mirrored. This may also be useful if closer.cgi is down.
12+
if [[ ! $(curl -s -f -I "${url}") ]]; then
13+
echo "Mirror does not have desired version, downloading direct from Apache"
14+
url="https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/${FILENAME}"
2015
fi
2116

2217
echo "Downloading Kafka from $url"

0 commit comments

Comments
 (0)