Skip to content

Instantly share code, notes, and snippets.

@bhavanki
Last active September 25, 2017 17:39
Show Gist options
  • Save bhavanki/41a638180d581fcd17ab3c030d15b5fe to your computer and use it in GitHub Desktop.
Save bhavanki/41a638180d581fcd17ab3c030d15b5fe to your computer and use it in GitHub Desktop.
A bash script for installing Cloudera Director. If you are feeling adventurous, use curl to pipe it into bash. Otherwise, download and run.
#!/usr/bin/env bash
# Copyright 2017 William A. Havanki, Jr.
# 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.
JAVA_VERSION=1.7
RELEASE_FILES=(
/etc/centos-release
/etc/oracle-release
/etc/redhat-release
/etc/SuSE-release
/etc/os-release
/etc/lsb-release
/etc/issue
)
detect_os() {
local osinfo=""
for f in "${RELEASE_FILES[@]}"; do
if [[ -r "$f" ]]; then
osinfo="$(cat "$f")"
break
fi
done
if [[ -z $osinfo ]]; then
echo "Failed to detect OS"
exit 1
fi
if [[ $osinfo =~ "Red Hat" || $osinfo =~ CentOS ]]; then
if [[ $osinfo =~ "release 7" ]]; then
echo "rhel7"
elif [[ $osinfo =~ "release 6" ]]; then
echo "rhel6"
fi
elif [[ $osinfo =~ "Debian GNU/Linux 7" ]]; then
echo "debianwheezy"
elif [[ $osinfo =~ "Precise Pangolin" || $osinfo =~ precise ]]; then
echo "ubuntuprecise"
elif [[ $osinfo =~ "Trusty Tahr" || $osinfo =~ trusty ]]; then
echo "ubuntutrusty"
elif [[ $osinfo =~ "Xenial Xerus" || $osinfo =~ xenial ]]; then
echo "ubuntuxenial"
else
echo "unknown"
fi
}
RHEL7_REPO_FILE=http://archive.cloudera.com/director/redhat/7/x86_64/director/cloudera-director.repo
RHEL6_REPO_FILE=http://archive.cloudera.com/director/redhat/6/x86_64/director/cloudera-director.repo
install_director_rhel() {
local ostype="$1"
cd /etc/yum.repos.d/
if [[ $ostype == "rhel7" ]]; then
sudo curl -O $RHEL7_REPO_FILE
elif [[ $ostype == "rhel6" ]]; then
sudo curl -O $RHEL6_REPO_FILE
else
echo "Unsupported RHEL compatible OS for install: $ostype"
exit 1
fi
sudo yum -y install oracle-j2sdk${JAVA_VERSION}
sudo yum -y install cloudera-director-server cloudera-director-client
}
install_director_deb() {
local ostype="$1"
cd /etc/apt/sources.list.d/
local archiveDir
if [[ $ostype == "ubuntutrusty" || $ostype == "ubuntuxenial" ]]; then
archiveDir="ubuntu/trusty"
else
echo "Unsupported Debian compatible OS for install: $ostype"
exit 1
fi
sudo curl -O "http://archive.cloudera.com/director/$archiveDir/amd64/director/cloudera-director.list"
sudo curl -s "http://archive.cloudera.com/director/$archiveDir/amd64/director/archive.key" | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install oracle-j2sdk${JAVA_VERSION}
sudo apt-get -y install cloudera-director-server cloudera-director-client
}
install_director() {
ostype="$(detect_os)"
echo "Installing Cloudera Director for $ostype"
case $ostype in
rhel*)
install_director_rhel "$ostype"
;;
deb*|ubu*)
install_director_deb "$ostype"
;;
*)
echo "Unsupported OS for install: $ostype"
exit 1
esac
echo "Cloudera Director is installed. To start the server:"
echo "sudo service cloudera-director-server start"
}
install_director
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment