diff --git a/scripts/solr/restore_solr.sh b/scripts/solr/restore_solr.sh index 4b8d3fdce5..df279c0b7e 100755 --- a/scripts/solr/restore_solr.sh +++ b/scripts/solr/restore_solr.sh @@ -5,6 +5,7 @@ # and UAT environments. For local development better use the runner command: # $ ./vendor/bin/run toolkit:install-dump +CURRENT_DIR=$(pwd) SOLR_SERVER_URL="http://localhost:8983/solr" TIMEOUT=300 TIMEOUT_PATTERN='^[0-9]+$' @@ -56,13 +57,30 @@ if ! [[ $TIMEOUT =~ ${TIMEOUT_PATTERN} ]] ; then error "Timeout needs to be numeric!"; fi -if [ "${CORE}" == '' ] || [ "${SNAPSHOT_DIR}" == '' ] || [ "${SNAPSHOT_NAME}" == '' ]; then +if [ "${CORE}" == '' ] || [ "${SNAPSHOT_NAME}" == '' ]; then show_help; exit 1; fi -CORE_EXISTS=`curl -sS "${SOLR_SERVER_URL}/admin/cores?action=STATUS&core=${CORE}&wt=xml" |grep -o ''` +# Assume the current dir if no snapshot dir has been passed. +if [ "${SNAPSHOT_DIR}" == '' ]; then + SNAPSHOT_DIR=${CURRENT_DIR} +fi + +if [ ! -d "${SNAPSHOT_DIR}" ]; then + error "The '${SNAPSHOT_DIR}' directory doesn't exist!"; +fi +# Normalize the snapshot dir to an absolute path. +cd ${SNAPSHOT_DIR} +SNAPSHOT_DIR=$(pwd) +cd ${CURRENT_DIR} + +if [ ! -d "${SNAPSHOT_DIR}/snapshot.${SNAPSHOT_NAME}" ]; then + error "The '${SNAPSHOT_DIR}' directory doesn't contain a '${SNAPSHOT_NAME}' snapshot!"; +fi + +CORE_EXISTS=`curl -sS "${SOLR_SERVER_URL}/admin/cores?action=STATUS&core=${CORE}&wt=xml" |grep -o ''` if [ "${CORE_EXISTS}" == '' ]; then error "Solr '${CORE}' core does not exists on this server!"; fi