forked from moliware/travis-solr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravis-solr.sh
executable file
·153 lines (137 loc) · 4.26 KB
/
travis-solr.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
#!/usr/bin/env bash
SOLR_PORT=${SOLR_PORT:-8983}
download() {
echo "Downloading solr from $1..."
curl -s $1 | tar xz
echo "Downloaded"
}
is_solr_up(){
http_code=`echo $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:$SOLR_PORT/solr/admin/ping")`
return `test $http_code = "200"`
}
wait_for_solr(){
while ! is_solr_up; do
sleep 3
done
}
run() {
echo "Starting solr on port ${SOLR_PORT}..."
cd $1/example
if [ $DEBUG ]
then
java -Djetty.port=$SOLR_PORT -jar start.jar &
else
java -Djetty.port=$SOLR_PORT -jar start.jar > /dev/null 2>&1 &
fi
wait_for_solr
cd ../../
echo "Started"
}
post_some_documents() {
java -Dtype=application/json -Durl=http://localhost:$SOLR_PORT/solr/update/json -jar $1/example/exampledocs/post.jar $2
}
download_and_run() {
case $1 in
3.5.0)
url="http://archive.apache.org/dist/lucene/solr/3.5.0/apache-solr-3.5.0.tgz"
dir_name="apache-solr-3.5.0"
dir_conf="conf/"
;;
3.6.0)
url="http://archive.apache.org/dist/lucene/solr/3.6.0/apache-solr-3.6.0.tgz"
dir_name="apache-solr-3.6.0"
dir_conf="conf/"
;;
3.6.1)
url="http://archive.apache.org/dist/lucene/solr/3.6.1/apache-solr-3.6.1.tgz"
dir_name="apache-solr-3.6.1"
dir_conf="conf/"
;;
3.6.2)
url="http://archive.apache.org/dist/lucene/solr/3.6.2/apache-solr-3.6.2.tgz"
dir_name="apache-solr-3.6.2"
dir_conf="conf/"
;;
4.0.0)
url="http://archive.apache.org/dist/lucene/solr/4.0.0/apache-solr-4.0.0.tgz"
dir_name="apache-solr-4.0.0"
dir_conf="collection1/conf/"
;;
4.1.0)
url="http://archive.apache.org/dist/lucene/solr/4.1.0/solr-4.1.0.tgz"
dir_name="solr-4.1.0"
dir_conf="collection1/conf/"
;;
4.2.0)
url="http://archive.apache.org/dist/lucene/solr/4.2.0/solr-4.2.0.tgz"
dir_name="solr-4.2.0"
dir_conf="collection1/conf/"
;;
4.2.1)
url="http://archive.apache.org/dist/lucene/solr/4.2.1/solr-4.2.1.tgz"
dir_name="solr-4.2.1"
dir_conf="collection1/conf/"
;;
4.3.1)
url="http://archive.apache.org/dist/lucene/solr/4.3.1/solr-4.3.1.tgz"
dir_name="solr-4.3.1"
dir_conf="collection1/conf/"
;;
4.4.0)
url="http://archive.apache.org/dist/lucene/solr/4.4.0/solr-4.4.0.tgz"
dir_name="solr-4.4.0"
dir_conf="collection1/conf/"
;;
4.5.0)
url="http://archive.apache.org/dist/lucene/solr/4.5.0/solr-4.5.0.tgz"
dir_name="solr-4.5.0"
dir_conf="collection1/conf/"
;;
4.5.1)
url="http://archive.apache.org/dist/lucene/solr/4.5.1/solr-4.5.1.tgz"
dir_name="solr-4.5.1"
dir_conf="collection1/conf/"
;;
4.6.0)
url="http://archive.apache.org/dist/lucene/solr/4.6.0/solr-4.6.0.tgz"
dir_name="solr-4.6.0"
dir_conf="collection1/conf/"
;;
4.6.1)
url="http://archive.apache.org/dist/lucene/solr/4.6.1/solr-4.6.1.tgz"
dir_name="solr-4.6.1"
dir_conf="collection1/conf/"
;;
esac
download $url
# copies custom configurations
for file in $SOLR_CONFS
do
if [ -f $file ]
then
cp $file $dir_name/example/solr/$dir_conf
echo "Copied $file into solr conf directory."
fi
done
# Run solr
run $dir_name $SOLR_PORT
# Post documents
if [ -z "$SOLR_DOCS" ]
then
echo "$SOLR_DOCS not defined, skipping initial indexing"
else
echo "Indexing $SOLR_DOCS"
post_some_documents $dir_name $SOLR_DOCS
fi
}
check_version() {
case $1 in
3.5.0|3.6.0|3.6.1|3.6.2|4.0.0|4.1.0|4.2.0|4.2.1|4.3.1|4.4.0|4.5.0|4.5.1|4.6.0|4.6.1);;
*)
echo "Sorry, $1 is not supported or not valid version."
exit 1
;;
esac
}
check_version $SOLR_VERSION
download_and_run $SOLR_VERSION