11#! /usr/bin/env bash
22
3- default_config_files[1]=' src/lib/Resources/config/solr/schema.xml'
4- default_config_files[2]=' src/lib/Resources/config/solr/custom-fields-types.xml'
5- default_config_files[3]=' src/lib/Resources/config/solr/language-fieldtypes.xml'
3+ SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
4+
5+ SOLR_VERSION=${SOLR_VERSION:- ' 9.8.1' }
6+
7+ if [[ " ${SOLR_VERSION} " =~ ^9\. ]]; then
8+ default_config_files[1]=" ${SCRIPT_DIR} /../src/lib/Resources/config/solr/managed-schema.xml"
9+ default_config_files[2]=" ${SCRIPT_DIR} /../src/lib/Resources/config/solr/custom-fields-types-solr9.xml"
10+ else
11+ default_config_files[1]=" ${SCRIPT_DIR} /../src/lib/Resources/config/solr/schema.xml"
12+ default_config_files[2]=" ${SCRIPT_DIR} /../src/lib/Resources/config/solr/custom-fields-types.xml"
13+ fi
14+
15+ default_config_files[3]=" ${SCRIPT_DIR} /../src/lib/Resources/config/solr/language-fieldtypes.xml"
616
717default_cores[0]=' core0'
818default_cores[1]=' core1'
@@ -16,7 +26,6 @@ default_shards=('shard0')
1626
1727SOLR_PORT=${SOLR_PORT:- 8983}
1828SOLR_DIR=${SOLR_DIR:- ' __solr' }
19- SOLR_VERSION=${SOLR_VERSION:- ' 8.11.2' }
2029SOLR_INSTALL_DIR=" ${SOLR_DIR} /${SOLR_VERSION} "
2130SOLR_DEBUG=${SOLR_DEBUG:- false}
2231SOLR_HOME=${SOLR_HOME:- ' ezcloud' }
@@ -32,7 +41,13 @@ SOLR_CLOUD=${SOLR_CLOUD:-'no'}
3241
3342INSTALL_DIR=" ${SOLR_DIR} /${SOLR_VERSION} "
3443HOME_DIR=" ${INSTALL_DIR} /server/${SOLR_HOME} "
35- TEMPLATE_DIR=" ${HOME_DIR} /template"
44+
45+ if [[ " ${SOLR_VERSION} " =~ ^9\. ]]; then
46+ TEMPLATE_DIR=" ${HOME_DIR} /template/conf"
47+ else
48+ TEMPLATE_DIR=" ${HOME_DIR} /template"
49+ fi
50+
3651START_SCRIPT=" ./${INSTALL_DIR} /bin/solr"
3752ZOOKEEPER_CLI_SCRIPT=" ./${INSTALL_DIR} /server/scripts/cloud-scripts/zkcli.sh"
3853ZOOKEEPER_HOST=" "
4560download () {
4661 case ${SOLR_VERSION} in
4762 # PS!!: Append versions and don't remove old ones (except in major versions), used in integration tests from other packages!
63+ 9.* )
64+ url=" https://archive.apache.org/dist/solr/solr/${SOLR_VERSION} /solr-${SOLR_VERSION} .tgz"
65+ ;;
4866 7.7.* | 8.* )
4967 url=" https://archive.apache.org/dist/lucene/solr/${SOLR_VERSION} /solr-${SOLR_VERSION} .tgz"
5068 ;;
@@ -104,8 +122,8 @@ copy_file() {
104122create_dir () {
105123 local dir_name=$1
106124
107- if [ ! -d ${dir_name} ] ; then
108- mkdir ${dir_name} || exit_on_error " Couldn't create directory '${dir_name} '"
125+ if [ ! -d " ${dir_name} " ] ; then
126+ mkdir -p " ${dir_name} " || exit_on_error " Couldn't create directory '${dir_name} '"
109127 echo " Created directory '${dir_name} '"
110128 fi
111129}
@@ -137,7 +155,11 @@ solr_run() {
137155 echo " Running with version ${SOLR_VERSION} in standalone mode"
138156 echo " Starting solr on port ${SOLR_PORT} ..."
139157
140- ./${SOLR_INSTALL_DIR} /bin/solr -p ${SOLR_PORT} -s ${SOLR_HOME} -Dsolr.disable.shardsWhitelist=true || exit_on_error " Can't start Solr"
158+ if [[ " ${SOLR_VERSION} " =~ ^9\. ]]; then
159+ ./${SOLR_INSTALL_DIR} /bin/solr start -p ${SOLR_PORT} -s ${SOLR_HOME} || exit_on_error " Can't start Solr"
160+ else
161+ ./${SOLR_INSTALL_DIR} /bin/solr -p ${SOLR_PORT} -s ${SOLR_HOME} -Dsolr.disable.shardsWhitelist=true || exit_on_error " Can't start Solr"
162+ fi
141163
142164 echo " Started"
143165
@@ -162,7 +184,11 @@ solr_create_core() {
162184 core_name=$1
163185 config_dir=$2
164186
165- ./${SOLR_INSTALL_DIR} /bin/solr create_core -p ${SOLR_PORT} -c ${core_name} -d ${config_dir} || exit_on_error " Can't create core"
187+ solr_port_flag=" -p ${SOLR_PORT} "
188+
189+ abs_conf_dir=" $( pwd) /${config_dir} "
190+
191+ ./${SOLR_INSTALL_DIR} /bin/solr create_core ${solr_port_flag} -c ${core_name} -d " ${abs_conf_dir} " || exit_on_error " Can't create core"
166192}
167193
168194solr_cloud_configure_nodes () {
@@ -284,10 +310,31 @@ solr_cloud_create_collection() {
284310download
285311
286312if [ " $SOLR_CLOUD " = " no" ]; then
313+
314+ if [[ " ${SOLR_VERSION} " =~ ^9\. ]]; then
315+ TEMPLATE_CONF=" template/conf"
316+ else
317+ TEMPLATE_CONF=" template"
318+ fi
319+
320+ echo " Generating Solr configuration in ${SOLR_INSTALL_DIR} /server/${SOLR_HOME} /${TEMPLATE_CONF} "
321+
322+ if [[ " ${CORES_SETUP:- } " == " dedicated" || " ${SOLR_CLOUD:- } " == " no" ]]; then
323+ # dedicated mode: point at the local core path
324+ ALLOW_URLS=" localhost:${SOLR_PORT} /solr"
325+ elif [[ " ${SOLR_CLOUD:- } " == " yes" && ${# default_nodes[@]} -gt 0 ]]; then
326+ # SolrCloud mode: join all nodes host:port
327+ ALLOW_URLS=$( IFS=,; echo " ${default_nodes[*]} " )
328+ else
329+ # fallback: single node without core-path
330+ ALLOW_URLS=" localhost:${SOLR_PORT} "
331+ fi
332+ export ALLOW_URLS
333+
287334 $SCRIPT_DIR /../bin/generate-solr-config.sh \
288335 --solr-install-dir=" ${SOLR_INSTALL_DIR} " \
289336 --solr-version=" ${SOLR_VERSION} " \
290- --destination-dir=" ${SOLR_INSTALL_DIR} /server/${SOLR_HOME} /template "
337+ --destination-dir=" ${SOLR_INSTALL_DIR} /server/${SOLR_HOME} /${TEMPLATE_CONF} "
291338 solr_run
292339else
293340 solr_cloud_configure_nodes
0 commit comments