Last active
November 30, 2015 20:09
-
-
Save RafPe/8380dda9882d8e2007a0 to your computer and use it in GitHub Desktop.
Bash script to automate required actions for deploying whole docker ELK stack. ( update to http://rafpe.ninja/2015/10/04/docker-compose-elk-automated-setup/ ).Shortened to http://git.io/vBPqC
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
| #!/bin/bash | |
| dir=`pwd` | |
| if [ $# -lt 1 ]; then | |
| echo "Please specify clustername" | |
| exit | |
| fi | |
| sudo mkdir -p ${dir}/elasticsearch/data | |
| sudo mkdir -p ${dir}/elasticsearch/config | |
| sudo mkdir -p ${dir}/elasticsearch/data/$1 | |
| sudo mkdir -p ${dir}/logstash/agent | |
| sudo mkdir -p ${dir}/logstash/central | |
| sudo mkdir -p ${dir}/logstash/conf.d | |
| # If the file does not exist then download it | |
| if [ ! -f "${dir}/compose/elk/docker-compose.yml" ] | |
| then | |
| # clone from github | |
| git clone https://gist.github.com/60c3d7ff1b383e34990a.git ${dir}/compose/elk | |
| # move the file | |
| sudo mv ${dir}/compose/elk/docker-compose_elk_with_redis.yml ${dir}/compose/elk/docker-compose.yml | |
| fi | |
| if [ ! -f "${dir}/logstash/central/central.conf" ] | |
| then | |
| # clone from github | |
| git clone https://gist.github.com/6627a2bf05ff956a28a9.git ${dir}/logstash/central | |
| # move the file | |
| sudo mv ${dir}/logstash/central/logstash_config_central.conf ${dir}/logstash/central/central.conf | |
| fi | |
| if [ ! -f "${dir}/logstash/central/central.conf--" ] | |
| then | |
| rm ${dir}/logstash/central/central.conf-- | |
| fi | |
| if [ ! -f "${dir}/logstash/agent/agent.conf" ] | |
| then | |
| # clone from git | |
| git clone https://gist.github.com/0cd6594672ebfe1205a5.git ${dir}/logstash/agent | |
| # move the file | |
| sudo mv ${dir}/logstash/agent/logstash_config_agent_with_redis.conf ${dir}/logstash/agent/agent.conf | |
| fi | |
| if [ ! -f "${dir}/elasticsearch/config/elasticsearch.yml" ] | |
| then | |
| # clone from git | |
| git clone https://gist.github.com/c897a35f955c9b1aa052.git ${dir}/elasticsearch/config | |
| # move the file | |
| sudo mv ${dir}/elasticsearch/config/elasticsearch_sample_conf.yml ${dir}/elasticsearch/config/elasticsearch.yml | |
| fi | |
| sudo sed -i -- 's:_replaceme_:'"$dir"':g' ${dir}/compose/elk/docker-compose.yml | |
| sudo sed -i -- 's:_clustername_:'"$1"':g' ${dir}/compose/elk/docker-compose.yml | |
| sudo sed -i -- 's:_clustername_:'"$1"':g' ${dir}/logstash/central/central.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment