-
Notifications
You must be signed in to change notification settings - Fork 76
/
grab-solr.sh
executable file
·136 lines (119 loc) · 3.58 KB
/
grab-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
#!/usr/bin/env sh
#
# Script to grab Solr and embed in priv dir. This script assumes it is
# being called from root dir or tools dir.
#
# Usage:
# ./grab-solr.sh
#
# specify SOLR_PKG_DIR to skip the solr download and use a local copy
set -e
if [ $(basename $PWD) != "tools" ]
then
cd tools
fi
PRIV_DIR=../priv
CONF_DIR=$PRIV_DIR/conf
SOLR_DIR=$PRIV_DIR/solr
BUILD_DIR=../build
VSN=solr-4.10.4-yz-2
FILENAME=$VSN.tgz
TMP_DIR=/var/tmp/yokozuna
TMP_FILE=$TMP_DIR/$FILENAME
SRC_DIR=$BUILD_DIR/$VSN
EXAMPLE_DIR=$SRC_DIR/example
COL1_DIR=$EXAMPLE_DIR/solr/collection1
check_for_solr()
{
# $SOLR_DIR is preloaded with xml files, so check for the generated jar
test -e $SOLR_DIR/start.jar
}
download()
{
if which wget > /dev/null; then
wget --no-check-certificate --progress=dot:mega $1
elif which curl > /dev/null; then
curl --insecure --progress-bar -O $1
elif which fetch > /dev/null; then
fetch --no-verify-peer $1
fi
}
get_solr()
{
if [ -z ${SOLR_PKG_DIR+x} ]
then
if [ -e $TMP_FILE ]; then
echo "Using cached copy of Solr $TMP_FILE"
ln -s $TMP_FILE $FILENAME
else
echo "Pulling Solr from S3"
download "http://s3.amazonaws.com/files.basho.com/solr/$FILENAME"
if [ -d $TMP_DIR ]; then
cp $FILENAME $TMP_DIR
else
mkdir $TMP_DIR
cp $FILENAME $TMP_DIR
fi
fi
else
# This is now obsolete thanks to implicit caching above
# but will leave in for now as to not break anyone.
echo "Using local copy of Solr $SOLR_PKG_DIR/$FILENAME"
cp $SOLR_PKG_DIR/$FILENAME ./
fi
tar zxf $FILENAME
}
if ! check_for_solr
then
echo "Create dir $BUILD_DIR"
if [ ! -e $BUILD_DIR ]; then
mkdir $BUILD_DIR
fi
cd $BUILD_DIR
if [ ! -e $SRC_DIR ]
then
get_solr
fi
echo "Creating Solr dir $SOLR_DIR"
# Explicitly copy files needed rather than copying everything and
# removing which requires using cp -rn (since $SOLR_DIR/etc has files
# which shouldn't be overwritten). For whatever reason, cp -n causes
# non-zero exit code when files that would have been overwritten are
# detected.
cp -r $EXAMPLE_DIR/etc/create-solrtest.keystore.sh $SOLR_DIR/etc
cp -r $EXAMPLE_DIR/etc/webdefault.xml $SOLR_DIR/etc
cp -r $EXAMPLE_DIR/lib $SOLR_DIR
cp -r $COL1_DIR/conf/lang $CONF_DIR
cp $COL1_DIR/conf/protwords.txt $CONF_DIR
cp $COL1_DIR/conf/stopwords.txt $CONF_DIR
cp $COL1_DIR/conf/synonyms.txt $CONF_DIR
cp $COL1_DIR/conf/mapping-* $CONF_DIR
# TODO: does resources need to be copied?
cp -r $EXAMPLE_DIR/resources $SOLR_DIR
cp -r $EXAMPLE_DIR/solr-webapp $SOLR_DIR
cp -r $EXAMPLE_DIR/start.jar $SOLR_DIR
cp -r $EXAMPLE_DIR/webapps $SOLR_DIR
echo "Solr dir created successfully"
fi
JAVA_LIB=../priv/java_lib
YZ_JAR_VSN=3
YZ_JAR_NAME=yokozuna-$YZ_JAR_VSN.jar
if [ ! -e $JAVA_LIB/$YZ_JAR_NAME ]
then
if [ ! -d $JAVA_LIB ]
then
mkdir $JAVA_LIB
fi
echo "Downloading $YZ_JAR_NAME"
download "http://s3.amazonaws.com/files.basho.com/yokozuna/$YZ_JAR_NAME"
mv $YZ_JAR_NAME $JAVA_LIB/$YZ_JAR_NAME
fi
EXT_LIB=../priv/solr/lib/ext
MON_JAR_VSN=1
MON_JAR_NAME=yz_monitor-$MON_JAR_VSN.jar
if [ ! -e $EXT_LIB/$MON_JAR_NAME ]
then
echo "Downloading $MON_JAR_NAME"
download "http://s3.amazonaws.com/files.basho.com/yokozuna/$MON_JAR_NAME"
mv $MON_JAR_NAME $EXT_LIB/$MON_JAR_NAME
fi