forked from spotify/luigi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_hadoop_env.sh
executable file
·83 lines (72 loc) · 2.4 KB
/
setup_hadoop_env.sh
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
HADOOP_DISTRO=${HADOOP_DISTRO:-"hdp"}
ONLY_DOWNLOAD=${ONLY_DOWNLOAD:-false}
ONLY_EXTRACT=${ONLY_EXTRACT:-false}
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "Setup environment for snakebite tests"
echo " "
echo "options:"
echo -e "\t-h, --help show brief help"
echo -e "\t-o, --only-download just download hadoop tar(s)"
echo -e "\t-e, --only-extract just extract hadoop tar(s)"
echo -e "\t-d, --distro select distro (hdp|cdh)"
exit 0
;;
-o|--only-download)
shift
ONLY_DOWNLOAD=true
;;
-e|--only-extract)
shift
ONLY_EXTRACT=true
;;
-d|--distro)
shift
if test $# -gt 0; then
HADOOP_DISTRO=$1
else
echo "No Hadoop distro specified - abort" >&2
exit 1
fi
shift
;;
*)
echo "Unknown options: $1" >&2
exit 1
;;
esac
done
if $ONLY_DOWNLOAD && $ONLY_EXTRACT; then
echo "Both only-download and only-extract specified - abort" >&2
exit 1
fi
mkdir -p $HADOOP_HOME
if [ $HADOOP_DISTRO = "cdh" ]; then
URL="http://archive.cloudera.com/cdh5/cdh/5/hadoop-latest.tar.gz"
elif [ $HADOOP_DISTRO = "hdp" ]; then
# This site provides good URLs:
# https://github.com/saltstack-formulas/hadoop-formula/blob/5034a2204da691eceb9c2d8cd8260f11d5cc06f3/hadoop/settings.sls
URL="http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.2.6.0/tars/hadoop-2.6.0.2.2.6.0-2800.tar.gz"
else
echo "No/bad HADOOP_DISTRO='${HADOOP_DISTRO}' specified" >&2
exit 1
fi
if ! $ONLY_EXTRACT && [ ! -e ${HADOOP_HOME}/hadoop.tar.gz ] ; then
echo "Downloading Hadoop from $URL to ${HADOOP_HOME}/hadoop.tar.gz"
curl -z ${HADOOP_HOME}/hadoop.tar.gz -o ${HADOOP_HOME}/hadoop.tar.gz -L $URL
if [ $? != 0 ]; then
echo "Failed to download Hadoop from $URL - abort" >&2
exit 1
fi
fi
if $ONLY_DOWNLOAD; then
exit 0
fi
echo "Extracting ${HADOOP_HOME}/hadoop.tar.gz into $HADOOP_HOME"
tar zxf ${HADOOP_HOME}/hadoop.tar.gz --strip-components 1 -C $HADOOP_HOME
if [ $? != 0 ]; then
echo "Failed to extract Hadoop from ${HADOOP_HOME}/hadoop.tar.gz to ${HADOOP_HOME} - abort" >&2
exit 1
fi