Skip to content

Instantly share code, notes, and snippets.

@tkoeppen
Last active October 7, 2015 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tkoeppen/3236713 to your computer and use it in GitHub Desktop.
Save tkoeppen/3236713 to your computer and use it in GitHub Desktop.
install elasticsearch on Ubuntu 12.04 (precise)
#!/bin/bash
# 0.1 2012 install elasticsearch VERSION on Ubuntu 12.04 (precise) @tomondev
# 0.2 2013-06-18 upgrade to es 0.90.1 @tomondev
# 0.3 2013-06-27 upgrade to es 0.90.2 @tomondev
VERSION=0.90.2
# Check for dependencies
check_deps () {
DEPS="curl unzip"
echo ".. check deps: $DEPS"
for i in $DEPS ; do
dpkg-query -W -f='${Package}\n' | grep ^$i$ > /dev/null
if [ $? != 0 ] ; then
echo ".. installing package: $i"
sudo apt-get install $i -y
fi
done
}
# download configured elasticsearch version, unzip
download_init_elasticsearch () {
echo ".. download and initialize elasticsearch $VERSION"
cd /tmp
curl -OL -k https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$VERSION.zip
unzip elasticsearch-$VERSION.zip
rm elasticsearch-$VERSION.zip
sudo mv elasticsearch-$VERSION /usr/local/
if [ -L /usr/local/elasticsearch ] ; then
sudo rm /usr/local/elasticsearch
fi
sudo ln -s /usr/local/elasticsearch-$VERSION /usr/local/elasticsearch
# fix wrong permission from the original zip
sudo find /usr/local/elasticsearch/ -type d -exec chmod 755 {} \;
}
download_init_servicewrapper () {
echo ".. download and install elasticsearch servicewrapper"
curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
sudo mv *servicewrapper*/service /usr/local/elasticsearch/bin/
rm -Rf *servicewrapper*
sudo chown -R root:root /usr/local/elasticsearch-$VERSION
# install init.d
if [ -L /etc/init.d/elasticsearch ] ; then
sudo rm /etc/init.d/elasticsearch
fi
sudo /usr/local/elasticsearch/bin/service/elasticsearch install
if [ -L /usr/local/bin/elasticsearch ]
then sudo rm /usr/local/bin/elasticsearch
fi
sudo ln -s `readlink -f /usr/local/elasticsearch/bin/service/elasticsearch` /usr/local/bin/elasticsearch
}
### MAIN program
check_deps
download_init_elasticsearch
download_init_servicewrapper
# fix missing logs dir for first wrapper start
sudo mkdir /usr/local/elasticsearch/logs
# eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment