Last active
November 1, 2016 20:32
-
-
Save mokuso/fd81b436724eb9c72d6a2aba7a632190 to your computer and use it in GitHub Desktop.
Installer to add the elasticsearch gpgkey, repository, and rpm package on el6 & el7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This file will install elasticsearch gpgkey, repository, and rpm package on el6 & el7 | |
# The elastic repositories do not work with older rpm based distributions that still use RPM v3, like CentOS5. | |
# | |
set -e | |
function install_rpm { | |
echo "* Installing elastic public key" | |
# Could check first (rpm -qi gpg-pubkey-d88e42b4) | |
rpm --quiet --import https://artifacts.elastic.co/GPG-KEY-elasticsearch | |
echo "* Installing elastic repository" | |
cat <<EOF > /etc/yum.repos.d/elasticsearch.repo | |
[elasticsearch-5.x] | |
name=Elasticsearch repository for 5.x packages | |
baseurl=https://artifacts.elastic.co/packages/5.x/yum | |
gpgcheck=1 | |
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch | |
enabled=1 | |
autorefresh=1 | |
type=rpm-md | |
EOF | |
echo "* Installing elasticsearch" | |
yum -q -y install elasticsearch | |
#echo "* Installing kibana" | |
#yum -q -y install kibana | |
} | |
function unsupported { | |
echo 'Unsupported operating system.' | |
exit 1 | |
} | |
#function start_onboot { | |
#SysV init (check with ps -p 1): | |
#chkconfig --add elasticsearch | |
#Otherwise if using systemd: | |
#sudo /bin/systemctl daemon-reload | |
#sudo /bin/systemctl enable elasticsearch.service | |
#} | |
if [ $(id -u) != 0 ]; then | |
echo "Installer must be run as root (or with sudo)." | |
exit 1 | |
fi | |
echo "* Detecting operating system" | |
ARCH=$(uname -m) | |
if [[ ! $ARCH = *86 ]] && [ ! $ARCH = "x86_64" ]; then | |
unsupported | |
fi | |
if [ -f /etc/system-release-cpe ]; then | |
DISTRO=$(cat /etc/system-release-cpe | cut -d':' -f3) | |
VERSION=$(cat /etc/system-release-cpe | cut -d':' -f5 | cut -d'.' -f1 | sed 's/[^0-9]*//g') | |
case "$DISTRO" in | |
"oracle" | "centos" | "redhat") | |
if [ $VERSION -ge 6 ]; then | |
install_rpm | |
else | |
unsupported | |
fi | |
;; | |
"amazon") | |
install_rpm | |
;; | |
*) | |
unsupported | |
;; | |
esac | |
else | |
unsupported | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment