Skip to content

Instantly share code, notes, and snippets.

@jdowning
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save jdowning/5056522b4efc9a89ae78 to your computer and use it in GitHub Desktop.

Select an option

Save jdowning/5056522b4efc9a89ae78 to your computer and use it in GitHub Desktop.
Update cluster.routing.allocation.enable in Elasticsearch
#!/bin/bash -e
if [[ "$1" == "all" || "$1" == "none" ]]; then
echo -n -e "Setting cluster.routing.allocation.enable to \e[0;33m${1}\e[0m..."
resp=$(curl -s -XPUT localhost:9200/_cluster/settings?pretty -d "{\"transient\":{\"cluster.routing.allocation.enable\":\"${1}\"}}" | awk -F: '/acknowledged/ {print $2}')
if [[ "$resp" == " true," ]]; then
echo "Done!"
else
echo "Failed!"
echo $resp
exit 1
fi
else
echo "Usage: $0 [all|none]"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment