This repository has been archived by the owner on Nov 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimport-marc.sh
137 lines (119 loc) · 3.81 KB
/
import-marc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# $Id: index_file.sh 17 2008-06-20 14:40:13Z wayne.graham $
#
# Bash script to start the import of a binary marc file for Solr indexing.
#
# VUFIND_HOME
# Path to the vufind installation
# SOLRMARC_HOME
# Path to the solrmarc installation
# JAVA_HOME
# Path to the java
# INDEX_OPTIONS
# Options to pass to the JVM
#
#####################################################
# handle the -p option to override properties file
#####################################################
if [ -z "$PROPERTIES_FILE" ]
then
PROPERTIES_FILE="import.properties"
fi
while getopts ":p:" Option
do
case $Option in
p) PROPERTIES_FILE=$OPTARG;;
:)
echo "argument to '-$OPTARG' is missing" >&2
exit -1;;
\?) echo "Unrecognized option '-$OPTARG'" >&2;;
esac
done
#Decrement the argument pointer so it points to next argument
shift $(($OPTIND - 1))
#####################################################
# Make sure we have the expected number of arguments
#####################################################
E_BADARGS=65
EXPECTED_ARGS=1
if [ $# -ne $EXPECTED_ARGS ]
then
echo " Usage: `basename $0` [-p ./path/to/import.properties] ./path/to/marc.mrc"
exit $E_BADARGS
fi
##################################################
# Set INDEX_OPTIONS
# Tweak these in accordance to your needs
# Xmx and Xms set the heap size for the Java Virtual Machine
# You may also want to add the following:
# -XX:+UseParallelGC
# -XX:+AggressiveOpts
##################################################
INDEX_OPTIONS='-Xms512m -Xmx512m'
##################################################
# Set SOLRCORE
##################################################
if [ -z "$SOLRCORE" ]
then
SOLRCORE="biblio"
fi
##################################################
# Set SOLR_HOME
##################################################
if [ -z "$SOLR_HOME" ]
then
if [ -z "$VUFIND_HOME" ]
then
echo "You need to set the VUFIND_HOME environmental variable before running this script."
exit 1
else
SOLR_HOME="$VUFIND_HOME/solr"
fi
fi
##################################################
# Set SOLRMARC_HOME
##################################################
if [ -z "$SOLRMARC_HOME" ]
then
SOLRMARC_HOME="$VUFIND_HOME/import"
fi
#####################################################
# Build java command
#####################################################
if [ "$JAVA_HOME" ]
then
JAVA="$JAVA_HOME/bin/java"
else
JAVA="java"
fi
##################################################
# Set properties file if not already provided
##################################################
if [ -z "$PROPERTIES_FILE" ]
then
PROPERTIES_FILE="$VUFIND_HOME/import/import.properties"
fi
##################################################
# Set Command Options
##################################################
JAR_FILE="$VUFIND_HOME/import/SolrMarc.jar"
#SOLRWARLOCATIONORJARDIR="$VUFIND_HOME/solr/jetty/webapps/solr.war"
#TEST_SOLR_JAR_DEF=-Done-jar.class.path=$SOLRWARLOCATIONORJARDIR
#SOLR_JAR_DEF=`echo $TEST_SOLR_JAR_DEF | sed -e"s|-Done-jar.class.path=.*|-Done-jar.class.path=$SOLRWARLOCATIONORJARDIR|"`
SOLR_JAR_DEF="-Dsolrmarc.solr.war.path=$VUFIND_HOME/solr/jetty/webapps/solr.war"
#####################################################
# Normalize target file path to absolute path
#####################################################
MARC_PATH=`dirname $1`
MARC_PATH=`cd $MARC_PATH && pwd`
MARC_FILE=`basename $1`
#####################################################
# Execute Importer
#####################################################
pushd $SOLR_HOME
RUN_CMD="$JAVA $INDEX_OPTIONS $SOLR_JAR_DEF -Dsolr.core.name=$SOLRCORE -Dsolrmarc.path=$SOLRMARC_HOME -Dsolr.path=$SOLR_HOME -Dsolr.solr.home=$SOLR_HOME $EXTRA_SOLRMARC_SETTINGS -jar $JAR_FILE $PROPERTIES_FILE $MARC_PATH/$MARC_FILE"
echo "Now Importing $1 ..."
echo $RUN_CMD
exec $RUN_CMD
popd
exit 0