-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcloud_delete.sh
executable file
·60 lines (51 loc) · 1.71 KB
/
cloud_delete.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#
# Deletes a SolrCloud collection
#
# TODO: Figure out which cloud is running and stop it, so that version need not be specified
#
###############################################################################
# CONFIG
###############################################################################
if [[ -s "cloud.conf" ]]; then
source "cloud.conf" # Local overrides
fi
pushd ${BASH_SOURCE%/*} > /dev/null
if [[ -s "cloud.conf" ]]; then
source "cloud.conf" # Project overrides
fi
source general.conf
: ${CLOUD:=`pwd`/cloud}
: ${SOLR:="$HOST:$SOLR_BASE_PORT/solr"}
popd > /dev/null
function usage() {
echo "Usage: ./cloud_delete.sh collection"
exit $1
}
check_parameters() {
if [ ! -d ${CLOUD}/$VERSION ]; then
>&2 echo "The Solr version $VERSION is not installed."
>&2 echo "Please run ./install_cloud.sh $VERSION"
usage 3
fi
COLLECTION="$1"
if [[ "." == ".$COLLECTION" ]]; then
echo "No collection specified. Available collections are"
curl -s "$SOLR/admin/collections?action=LIST" | grep -o "<arr name=.collections.*</arr>" | grep -o "<str>[^<]*</str>" | sed 's/<\/*str>//g'
echo ""
usage 4
fi
}
################################################################################
# FUNCTIONS
################################################################################
delete_collection() {
DELETE_URL="$SOLR/admin/collections?action=DELETE&name=${COLLECTION}"
echo "Calling $DELETE_URL"
curl "$DELETE_URL"
}
###############################################################################
# CODE
###############################################################################
check_parameters "$@"
delete_collection