From 3933a06fb240ba573ffc8818e0fd9615ee80548c Mon Sep 17 00:00:00 2001 From: Mario Trojan Date: Wed, 24 Oct 2018 17:00:11 +0200 Subject: [PATCH] temporary fix for import-marc-auth.sh until it is taken over by vufind-org, see vufind-org/vufind pull request #1239 --- import-marc-auth.sh | 49 +++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/import-marc-auth.sh b/import-marc-auth.sh index 9ca73e68dd9..d543d17c621 100755 --- a/import-marc-auth.sh +++ b/import-marc-auth.sh @@ -12,21 +12,17 @@ then exit $E_BADARGS fi -# Always use the standard authority mappings; if the user specified an override -# file, add that to the setting. -if [ -f "$VUFIND_LOCAL_DIR/import/marc_auth.properties" ] +################################################## +# Set VUFIND_HOME +################################################## +if [ -z "$VUFIND_HOME" ] then - MAPPINGS_FILE="$VUFIND_LOCAL_DIR/import/marc_auth.properties" -else - MAPPINGS_FILE="$VUFIND_HOME/import/marc_auth.properties" -fi -if [ $# -gt 1 ] -then - if [ -f "$VUFIND_LOCAL_DIR/import/$2" ] + # set VUFIND_HOME to the absolute path of the directory containing this script + # https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself + export VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)" + if [ -z "$VUFIND_HOME" ] then - MAPPINGS_FILE="$MAPPINGS_FILE,$VUFIND_LOCAL_DIR/import/$2" - else - MAPPINGS_FILE="$MAPPINGS_FILE,$VUFIND_HOME/import/$2" + exit 1 fi fi @@ -37,8 +33,31 @@ then else export PROPERTIES_FILE="$VUFIND_HOME/import/import_auth.properties" fi + +# Always use the authority mappings from PROPERTIES_FILE +# if the user specified an override file, add that to the setting. +MAPPINGS_FILENAMES=($(sed --quiet --expression='s/^\(solr.indexer.properties\s*=\s*\)\(.*\)/\2/p' $PROPERTIES_FILE | tr "," " ")) +if [ $# -gt 1 ] +then + MAPPINGS_FILENAMES+=($2) +fi + +MAPPINGS_FILES="" +for MAPPINGS_FILENAME in ${MAPPINGS_FILENAMES[@]}; do + if [ -n "$MAPPINGS_FILES" ]; then + MAPPINGS_FILES+="," + fi + + if [ -f "$VUFIND_LOCAL_DIR/import/$MAPPINGS_FILENAME" ] + then + MAPPINGS_FILES+="$VUFIND_LOCAL_DIR/import/$MAPPINGS_FILENAME" + else + MAPPINGS_FILES+="$VUFIND_HOME/import/$MAPPINGS_FILENAME" + fi +done + export SOLRCORE="authority" -export EXTRA_SOLRMARC_SETTINGS="-Dsolr.indexer.properties=$MAPPINGS_FILE" +export EXTRA_SOLRMARC_SETTINGS="-Dsolr.indexer.properties=$MAPPINGS_FILES" # Call the standard script: -$VUFIND_HOME/import-marc.sh $1 \ No newline at end of file +$VUFIND_HOME/import-marc.sh $1