Skip to content

Instantly share code, notes, and snippets.

@markrmiller
Created February 29, 2024 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markrmiller/ddef1f257cdd7cb0078baf49a4e08f0b to your computer and use it in GitHub Desktop.
Save markrmiller/ddef1f257cdd7cb0078baf49a4e08f0b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define Solr version
SOLR_VERSION="9.5.0"
SOLR_COLLECTION="testCreateWithDefaultConfigSet"
SOLR_ZK="localhost:14332/solr"
SOLR_DIR="solr-$SOLR_VERSION"
# Step 1: Check if Solr has already been downloaded and extracted
if [ -d "$SOLR_DIR" ]; then
echo "Apache Solr $SOLR_VERSION is already downloaded and extracted."
else
# Download Apache Solr 9.5.0
echo "Downloading Apache Solr $SOLR_VERSION..."
wget https://downloads.apache.org/solr/solr/$SOLR_VERSION/solr-$SOLR_VERSION.tgz -O solr-$SOLR_VERSION.tgz
# Extract Solr
echo "Extracting Solr..."
mkdir $SOLR_DIR
tar -xzf solr-$SOLR_VERSION.tgz -C $SOLR_DIR --strip-components=1
fi
# Step 3: Compile SolrCoreReloader.java using globbing for classpath
echo "Compiling SolrCoreReloader.java..."
javac -cp "./solr-$SOLR_VERSION/server/solr-webapp/webapp/WEB-INF/lib/*:./solr-$SOLR_VERSION/server/lib/ext/*" SolrCoreReloader.java
# Step 4: Run SolrCoreReloader
# Ensure to replace 'your_zookeeper_connection_string' with your actual ZooKeeper connection string
# Replace 'your_collection_name' with the name of the Solr collection you want to reload
echo "Running SolrCoreReloader..."
java -cp ".:./solr-$SOLR_VERSION/server/solr-webapp/webapp/WEB-INF/lib/*:./solr-$SOLR_VERSION/server/lib/ext/*" SolrCoreReloader $SOLR_ZK $SOLR_COLLECTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment