-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_current_dir_as_core
executable file
·59 lines (45 loc) · 1.25 KB
/
load_current_dir_as_core
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
#!/bin/bash
dir=`pwd`
port=$1
core=$2
function usage() {
echo
echo "Usage: load_core.sh port [corename]"
echo " * port defaults to 8025"
echo " * Corename defaults to the name of the current directory"
echo " * Solr url will be http://localhost:$port/solr unless \$SOLR_ROOT is set,"
echo " in which case port is ignored"
echo
exit 1
}
if [ "$1" == "-h" ]; then
usage
fi
if [ $# -eq 0 ]; then
usage
fi
if [ -z $core ]; then
defaultcore=1
core=`basename $(pwd)`
fi
if [ -z $SOLR_ROOT ]; then
SOLR_ROOT="http://localhost:${port}/solr"
defaultsolr=1
fi
echo -e "\n**************************************************************"
echo -e "\n"
if [ ! -z ${defaultsolr+x} ] ; then
echo -e "\$SOLR_URL not set"
echo -e " Targeting '${SOLR_ROOT}' taken from defaults."
else
echo -e " Targeting '$SOLR_ROOT'"
fi
echo -e "\n"
if [ ! -z ${defaultcore+x} ]; then
echo -e "No argument given for corename"
echo -e " '$core' taken from name of current directory"
else
echo -e " '$core' used as corename (from second argument)"
fi
echo "Loading config in ${dir}"
curl "${SOLR_ROOT}/admin/cores?action=CREATE&name=$core&config=solrconfig.xml&dataDir=data&instanceDir=$dir&wt=json"