From a1d8115db8ec52efbab3850e6c79b1db8dd29607 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Thu, 10 Jun 2021 10:09:24 +0300 Subject: [PATCH 1/2] ISAICP-6544: Fix the restore_solr.sh script. --- scripts/solr/restore_solr.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/solr/restore_solr.sh b/scripts/solr/restore_solr.sh index 4b8d3fdce5..200c296647 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,31 @@ 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} + +echo "${SNAPSHOT_DIR}/snapshot.${SNAPSHOT_NAME}" +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 From b05c8540bcfde95e6f43ef95b157208e5bf4d700 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Thu, 10 Jun 2021 12:57:38 +0300 Subject: [PATCH 2/2] ISAICP-6544: Remove debug leftover. --- scripts/solr/restore_solr.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/solr/restore_solr.sh b/scripts/solr/restore_solr.sh index 200c296647..df279c0b7e 100755 --- a/scripts/solr/restore_solr.sh +++ b/scripts/solr/restore_solr.sh @@ -76,7 +76,6 @@ cd ${SNAPSHOT_DIR} SNAPSHOT_DIR=$(pwd) cd ${CURRENT_DIR} -echo "${SNAPSHOT_DIR}/snapshot.${SNAPSHOT_NAME}" if [ ! -d "${SNAPSHOT_DIR}/snapshot.${SNAPSHOT_NAME}" ]; then error "The '${SNAPSHOT_DIR}' directory doesn't contain a '${SNAPSHOT_NAME}' snapshot!"; fi