-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure-solr-sample.sh
executable file
·35 lines (28 loc) · 1.37 KB
/
configure-solr-sample.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
#!/bin/bash
# This script configures the default Apache Solr search core to use one of the
# Drupal Solr module's configurations. This shell script presumes you have
# `solr` in the `installed_extras`, and is currently set up for the D8 versions
# of Apache Solr Search or Search API Solr.
SOLR_CORE_NAME="solr_custome_core"
SOLR_SETUP_COMPLETE_FILE="/etc/drupal_vm_solr_config_complete_$SOLR_CORE_NAME"
# Search API Solr module.
SOLR_DOWNLOAD="https://ftp.drupal.org/files/projects/search_api_solr-8.x-2.7.tar.gz"
SOLR_DOWNLOAD_DIR="/tmp"
SOLR_MODULE_NAME="search_api_solr"
SOLR_VERSION="7.x"
SOLR_CORE_PATH="/var/solr/data/$SOLR_CORE_NAME"
# Check to see if we've already performed this setup.
if [ ! -e "$SOLR_SETUP_COMPLETE_FILE" ]; then
# Download and expand the Solr module.
wget -qO- $SOLR_DOWNLOAD | tar xvz -C $SOLR_DOWNLOAD_DIR
# Copy new Solr collection core with the Solr configuration provided by module.
sudo su - solr -c "/opt/solr/bin/solr create -c $SOLR_CORE_NAME -d $SOLR_DOWNLOAD_DIR/$SOLR_MODULE_NAME/solr-conf/$SOLR_VERSION/"
# Adjust the autoCommit time so index changes are committed in 1s.
sudo sed -i 's/\(<maxTime>\)\([^<]*\)\(<[^>]*\)/\11000\3/g' $SOLR_CORE_PATH/conf/solrconfig.xml
# Restart Apache Solr.
sudo service solr restart
# Create a file to indicate this script has already run.
sudo touch $SOLR_SETUP_COMPLETE_FILE
else
exit 0
fi