forked from PandoraMedia/kbrowse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch-kafka-tgz
executable file
·56 lines (51 loc) · 1.52 KB
/
fetch-kafka-tgz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
# Copyright 2017-present Pandora Media, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Fetch the Kafka binaries into a local "kafka" dir.
set -e -o pipefail
function verify_md5_hash {
FILE=$1
HASH=$2
set +e
if type md5 > /dev/null; then
# OSX
set -e
if [ "$(md5 $FILE | awk '{ print $4 }')" == "$HASH" ]; then
return 0
else
echo md5 hash checked failed on $FILE
return 1
fi
elif type md5sum > /dev/null; then
# Linux
set -e
if [ "$(md5sum $FILE | awk '{ print $1 }')" == "$HASH" ]; then
return 0
else
echo md5sum hash checked failed on $FILE
return 1
fi
else
echo verify_md5_hash_failed: could not find md5 or md5sum
return 1
fi
}
TGZ=kafka_2.11-1.1.0.tgz
if [ ! -f $TGZ ]; then
echo Downloading Kafka...
curl http://www-us.apache.org/dist/kafka/1.1.0/$TGZ -o $TGZ
verify_md5_hash $TGZ 9487884ea6908e4dd15fa969ffcc2f9c
fi