-
Notifications
You must be signed in to change notification settings - Fork 35
/
InstallSigma.bat
executable file
·225 lines (198 loc) · 6.29 KB
/
InstallSigma.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
@echo off
echo.
echo Installing Sigma files ...
echo.
set EXPECTED_TOMCAT_ROOT=C:\Program Files\Apache Software Foundation\
set TOMCAT_ROOT=
set TOMCAT_WEBAPPs_DIR=
set SIGMA_ROOT=
set SIGMA_KBS_DIR=
echo SIGMA_HOME=%SIGMA_HOME%
echo.
echo CATALINA_HOME=%CATALINA_HOME%
echo.
if exist "%CATALINA_HOME%" (
set TOMCAT_ROOT=%CATALINA_HOME%
) else (
for /D %%R in ( "%EXPECTED_TOMCAT_ROOT%Tomcat*" ) do (
set TOMCAT_ROOT=%%R
)
)
if not exist "%TOMCAT_ROOT%" (
echo.
echo Tomcat is not in %TOMCAT_ROOT%.
echo.
echo Please install Tomcat or edit %0, and then try again.
pause
goto quit
)
set TOMCAT_WEBAPPs_DIR=%TOMCAT_ROOT%\webapps
if not exist "%TOMCAT_WEBAPPs_DIR%" (
echo.
echo The directory %TOMCAT_WEBAPPs_DIR% could not be found.
pause
goto quit
)
if not "%SIGMA_HOME%"=="" (
if not exist "%SIGMA_HOME%" (
mkdir "%SIGMA_HOME%"
)
set SIGMA_ROOT=%SIGMA_HOME%
) else (
set SIGMA_ROOT=%TOMCAT_ROOT%
)
if not exist "%SIGMA_ROOT%" (
mkdir "%SIGMA_ROOT%"
if not exist "%SIGMA_ROOT%" (
echo.
echo The directory %SIGMA_ROOT% could not be created.
echo.
echo Perhaps you do not have permission to create it.
pause
goto quit
)
)
set SIGMA_KBS_DIR=%SIGMA_ROOT%\KBs
if not exist "%SIGMA_KBS_DIR%" (
mkdir "%SIGMA_KBS_DIR%"
if not exist "%SIGMA_KBS_DIR%" (
echo.
echo The directory %SIGMA_KBS_DIR% could not be created.
echo.
echo Perhaps you do not have permission to create it.
pause
goto quit
)
)
if exist "%TOMCAT_ROOT%\work\Catalina\localhost\sigma" (
rmdir /S /Q "%TOMCAT_ROOT%\work\Catalina\localhost\sigma"
if exist "%TOMCAT_ROOT%\work\Catalina\localhost\sigma" (
echo.
echo Could not remove %TOMCAT_ROOT%\work\Catalina\localhost\sigma.
echo.
echo Please remove it before starting Tomcat.
) else (
echo.
echo Removed %TOMCAT_ROOT%\work\Catalina\localhost\sigma.
)
)
if exist "%TOMCAT_WEBAPPs_DIR%\sigma" (
rmdir /S /Q "%TOMCAT_WEBAPPs_DIR%\sigma"
if exist "%TOMCAT_WEBAPPs_DIR%\sigma" (
echo.
echo Could not remove %TOMCAT_WEBAPPs_DIR%\sigma.
echo.
echo Please remove it before starting Tomcat.
) else (
echo.
echo Removed %TOMCAT_WEBAPPs_DIR%\sigma.
)
)
if exist "%TOMCAT_WEBAPPs_DIR%\sigma.war" (
copy /B "%TOMCAT_WEBAPPs_DIR%\sigma.war" "%TOMCAT_WEBAPPs_DIR%\sigma.war.old"
if exist "%TOMCAT_WEBAPPs_DIR%\sigma.war.old" (
echo Wrote sigma.war.old.
del "%TOMCAT_WEBAPPs_DIR%\sigma.war"
)
)
for %%X in ( "sigma*.war" ) do (
copy /B "%%X" "%TOMCAT_WEBAPPs_DIR%\sigma.war"
if not exist "%TOMCAT_WEBAPPs_DIR%\sigma.war" (
echo.
echo Could not copy %%X.
pause
goto quit
)
echo Wrote %%~nxX.
)
for %%I in ( "KBs\*.kif" "KBs\*.txt" "KBs\*.exc" "KBs\index.*" ) do (
if %CD%\%%I NEQ %SIGMA_KBS_DIR%\%%~nxI (
if exist "%SIGMA_KBS_DIR%\%%~nxI" (
copy /B "%SIGMA_KBS_DIR%\%%~nxI" "%SIGMA_KBS_DIR%\%%~nxI.old"
echo Wrote %%~nxI.old
del "%SIGMA_KBS_DIR%\%%~nxI"
)
copy /B "%%I" "%SIGMA_KBS_DIR%\%%~nxI"
if not exist "%SIGMA_KBS_DIR%\%%~nxI" (
echo.
echo %%~nxI could not be copied.
pause
goto quit
)
echo Wrote %%~nxI.
)
)
if not exist "%SIGMA_KBS_DIR%\tests" (
mkdir "%SIGMA_KBS_DIR%\tests"
)
if not exist "%SIGMA_KBS_DIR%\tests" (
echo.
echo The directory %SIGMA_KBS_DIR%\tests could not be created.
echo.
echo The inference test files will not be copied.
) else (
for %%I in ( "KBs\tests\*" ) do (
if %CD%\%%I NEQ %SIGMA_KBS_DIR%\tests\%%~nxI (
if exist "%SIGMA_KBS_DIR%\tests\%%~nxI" (
copy /B "%SIGMA_KBS_DIR%\tests\%%~nxI" "%SIGMA_KBS_DIR%\tests\%%~nxI.old"
echo Wrote %%~nxI.old
del "%SIGMA_KBS_DIR%\tests\%%~nxI"
)
copy /B "%%I" "%SIGMA_KBS_DIR%\tests\%%~nxI"
if not exist "%SIGMA_KBS_DIR%\tests\%%~nxI" (
echo.
echo %%~nxI could not be copied.
pause
goto quit
)
echo Wrote %%~nxI.
)
)
)
set CFGFILE=%SIGMA_KBS_DIR%\config.xml
if exist "%CFGFILE%" (
copy /B "%CFGFILE%" "%CFGFILE%.old"
echo Wrote config.xml.old
)
for %%X in ( "inference\*.exe" ) do (
if exist "%%~fX" (
echo ^<configuration^> > "%CFGFILE%"
echo ^<preference value^="%SIGMA_ROOT%" name^="baseDir" ^/^> >> "%CFGFILE%"
echo ^<preference value^="%SIGMA_KBS_DIR%" name^="kbDir" ^/^> >> "%CFGFILE%"
echo ^<preference value^="%%~fX" name="inferenceEngine" ^/^> >> "%CFGFILE%"
echo ^<preference value^="%SIGMA_KBS_DIR%\tests" name^="inferenceTestDir" ^/^> >> "%CFGFILE%"
echo ^<preference value^="%TOMCAT_WEBAPPS_DIR%\sigma\tests" name^="testOutputDir" ^/^> >> "%CFGFILE%"
echo ^<preference value^="yes" name^="typePrefix" ^/^> >> "%CFGFILE%"
echo ^<preference value^="no" name^="holdsPrefix" ^/^> >> "%CFGFILE%"
echo ^<preference value^="yes" name^="cache" ^/^> >> "%CFGFILE%"
echo ^<preference value^="yes" name^="TPTP" ^/^> >> "%CFGFILE%"
echo ^<preference value^="" name^="celtdir" ^/^> >> "%CFGFILE%"
echo ^<preference value^="no" name^="loadCELT" ^/^> >> "%CFGFILE%"
echo ^<preference value^="yes" name="showcached" ^/^> >> "%CFGFILE%"
echo ^<preference value^="" name^="lineNumberCommand" ^/^> >> "%CFGFILE%"
echo ^<preference value^="" name^="editorCommand" ^/^> >> "%CFGFILE%"
echo ^<preference value^="localhost" name^="hostname" ^/^> >> "%CFGFILE%"
echo ^<preference value^="8080" name^="port" ^/^> >> "%CFGFILE%"
echo ^<preference value^="SUMO" name^="sumokbname" ^/^> >> "%CFGFILE%"
echo ^<preference value^="" name^="prolog" ^/^> >> "%CFGFILE%"
echo ^<kb name^="SUMO"^> >> "%CFGFILE%"
echo ^<constituent filename^="%SIGMA_KBS_DIR%\Merge.kif" ^/^> >> "%CFGFILE%"
echo ^<constituent filename^="%SIGMA_KBS_DIR%\english_format.kif" ^/^> >> "%CFGFILE%"
echo ^<^/kb^> >> "%CFGFILE%"
echo ^<^/configuration^> >> "%CFGFILE%"
) else (
copy /B "KBs\config.xml" "%SIGMA_KBS_DIR%\config.xml"
)
)
if not exist "%CFGFILE%" (
echo.
echo config.xml could not be copied.
pause
goto quit
)
echo Wrote config.xml.
echo.
echo Sigma files installed!
echo.
pause
:quit