Commit 5c4f1aa8 authored by Cristian Weiland's avatar Cristian Weiland

Merge branch 'issue/73' into 'develop'

Issue #73: made user and password be optional in rename_index

See merge request !36
parents e1b74bad af422f1d
# Input: Kibana/ElasticSearch's user and password and two index names: the script will rename the index with the first name to the second one.
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <user:password> <old-index> <new-index>"
if [[ "$#" -lt 2 || "$#" -gt 3 ]]; then
echo "Usage: $0 <old-index> <new-index> <user:password>"
echo "Example: $0 myuser:mypass ufpr-csv-2016-11 ufpr-servidores-2016-11"
exit
fi
userAndPasswd=$1
sourceIndex=$2
destIndex=$3
sourceIndex=$1
destIndex=$2
source ./config.sh
# Copy old index to new index...
curl -XPOST -u $userAndPasswd "${dbHostname}_reindex?pretty" -H 'Content-Type: application/json' -d'
{
"source": {
"index": "'$sourceIndex'"
},
"dest": {
"index": "'$destIndex'"
}
}
'
if [[ "$#" -eq 3 ]]; then
userAndPasswd=$3
# Copy old index to new index...
curl -XPOST -u $userAndPasswd "${dbHostname}_reindex?pretty" -H 'Content-Type: application/json' -d'
{
"source": {
"index": "'$sourceIndex'"
},
"dest": {
"index": "'$destIndex'"
}
}
'
# Delete old index...
curl -XDELETE -u $userAndPasswd "${dbHostname}$sourceIndex?pretty"
# Delete old index...
curl -XDELETE -u $userAndPasswd "${dbHostname}$sourceIndex?pretty"
else
# Copy old index to new index...
curl -XPOST "${dbHostname}_reindex?pretty" -H 'Content-Type: application/json' -d'
{
"source": {
"index": "'$sourceIndex'"
},
"dest": {
"index": "'$destIndex'"
}
}
'
# Delete old index...
curl -XDELETE "${dbHostname}$sourceIndex?pretty"
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment