-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcloud_install.sh
executable file
·172 lines (150 loc) · 5.08 KB
/
cloud_install.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
#
# Installs a specific SolrCloud
#
###############################################################################
# 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
SHOME=`pwd`
: ${CACHE:=`pwd`/cache}
: ${CLOUD:=`pwd`/cloud}
: ${VERSION:="$1"}
popd > /dev/null
function usage() {
echo "Usage: ./cloud_install.sh <`echo \"$VERSIONS\" | sed 's/ / | /g'`>"
exit $1
}
check_parameters() {
if [[ -z "$VERSION" ]]; then
echo "No Solr version specified."$'\n'
usage
fi
}
################################################################################
# FUNCTIONS
################################################################################
# Input: Package
function check_package() {
if [[ ! -s "${CACHE}/$1" ]]; then
echo "Activating get_solr.sh as package $1 is not available at ${CACHE}/$1"
SPECIFIC_SOLR="$VERSION"
. $SHOME/get_solr.sh
if [ ! -s ${CACHE}/$1 ]; then
>&2 "Error: Package $P not available after call to get_solr.sh"
exit 2
fi
fi
}
function zoo() {
local ZPACK="$1"
local FOLDER=`echo $ZPACK | sed -e 's/.gz$//' -e 's/.tar$//' -e 's/.tgz//'`
echo " - Installing ZooKeeper ensemble of size $ZOOS"
local ZPORT=$ZOO_BASE_PORT
for Z in `seq 1 $ZOOS`; do
if [ ! -d zoo$Z ]; then
echo " - Copying ZooKeeper files for instance $Z"
tar -xzovf ${CACHE}/$ZPACK > /dev/null
mv $FOLDER zoo$Z
else
echo " - ZooKeeper files for instance $Z already exists"
fi
local ZCONF="zoo$Z/conf/zoo.cfg"
if [ ! -s "$ZCONF" ]; then
echo " - Creating new setup for ZooKeeper $Z"
echo "dataDir=`pwd`/zoo$Z/data" >> "$ZCONF"
echo "clientPort=$ZPORT" >> "$ZCONF"
else
echo " - ZooKeeper $Z already configured"
fi
local ZPORT=$(( ZPORT + 1 ))
done
}
function solr() {
local SPACK="$1"
local FOLDER=`echo $SPACK | sed -e 's/[.]gz$//' -e 's/[.]tar$//' -e 's/[.]tgz//'`
echo " - Installing $SOLRS Solrs"
tar -xzovf ${CACHE}/$SPACK > /dev/null
if [ solr-* != $FOLDER ]; then
mv solr-* $FOLDER
fi
if [ "." == ".`echo \" $LAYOUT2_VERSIONS \" | grep \" $DEST \"`" ]; then
# We inject the JARs into the WAR to avoid fiddling with solrconfig.xml
pushd $FOLDER/example/webapps/ > /dev/null
if [ ! "." == ".$SPARSE_WAR" ]; then
echo " - Using sparse Solr WAR as Solr $VERSION"
cp ${CACHE}/$SPARSE_WAR solr.war
fi
mkdir -p WEB-INF/lib/
cp ../../dist/solr-analysis-extras-*.jar WEB-INF/lib/
cp ../../contrib/analysis-extras/lucene-libs/lucene-analyzers-icu-*.jar WEB-INF/lib/
cp ../../contrib/analysis-extras/lib/icu4j*.jar WEB-INF/lib/
echo " - Patching Solr $VERSION WAR with needed JARs"
zip solr.war WEB-INF > /dev/null
# rm -r WEB_INF/
popd > /dev/null
fi
for S in `seq 1 $SOLRS`; do
if [ ! -d solr$S ]; then
echo " - Copying Solr files for instance $S"
cp -r $FOLDER solr$S
# The three libraries below are needed for collator sorting
if [ ! "." == ".`echo \" $LAYOUT2_VERSIONS \" | grep \" $DEST \"`" ]; then
local SOLR_LIB=solr$S/server/solr/lib/
mkdir -p $SOLR_LIB
cp $FOLDER/dist/solr-analysis-extras-*.jar $SOLR_LIB
cp $FOLDER/contrib/analysis-extras/lucene-libs/lucene-analyzers-icu-*.jar $SOLR_LIB
cp $FOLDER/contrib/analysis-extras/lib/icu4j*.jar $SOLR_LIB
fi
else
echo " - Solr $S already exists"
fi
done
}
function install() {
local VERSION="$1"
# Shared setup
mkdir -p ${CLOUD}
DEST=$VERSION
echo "- Installing SolrCloud $DEST at ${CLOUD}/$DEST"
if [ $VERSION == 4.10.4-sparse ]; then
SPARSE_WAR=sparse-4.10.war
VERSION=4.10.4
fi
SPACK=solr-${VERSION}.tgz
ZPACK=$(basename "$ZOO_URL")
check_package $SPACK
check_package $ZPACK
echo " - Source packages: $SPACK and $ZPACK"
mkdir -p ${CLOUD}/$DEST
pushd ${CLOUD}/$DEST > /dev/null
zoo $ZPACK
# Version specific parts
if [ ! "." == ".`echo \" $VERSIONS \" | grep \" $DEST \"`" ]; then
solr $SPACK
popd > /dev/null # ${CLOUD}/$DEST
return
fi
>&2 echo "Error: Support for Solr version '$DEST' has not been implemented yet"
usage 1
}
###############################################################################
# CODE
###############################################################################
check_parameters "$@"
pushd ${BASH_SOURCE%/*} > /dev/null
if [[ "." == ".$@" ]]; then
install "$VERSION"
else
for V in $@; do
install $V
done
fi
popd > /dev/null