Skip to content

Instantly share code, notes, and snippets.

@nicksherron
Last active November 24, 2018 15:28
Show Gist options
  • Select an option

  • Save nicksherron/5afd897f881257cc282f4b35c622e826 to your computer and use it in GitHub Desktop.

Select an option

Save nicksherron/5afd897f881257cc282f4b35c622e826 to your computer and use it in GitHub Desktop.
install elasticsearch and kibana 6.5.1 on ubuntu
#!/bin/bash
#ONE LINE
#sudo wget -Nnv 'https://gist.githubusercontent.com/nsherron90/5afd897f881257cc282f4b35c622e826/raw/2072030410ea3d7956823e199ae4ef25b87079f9/elk.sh' && bash elk.sh && rm -f elk.sh
# Checking whether user has enough permission to run this script
sudo -n true
if [ $? -ne 0 ]
then
echo "This script requires user to have passwordless sudo access"
exit
fi
dependency_check_deb() {
java -version
if [ $? -ne 0 ]
then
# Installing Java 8 if it's not installed
sudo apt-get install openjdk-8-jre-headless -y
# Checking if java installed is less than version 7. If yes, installing Java 7. As logstash & Elasticsearch require Java 7 or later.
elif [ "`java -version 2> /tmp/version && awk '/version/ { gsub(/"/, "", $NF); print ( $NF < 1.8 ) ? "YES" : "NO" }' /tmp/version`" == "YES" ]
then
sudo apt-get install openjdk-8-jre-headless -y
fi
}
debian_elk() {
# resynchronize the package index files from their sources.
sudo apt-get update
# Downloading debian package of elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.1.deb
# Install debian package of elasticsearch
sudo dpkg -i elasticsearch-6.5.1.deb
# install kibana
sudo apt-get install apt-transport-https
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.5.1-amd64.deb
sudo dpkg -i kibana-6.5.1-amd64.deb
# Starting The Services
sudo systemctl restart elasticsearch
sudo systemctl enable elasticsearch
sudo systemctl restart kibana
sudo systemctl enable kibana
}
# Installing ELK Stack
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]
then
echo " It's a Debian based system"
dependency_check_deb
debian_elk
elif [ "$(grep -Ei 'fedora|redhat|centos' /etc/*release)" ]
then
echo "It's a RedHat based system."
dependency_check_rpm
rpm_elk
else
echo "This script doesn't support ELK installation on this OS."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment