Skip to content

Instantly share code, notes, and snippets.

@makuk66
Last active October 22, 2016 13:20
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 makuk66/e46b92111cf35cd4f49024a2215b2ed3 to your computer and use it in GitHub Desktop.
Save makuk66/e46b92111cf35cd4f49024a2215b2ed3 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# A helper script to initialise a custom SOLR_HOME.
# For example:
#
# mkdir mysolrhome
# sudo chown 8983:8983 mysolrhome
# docker run -it -v $PWD/mysolrhome:/mysolrhome -e SOLR_HOME=/mysolrhome solr
#
if [[ "$VERBOSE" = "yes" ]]; then
set -x
fi
# Normally SOLR_HOME is not set, and Solr will use /opt/solr/server/solr/
# If it's not set, then this script has no relevance.
if [[ -z $SOLR_HOME ]]; then
exit
fi
# check the directory exists.
if [ ! -d "$SOLR_HOME" ]; then
echo "SOLR_HOME $SOLR_HOME does not exist"
exit 1
fi
# don't do anything if it is non-empty
if [ $(find "$SOLR_HOME" -mindepth 1 | wc -l) != '0' ]; then
exit
fi
# populate with default solr home contents
echo "copying solr home contents to $SOLR_HOME"
cp -R /opt/solr/server/solr/* "$SOLR_HOME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment