-
Notifications
You must be signed in to change notification settings - Fork 1
/
import-marc.bat
120 lines (106 loc) · 4.06 KB
/
import-marc.bat
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
@echo off
rem Batch file to start the import of a binary marc file for Solr indexing.
rem
rem VUFIND_HOME
rem Path to the vufind installation
rem SOLRMARC_HOME
rem Path to the solrmarc installation
rem JAVA_HOME
rem Path to the java
rem INDEX_OPTIONS
rem Options to pass to the JVM
rem Make sure that environment edits are local and that we have access to the
rem Windows command extensions.
setlocal enableextensions
if not errorlevel 1 goto extensionsokay
echo Unable to enable Windows command extensions.
goto end
:extensionsokay
rem Save %0 for later in case the batch file's name gets shifted away
set THISFILE=%0
rem #####################################################
rem # handle the -p option to override properties file
rem #####################################################
if "%1"=="-p" (
set PROPERTIES_FILE=%2
shift
shift
)
rem #####################################################
rem # Make sure we have the expected number of arguments
rem #####################################################
if not "!%1!"=="!!" goto argfound
echo Usage: %THISFILE% [-p c:\path\to\import.properties] c:\path\to\marc.mrc
goto end
:argfound
rem ##################################################
rem # Set INDEX_OPTIONS
rem # Tweak these in accordance to your needs
rem # Xmx and Xms set the heap size for the Java Virtual Machine
rem # You may also want to add the following:
rem # -XX:+UseParallelGC
rem # -XX:+AggressiveOpts
rem ##################################################
set INDEX_OPTIONS=-Xms512m -Xmx512m
rem ##################################################
rem # Set SOLRCORE
rem ##################################################
if not "!%SOLRCORE%!"=="!!" goto solrcorefound
set SOLRCORE=biblio
:solrcorefound
rem ##################################################
rem # Set SOLR_HOME
rem ##################################################
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
rem VUFIND_HOME not set -- try to call vufind.bat to
rem fix the problem before we give up completely
if exist vufind.bat goto usevufindbat
rem If vufind.bat doesn't exist, the user hasn't run install.bat yet.
echo ERROR: vufind.bat does not exist -- could not set up environment.
echo Please run install.bat to correct this problem.
goto end
:usevufindbat
call vufind > nul
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
echo You need to set the VUFIND_HOME environmental variable before running this script.
goto end
:vufindhomefound
if not "!%SOLR_HOME%!"=="!!" goto solrhomefound
set SOLR_HOME=%VUFIND_HOME%\solr
:solrhomefound
rem ##################################################
rem # Set SOLRMARC_HOME
rem ##################################################
if not "!%SOLRMARC_HOME%!"=="!!" goto solrmarchomefound
set SOLRMARC_HOME=%VUFIND_HOME%\import
:solrmarchomefound
rem #####################################################
rem # Build java command
rem #####################################################
if not "!%JAVA_HOME%!"=="!!" goto javahomefound
set JAVA=java
goto javaset
:javahomefound
set JAVA="%JAVA_HOME%\bin\java"
:javaset
rem ##################################################
rem # Set properties file if not already provided
rem ##################################################
if not "!%PROPERTIES_FILE%!"=="!!" goto propertiesfound
set PROPERTIES_FILE=%VUFIND_HOME%\import\import.properties
:propertiesfound
rem ##################################################
rem # Set Command Options
rem ##################################################
set JAR_FILE=%VUFIND_HOME%\import\SolrMarc.jar
set SOLR_JAR_DEF=-Dsolrmarc.solr.war.path=%VUFIND_HOME%\solr\jetty\webapps\solr.war
rem #####################################################
rem # Execute Importer
rem #####################################################
set 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% %1
echo Now Importing %1 ...
echo %RUN_CMD%
%RUN_CMD%
:end
rem We're all done -- close down the local environment.
endlocal