forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 1
/
import-marc.bat
138 lines (123 loc) · 5.03 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
@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 # Print usage when called with no 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 ##################################################
if not "!%INDEX_OPTIONS%!"=="!!" goto indexoptionsfound
set INDEX_OPTIONS=-Xms512m -Xmx512m -DentityExpansionLimit=0
:indexoptionsfound
rem ##################################################
rem # Set SOLRCORE
rem ##################################################
if "!%SOLRCORE%!"=="!!" goto solrcorenotfound
set EXTRA_SOLRMARC_SETTINGS=%EXTRA_SOLRMARC_SETTINGS% -Dsolr.core.name=%SOLRCORE%
:solrcorenotfound
rem ##################################################
rem # Set VUFIND_HOME
rem ##################################################
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
rem VUFIND_HOME not set -- try to call env.bat to
rem fix the problem before we give up completely
if exist env.bat goto useenvbat
rem If env.bat doesn't exist, the user hasn't run the installer yet.
echo WARNING: env.bat does not exist -- trying default environment settings.
echo Please run "php install.php" to correct this problem.
rem Extract path from current batch file and trim trailing slash:
set VUFIND_HOME=%~dp0%
set VUFIND_HOME=%VUFIND_HOME:~0,-1%
goto vufindhomefound
:useenvbat
call env > nul
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomefound
echo You need to set the VUFIND_HOME environmental variable before running this script.
goto end
:vufindhomefound
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
if not exist %VUFIND_LOCAL_DIR%\import\import.properties goto nolocalproperties
set PROPERTIES_FILE=%VUFIND_LOCAL_DIR%\import\import.properties
goto propertiesfound
:nolocalproperties
echo WARNING: VUFIND_LOCAL_DIR environment variable is not set. Is this intentional?
set PROPERTIES_FILE=%VUFIND_HOME%\import\import.properties
:propertiesfound
rem ##################################################
rem # Set log4j config file if not already provided
rem ##################################################
if defined LOG4J_CONFIG goto log4jfound
if not exist %VUFIND_LOCAL_DIR%\import\log4j.properties goto nolocallog4j
set LOG4J_CONFIG=%VUFIND_LOCAL_DIR%\import\log4j.properties
goto log4jfound
:nolocallog4j
set LOG4J_CONFIG=%VUFIND_HOME%\import\log4j.properties
:log4jfound
rem ##################################################
rem # Set Command Options
rem ##################################################
for %%a in (%VUFIND_HOME%\import\solrmarc_core_*.jar) do set JAR_FILE=%%a
rem ##################################################
rem # Collect all filenames from command line
rem ##################################################
:collectfilenamesloop
set ALL_FILENAMES=%ALL_FILENAMES% %1
shift
if not "!%1!"=="!!" goto :collectfilenamesloop
rem #####################################################
rem # Execute Importer
rem #####################################################
set RUN_CMD=%JAVA% %INDEX_OPTIONS% -Duser.timezone=UTC -Dlog4j.configuration="file:///%LOG4J_CONFIG%" %EXTRA_SOLRMARC_SETTINGS% -jar %JAR_FILE% %PROPERTIES_FILE% -solrj %VUFIND_HOME%\solr\vendor\server\solr-webapp\webapp\WEB-INF\lib -lib_local %VUFIND_HOME%\import\lib_local;%VUFIND_HOME%\solr\vendor\modules\analysis-extras\lib%ALL_FILENAMES%
echo Now Importing%ALL_FILENAMES% ...
echo %RUN_CMD%
%RUN_CMD%
exit /b %ERRORLEVEL%
:end
rem We're all done -- close down the local environment.
endlocal