Nodes=$(curl -s -XGET 'http://'$(hostname)':9200/_nodes/process?pretty=true' |grep nodes -A 1 |grep -v nodes |cut -d \" -f2 )
for Index in $(curl -s -XGET 'http://'$(hostname)':9200/_cat/shards' | grep UNASSIGNED |awk '{print $1}'|sort |uniq)
do
for Shards in $(curl -s -XGET 'http://'$(hostname)':9200/_cat/shards' | grep UNASSIGNED | grep $Index | awk '{print $2}'|sort|uniq)
do
curl -s -XPOST 'http://'$(hostname)':9200/_cluster/reroute' -d '{"commands":[{"allocate":{"index":"'$Index'","shard":'$Shards',"node":"'$Nodes'","allow_primary":"true"}}]}'
done
done