Last active
March 23, 2017 08:18
-
-
Save mrqaidi/f79696014e77fa642f7b155deed94a5e to your computer and use it in GitHub Desktop.
elasticsearch-installer.sh
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 | |
# Coded By Ayman Qaidi mrqaidi@gmail.com | |
# run chmod 755 elasticsearch-installer.sh; ./elasticsearch-installer.sh | |
install_jdk180(){ | |
cd /opt/ | |
wget --no-cookies --no-check-certificate --header \ | |
"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ | |
"http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.tar.gz" | |
tar xzf jdk-8u102-linux-x64.tar.gz | |
cd jdk1.8.0_102/ | |
alternatives --install /usr/bin/java java /opt/jdk1.8.0_102/bin/java 2 | |
alternatives --auto java | |
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_102/bin/jar 2 | |
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_102/bin/javac 2 | |
alternatives --set jar /opt/jdk1.8.0_102/bin/jar | |
alternatives --set javac /opt/jdk1.8.0_102/bin/javac | |
cd /opt/ | |
rm -f jdk-8u102-linux-x64.tar.gz | |
} | |
add_repo_elasticsearch234_centos(){ | |
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch | |
echo -e "[elasticsearch-2.x] | |
name=Elasticsearch repository for 2.x packages | |
baseurl=https://packages.elastic.co/elasticsearch/2.x/centos | |
gpgcheck=1 | |
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch | |
enabled=1" > /etc/yum.repos.d/elasticsearch.repo | |
sed -i 's/^[\ ]\ //g' /etc/yum.repos.d/elasticsearch.repo | |
} | |
install_elasticsearch234_centos(){ | |
[ "${FRESH_INSTALL_CENTOS7}" == 1 ] && java_ok='n' | |
# Verificar se JAVA JDK 1.8.0 está instalado | |
[ -z "$java_ok" ] && read -p "Java JDK ok? (y/n)" java_ok | |
if [ "${java_ok}" == "n" ]; then | |
echo "Execute: install_jdk180" | |
install_jdk180 | |
yum install -y elasticsearch-2.3.4 | |
systemctl start elasticsearch | |
[ "$?" != 0 ] && /etc/init.d/elasticsearch start | |
elif [ "${java_ok}" == "y" ]; then | |
yum install -y elasticsearch-2.3.4 | |
systemctl start elasticsearch | |
[ "$?" != 0 ] && /etc/init.d/elasticsearch start | |
fi | |
} | |
add_repo_elasticsearch234_centos | |
install_elasticsearch234_centos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment