-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathget_hue_version.sh
executable file
·63 lines (54 loc) · 1.96 KB
/
get_hue_version.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
#!/bin/bash
set -x
TMP_DIR=/tmp/$(basename "$0" | awk -F\. '{print $1}')
HUE_VERSION=$1
if [[ -d /opt/cloudera/parcels/CDH/lib/hue-${HUE_VERSION} ]]
then
echo "This version already downloaded"
exit 1
fi
HUE_MAJOR=$(echo ${HUE_VERSION} | cut -f1 -d.)
OS_CDH_VERSION=$(basename $(hadoop version | grep "\.jar" | awk '{print $6}') | awk -Fcdh '{print $2}' | awk -F\. '{print $1}')
OS_EL_VERSION="el$(lsb_release -rs | cut -f1 -d.)"
HUE_VERSION_TEST=
if [[ ${HUE_MAJOR} -eq 5 ]]
then
HUE_VERSION_TEST=$(echo ${HUE_VERSION} | grep "^[0-9]\.[0-9][0-9]\.[0-9]$")
ARCHIVE_BASE_URL=https://archive.cloudera.com/cdh${HUE_MAJOR}/parcels/${HUE_VERSION}/
elif [[ ${HUE_MAJOR} -eq 6 ]]
then
HUE_VERSION_TEST=$(echo ${HUE_VERSION} | grep "^[0-9]\.[0-9]\.[0-9]$")
ARCHIVE_BASE_URL=https://archive.cloudera.com/cdh${HUE_MAJOR}/${HUE_VERSION}/parcels/
elif [[ ${HUE_MAJOR} -eq 7 ]]
then
HUE_VERSION_TEST=$(echo ${HUE_VERSION} | grep "^[0-9]\.[0-9]\.[0-9]$")
ARCHIVE_BASE_URL=https://archive.cloudera.com/cdh${HUE_MAJOR}/${HUE_VERSION}/parcels/
else
echo "Major version was ${HUE_MAJOR} this script only works on major version 5, 6, 7"
exit 1
fi
if [[ -z ${HUE_VERSION_TEST} ]]
then
echo "Invalid Hue version, example of good 5.16.0 or 6.3.2"
exit 1
fi
if [[ ! -f /etc/redhat-release ]]
then
echo "This is not RedHat, Oracle Linux or CentOS, this script only works on those OS's"
exit 1
fi
PARCEL_NAME=$(curl -s ${ARCHIVE_BASE_URL} | grep "${OS_EL_VERSION}.parcel<" | sed "s/.*href=\"//g" | sed "s/\">.*//g")
if [[ ! -z ${PARCEL_NAME} ]]
then
PARCEL_DIR_NAME=$(echo ${PARCEL_NAME} | sed "s/\-${OS_EL_VERSION}.*//g")
mkdir -p ${TMP_DIR}
cd ${TMP_DIR} && wget ${ARCHIVE_BASE_URL}/${PARCEL_NAME}
cd ${TMP_DIR} && tar xvf ${PARCEL_NAME}
if [[ ! -d /opt/cloudera/parcels/CDH/lib/hue-${HUE_VERSION} ]]
then
cd ${TMP_DIR} && mv ${PARCEL_DIR_NAME}/lib/hue /opt/cloudera/parcels/CDH/lib/hue-${HUE_VERSION}
fi
else
echo "${HUE_VERSION} does not exist"
fi
cd && rm -Rf ${TMP_DIR}