Skip to content

Instantly share code, notes, and snippets.

@Markbnj
Created August 11, 2015 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Markbnj/f1c14d69b484904266ec to your computer and use it in GitHub Desktop.
Save Markbnj/f1c14d69b484904266ec to your computer and use it in GitHub Desktop.
Update elasticsearch.yml and launch the service
# Script to update elasticsearch.yml and launch the service. In this
# scenario the service is being launched inside a container on ec2
# but the technique is easily generalizable.
#
# Expects the following environment vars to be set inside the container
#
# HOST_IP - the IP address of the host running the container
# AWS_ACCESS_KEY - the AWS account access key
# AWS_SECRET_KEY - the AWS account secret key
# CLUSTER_NAME - the name of the ES cluster to join
#
echo "Updating elasticsearch configuration..."
echo "Cluster name :" $CLUSTER_NAME
sed -i.bak -e"s:%1:${CLUSTER_NAME}:g" /etc/elasticsearch/elasticsearch.yml
echo "Host ip :" $HOST_IP
sed -i.bak -e"s:%2:${HOST_IP}:g" /etc/elasticsearch/elasticsearch.yml
echo "Cloud key :" $AWS_ACCESS_KEY
sed -i.bak -e"s:%3:${AWS_ACCESS_KEY}:g" /etc/elasticsearch/elasticsearch.yml
echo "Cloud secret :" $AWS_SECRET_KEY
sed -i.bak -e"s:%4:${AWS_SECRET_KEY}:g" /etc/elasticsearch/elasticsearch.yml
rm /etc/elasticsearch/elasticsearch.yml.bak
echo "Completed. Starting service..."
service elasticsearch start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment