1#!/bin/bash 2 3set -e 4 5SOLR_VERSION=6.5.0 6SOLR_DIR=solr 7 8 9SOLR_PORT=9001 10 11cd $(dirname $0) 12 13export TEST_ROOT=$(pwd) 14 15export SOLR_ARCHIVE="${SOLR_VERSION}.tgz" 16 17if [ -d "${HOME}/download-cache/" ]; then 18 export SOLR_ARCHIVE="${HOME}/download-cache/${SOLR_ARCHIVE}" 19fi 20 21if [ -f ${SOLR_ARCHIVE} ]; then 22 # If the tarball doesn't extract cleanly, remove it so it'll download again: 23 tar -tf ${SOLR_ARCHIVE} > /dev/null || rm ${SOLR_ARCHIVE} 24fi 25 26if [ ! -f ${SOLR_ARCHIVE} ]; then 27 SOLR_DOWNLOAD_URL=$(python get-solr-download-url.py $SOLR_VERSION) 28 curl -Lo $SOLR_ARCHIVE ${SOLR_DOWNLOAD_URL} || (echo "Unable to download ${SOLR_DOWNLOAD_URL}"; exit 2) 29fi 30 31echo "Extracting Solr ${SOLR_ARCHIVE} to `pwd`/${SOLR_DIR}" 32rm -rf ${SOLR_DIR} 33mkdir ${SOLR_DIR} 34FULL_SOLR_DIR=$(readlink -f ./${SOLR_DIR}) 35tar -C ${SOLR_DIR} -xf ${SOLR_ARCHIVE} --strip-components=1 36 37export SOLR_LOGS_DIR="${FULL_SOLR_DIR}/logs" 38 39install -d ${SOLR_LOGS_DIR} 40 41echo "Changing into ${FULL_SOLR_DIR} " 42 43cd ${FULL_SOLR_DIR} 44 45echo "Creating Solr Core" 46./bin/solr start -p ${SOLR_PORT} 47./bin/solr create -c collection1 -p ${SOLR_PORT} -n basic_config 48./bin/solr create -c mgmnt -p ${SOLR_PORT} 49 50echo "Solr system information:" 51curl --fail --silent 'http://localhost:9001/solr/admin/info/system?wt=json&indent=on' | python -m json.tool 52./bin/solr stop -p ${SOLR_PORT} 53 54CONF_DIR=${TEST_ROOT}/confdir 55CORE_DIR=${FULL_SOLR_DIR}/server/solr/collection1 56mv ${CORE_DIR}/conf/managed-schema ${CORE_DIR}/conf/managed-schema.old 57cp ${CONF_DIR}/* ${CORE_DIR}/conf/ 58 59echo 'Starting server' 60cd server 61# We use exec to allow process monitors to correctly kill the 62# actual Java process rather than this launcher script: 63export CMD="java -Djetty.port=${SOLR_PORT} -Djava.awt.headless=true -Dapple.awt.UIElement=true -jar start.jar --module=http -Dsolr.install.dir=${FULL_SOLR_DIR} -Dsolr.log.dir=${SOLR_LOGS_DIR}" 64 65if [ -z "${BACKGROUND_SOLR}" ]; then 66 exec $CMD 67else 68 exec $CMD >/dev/null & 69fi 70