Last active
August 29, 2015 14:20
-
-
Save philwinder/9ad95352f0f41e8237da to your computer and use it in GitHub Desktop.
IVZ. Bootstrap shell script to install software and Vagrantfile. If you also want to install kibana, download the bootstrap_kibana.sh too!
This file contains hidden or 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
#!/usr/bin/env bash | |
# Install java | |
su | |
mkdir ~/Downloads | |
cd ~/Downloads | |
echo "Installing java" | |
if [ ! -f ./java.rpm ]; then | |
echo "Downloading java" | |
wget --quiet "http://javadl.sun.com/webapps/download/AutoDL?BundleId=106239" --output-document=java.rpm | |
fi | |
ln -s /usr/sbin/update-alternatives /usr/sbin/alternatives | |
rpm -ih --nodeps java.rpm | |
export JAVA_HOME=/usr/java/jre1.8.0_45/bin | |
# Install Elasticsearch | |
echo "Installing elasticsearch" | |
if [ ! -f ./elastic.tar.gz ]; then | |
echo "Downloading elasticsearch" | |
wget --quiet "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.2.tar.gz" | |
fi | |
tar -xf elasticsearch-1.5.2.tar.gz | |
mkdir /usr/share/elasticsearch | |
mv elasticsearch-1.5.2/* /usr/share/elasticsearch | |
chown vagrant /usr/share/elasticsearch | |
wget --quiet --no-check-certificate https://gist.githubusercontent.com/philwinder/09fcc5dc3a0f60979b3f/raw/elasticsearch | |
mv elasticsearch /etc/init.d | |
chmod +x /etc/init.d/elasticsearch | |
chkconfig --add elasticsearch | |
service elasticsearch start | |
sleep 20 | |
# Post some dummy data to elasticsearch | |
echo "Inserting test data to elasticsearch" | |
curl -XDELETE localhost:9200/* | |
curl -XPOST localhost:9200/_bulk -d ' | |
{ "create" : { "_index" : "log-1234", "_type" : "document", "_id" : "fd9fdas89" } } | |
{ "field1" : "testData" } | |
{ "create" : { "_index" : "log-1234", "_type" : "document", "_id" : "fd09fdsa" } } | |
{ "field1" : "testData" } | |
{ "create" : { "_index" : "log-5678", "_type" : "document", "_id" : "890fdshj" } } | |
{ "field1" : "testData" } | |
{ "create" : { "_index" : "log-9012", "_type" : "document", "_id" : "98fdsah" } } | |
{ "field1" : "testData" } | |
{ "create" : { "_index" : "monitor-1234", "_type" : "document", "_id" : "fd9fdajio9s89" } } | |
{ "field1" : "testData" } | |
{ "create" : { "_index" : "monitor-1234", "_type" : "document", "_id" : "fd09fdg3sa" } } | |
{ "field1" : "testData" } | |
{ "create" : { "_index" : "monitor-1234", "_type" : "document", "_id" : "890fdgf43shj" } } | |
{ "field1" : "testData" } | |
{ "create" : { "_index" : "monitor-5678", "_type" : "document", "_id" : "98fg432dsah" } } | |
{ "field1" : "testData" }' | |
# Install nginx and lua dependencies | |
zypper --quiet --no-gpg-checks --non-interactive install readline-devel pcre-devel libopenssl-devel | |
echo "Installing luaJIT" | |
wget --quiet http://luajit.org/download/LuaJIT-2.0.4.tar.gz | |
tar -xf LuaJIT-2.0.4.tar.gz | |
cd LuaJIT-2.0.4 | |
make | |
make install | |
cd .. | |
echo "Installing nginx with lua support" | |
wget http://openresty.org/download/ngx_openresty-1.4.3.9.tar.gz | |
tar -xf ngx_openresty-1.4.3.9.tar.gz | |
cd ngx_openresty-1.4.3.9 | |
./configure --with-luajit | |
make | |
make install | |
cd .. | |
# Make some folders to hold the user/pass information | |
mkdir -p /usr/local/openresty/nginx/conf | |
mkdir -p /usr/local/openresty/nginx/auth | |
# Download confs | |
echo "Downloading nginx and lua conf to /usr/local/openresty/nginx/conf" | |
cd /usr/local/openresty/nginx/conf | |
wget --quiet --no-check-certificate https://gist.githubusercontent.com/philwinder/5ec7628c6687794029b3/raw/nginx_authorize_by_lua.conf --output-document=nginx.conf | |
wget --quiet --no-check-certificate https://gist.githubusercontent.com/philwinder/5ec7628c6687794029b3/raw/authorize.lua | |
# Download example htpasswd file | |
echo "Downloading example htpasswd file to /etc/nginx/auth" | |
cd /usr/local/openresty/nginx/auth | |
wget --quiet --no-check-certificate https://gist.githubusercontent.com/philwinder/5ec7628c6687794029b3/raw/htpasswd | |
echo "Setting up init.d script" | |
cd /etc/init.d | |
wget --quiet --no-check-certificate https://gist.githubusercontent.com/vdel26/8805927/raw/nginx | |
chmod 755 nginx | |
echo "Starting nginx" | |
# Start nginx | |
chkconfig --add nginx | |
service nginx start |
This file contains hidden or 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
#!/usr/bin/env bash | |
su | |
# Bonus, install Kibana. | |
echo "Installing Kibana" | |
cd /opt | |
wget --quiet https://download.elastic.co/kibana/kibana/kibana-4.0.2-linux-x64.tar.gz | |
tar xf kibana-4.0.2-linux-x64.tar.gz | |
rm kibana-4.0.2-linux-x64.tar.gz | |
mv kibana-4.0.2-linux-x64 kibana | |
cd /etc/init.d | |
wget --quiet --no-check-certificate https://gist.githubusercontent.com/philwinder/a86b5528608fd0295c60/raw/kibana4 --output-document=kibana4 | |
chmod 755 kibana4 | |
echo "Starting Kibana4" | |
# Start nginx | |
chkconfig --add kibana4 | |
service kibana4 start | |
echo "Updating nginx config to allow kibana at the address http://localhost:8080/kibana4" | |
service nginx stop | |
cd /usr/local/openresty/nginx/conf | |
rm -f nginx.conf | |
wget --quiet --no-check-certificate https://gist.githubusercontent.com/philwinder/5ec7628c6687794029b3/raw/nginx_authorize_by_lua_kibana.conf --output-document=nginx.conf | |
service nginx start |
This file contains hidden or 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "idar/sles11sp3" | |
# config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "2048" | |
end | |
# Provision software on instance using shell script | |
if File.exists?("bootstrap.sh") | |
config.vm.provision :shell, path: "bootstrap.sh" | |
end | |
if File.exists?("bootstrap_kibana.sh") | |
config.vm.provision :shell, path: "bootstrap_kibana.sh" | |
end | |
# Forward ports from VM to local machine. | |
config.vm.network :forwarded_port, host: 8080, guest: 8080 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment