-
Notifications
You must be signed in to change notification settings - Fork 0
/
yc.bat
executable file
·464 lines (360 loc) · 14.3 KB
/
yc.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
@echo off
rem
rem YesCart development script
rem @author Denys Pavlov
set RUNDIR=%CD%
set YC_HOME=%~dp0
rem Remove last slash if there is one
if "x%YC_HOME:~-1%".=="x\". (
set YC_HOME=%YC_HOME:~0,-1%
)
set MVN=%M2_HOME%\bin\mvn.bat
rem set MVN=%M3_HOME%\bin\mvn3.bat
rem Default come back label
set comeBack=finish
if %1.==help. (
goto show_help
)
if %1.==env. (
call cd %YC_HOME%
set comeBack=env
goto show_env;
:env
call cd %RUNDIR%
goto finish
)
if %1.==i3rd. (
call cd %YC_HOME%
set comeBack=i3rd
goto add_mvn_extra_dep
:i3rd
call cd %RUNDIR%
goto finish
)
if %1.==cpres. (
call cd %YC_HOME%
set comeBack=cpres
goto cp_resources_to_webapp
:cpres
call cd %RUNDIR%
goto finish
)
if %1.==dbimysql. (
call cd %YC_HOME%
set comeBack=dbimysql
goto init_db_mysql
:dbimysql
call cd %RUNDIR%
goto finish
)
if %1.==dbiderby. (
call cd %YC_HOME%
set comeBack=dbiderby
goto init_db_derby
:dbiderby
call cd %RUNDIR%
goto finish
)
if %1.==derbygo. (
call cd %YC_HOME%
set comeBack=derbygo
goto db_derby_go
:derbygo
call cd %RUNDIR%
goto finish
)
if %1.==derbygob. (
call cd %YC_HOME%
set comeBack=derbygob
goto db_derby_gob
:derbygob
call cd %RUNDIR%
goto finish
)
if %1.==derbyend. (
call cd %YC_HOME%
set comeBack=derbyend
goto db_derby_end
:derbyend
call cd %RUNDIR%
goto finish
)
if %1.==derbycon. (
call cd %YC_HOME%
set comeBack=derbycon
goto db_derby_connect
:derbycon
call cd %RUNDIR%
goto finish
)
if %1.==clndemo. (
call cd %YC_HOME%
set comeBack=clndemo
goto prepare_demo_clean
:clndemo
call cd %RUNDIR%
goto finish
)
if %1.==pkgdemo. (
call cd %YC_HOME%
set comeBack=pkgdemo1
goto prepare_demo_clean
:pkgdemo1
set comeBack=pkgdemo2
goto prepare_demo_pkg
:pkgdemo2
call cd %RUNDIR%
goto finish
)
if %1.==luke. (
call cd %YC_HOME%
set comeBack=luke
goto start_luke
:luke
call cd %RUNDIR%
goto finish
)
echo Provide a command...
goto show_help
goto finish
rem Sub routines below this comment
:show_env
echo ================================================
echo Environment variables
echo ================================================
echo user.name : %HOME%
echo user.home : %HOME%
echo YC_HOME : %YC_HOME%
echo RUNNIG_HOME : %RUNDIR%
echo ANT_HOME : %ANT_HOME%
echo FLEX_HOME : %FLEX_HOME%
echo JAVA_HOME : %JAVA_HOME%
echo M2_HOME : %M2_HOME%
echo ================================================
goto %comeBack%
:show_help
echo ================================================
echo YesCart environment script
echo ================================================
echo commands:
echo env - show environment variables
echo.
echo i3rd - setup necessary artifacts 3rd
echo party artifacts for maven
echo.
echo cpres - copy extra resources to webapps
echo.
echo luke - start luke
echo.
echo dbimysql - initialise db for mysql
echo.
echo dbiderby - initialise db for derby
echo derbygo - start derby server
echo derbygob - start derby server (in back mode)
echo derbyend - stop derby server
echo derbycon - connect to derby with ij
echo.
echo pkgdemo - prepare demo package
echo clndemo - clean demo package
echo ================================================
goto %comeBack%
:add_mvn_extra_dep
echo ================================================
echo Setup environment
echo ================================================
echo Adding extra dependencies...
call cd %YC_HOME%\env\setup\lib3rdparty
set LIBFILE=%YC_HOME%\env\setup\lib3rdparty\authorize.net\anet-java-sdk-1.4.2.jar
call %MVN% install:install-file -DgroupId=net.authorize -DartifactId=authorize-client -Dversion=1.4.2 -Dpackaging=jar -Dfile=%LIBFILE%
set LIBFILE=%YC_HOME%\env\setup\lib3rdparty\cybersource\cybssecurity.jar
call %MVN% install:install-file -DgroupId=com.cybersource -DartifactId=cybersource-security -Dversion=1.5 -Dpackaging=jar -Dfile=%LIBFILE%
set LIBFILE=%YC_HOME%\env\setup\lib3rdparty\cybersource\cybsclients15.jar
call %MVN% install:install-file -DgroupId=com.cybersource -DartifactId=cybersource-client -Dversion=1.5 -Dpackaging=jar -Dfile=%LIBFILE%
set LIBFILE=%YC_HOME%\env\setup\lib3rdparty\payflow\payflow.jar
call %MVN% install:install-file -DgroupId=paypal.payflow -DartifactId=payflow-client -Dversion=4.31 -Dpackaging=jar -Dfile=%LIBFILE%
set LIBFILE=%YC_HOME%\env\setup\lib3rdparty\paypal\paypal_base.jar
call %MVN% install:install-file -DgroupId=com.paypal -DartifactId=paypal-client -Dversion=5.1.1 -Dpackaging=jar -Dfile=%LIBFILE%
call cd %YC_HOME%
echo ================================================
goto %comeBack%
:cp_resources_to_webapp
echo ================================================
echo Copy resources to webapps
echo ================================================
echo copying resources... manager/server
call cd %YC_HOME%\manager\server
call %MVN% validate -Ptemplates
echo copying resources... web/store
call cd %YC_HOME%\web\store
call %MVN% validate -Ptemplates
echo copying resources... web/api
call cd %YC_HOME%\web\api
call %MVN% validate -Ptemplates
goto %comeBack%
:init_db_mysql
echo ================================================
echo Initialise MySQL database
echo ================================================
set DBINITSCRIPT=%YC_HOME%\env\setup\dbi\mysql\dbinit.sql
echo Running init script as root user %DBINITSCRIPT%
call mysql -uroot -p < %DBINITSCRIPT%
echo Initialisation complete.
goto %comeBack%
:db_derby_go
echo ================================================
echo Starting Derby database
echo ================================================
echo %YC_HOME%
set DERBY_INSTALL=%YC_HOME%\env\derby
set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;%DERBY_INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\derbynet.jar;.
call cd %DERBY_INSTALL%\lib
call java -jar derbyrun.jar server start
goto %comeBack%
:db_derby_gob
echo ================================================
echo Starting Derby database (background mode)
echo ================================================
set DERBY_INSTALL=%YC_HOME%\env\derby
set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;%DERBY_INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\derbynet.jar;.
call cd %DERBY_INSTALL%\lib
start java -jar derbyrun.jar server start
echo Derby server started on port 1527...
goto %comeBack%
:db_derby_end
echo ================================================
echo Stopping Derby database
echo ================================================
set DERBY_INSTALL=%YC_HOME%\env\derby
set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;%DERBY_INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\derbynet.jar;.
call cd %DERBY_INSTALL%\lib
call java -jar derbyrun.jar server shutdown
echo Derby server stopped...
goto %comeBack%
:init_db_derby
echo ================================================
echo Initialise Derby database
echo ================================================
echo Setting Derby environment variables
set DERBY_INSTALL=%YC_HOME%\env\derby
set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;%DERBY_INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\derbynet.jar;.
call cd %DERBY_INSTALL%\lib
rem call java org.apache.derby.tools.sysinfo
set DBINITSCRIPT=%YC_HOME%\env\setup\dbi\derby\dbinit.sql
echo Running init script %DBINITSCRIPT%
call java -Dderby.system.home=%YC_HOME% -Dij.outfile=%YC_HOME%\derbyinit.log -Dderby.ui.codeset=UTF8 org.apache.derby.tools.ij %DBINITSCRIPT%
rem call java -Dderby.system.home=%YC_HOME% org.apache.derby.tools.ij %DBINITSCRIPT%
call cd %YC_HOME%;
echo Initialisation complete. See log: %YC_HOME%\derbyinit.log
goto %comeBack%
:db_derby_connect
echo ================================================
echo Starting Derby client
echo ================================================
set DERBY_INSTALL=%YC_HOME%\env\derby
set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;%DERBY_INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\derbynet.jar;.
call cd %DERBY_INSTALL%\lib
echo Working directory is
echo %CD%
echo Use:
echo connect 'jdbc:derby://localhost:1527/yes'; - to connect to main db
echo connect 'jdbc:derby://localhost:1527/yespay'; - to connect to payment gateway db
echo disconnect; - to quit
call java -Dderby.ui.codeset=UTF8 org.apache.derby.tools.ij
goto %comeBack%
:prepare_demo_clean
echo ================================================
echo Cleaning DEMO package
echo ================================================
echo.
echo Cleaning Tomcat Logs
call del /Q %YC_HOME%\demo\yes-server\logs\*.log
call del /Q %YC_HOME%\demo\yes-server\logs\catalina.out
echo done...
echo Cleaning Tomcat Temp
call del /Q %YC_HOME%\demo\yes-server\work\*
call del /Q %YC_HOME%\demo\yes-server\temp\*
echo done...
echo Cleaning Derby bundle %YC_HOME%\demo\yes-db\*
call rmdir /S /Q %YC_HOME%\demo\yes-db\yes
call rmdir /S /Q %YC_HOME%\demo\yes-db\yespay
call del /Q %YC_HOME%\demo\yes-db\*
echo done...
echo Cleaning demo import data %YC_HOME%\demo\import-data\*
call del /Q %YC_HOME%\demo\import-data\*
echo done...
set YESCONF=%YC_HOME%\demo\yes-server\conf\Catalina\localhost
set YESCONFSHOP=%YESCONF%\yes-shop.xml
set YESCONFMANAGER=%YESCONF%\yes-manager.xml
echo Removing old context.xml:
echo %YESCONFSHOP%
call del /Q %YESCONFSHOP%
echo %YESCONFMANAGER%
call del /Q %YESCONFMANAGER%
set YESWEBAPPS=%YC_HOME%\demo\yes-server\webapps
set YESSHOP_OLD=%YESWEBAPPS%\yes-shop
set YESSHOPWAR_OLD=%YESWEBAPPS%\yes-shop.war
set YESMANAGER_OLD=%YESWEBAPPS%\yes-manager
set YESMANAGERWAR_OLD=%YESWEBAPPS%\yes-manager.war
echo Removing old wars:
echo %YESSHOP_OLD%
call rmdir /S /Q %YESSHOP_OLD%
echo %YESSHOPWAR_OLD%
call del /Q %YESSHOPWAR_OLD%
echo %YESMANAGER_OLD%
call rmdir /S /Q %YESMANAGER_OLD%
echo %YESMANAGERWAR_OLD%
call del /Q %YESMANAGERWAR_OLD%
echo done...
goto %comeBack%
:prepare_demo_pkg
echo ================================================
echo Preparing DEMO package
echo ================================================
echo.
echo Make sure that you have prepared derby dbs and
echo created a full maven build with derby profile.
echo.
echo Copying Derby package
call xcopy %YC_HOME%\env\derby\lib\*.jar %YC_HOME%\demo\yes-db
echo done...
set YESDB_OLD=%YC_HOME%\demo\yes-db\yes
set YESDB_NEW=%YC_HOME%\env\derby\lib\yes
echo Copying new db: %YESDB_NEW%
call xcopy /E %YESDB_NEW% %YESDB_OLD%
echo done...
set YESPAYDB_OLD=%YC_HOME%\demo\yes-db\yespay
set YESPAYDB_NEW=%YC_HOME%\env\derby\lib\yespay
echo Copying new db: %YESPAYDB_NEW%
call xcopy /E %YESPAYDB_NEW% %YESPAYDB_OLD%
echo done...
set YESWEBAPPS=%YC_HOME%\demo\yes-server\webapps
set YESSHOPWAR_NEW=%YC_HOME%\web\store\target\yes-shop.war
set YESMANAGERWAR_NEW=%YC_HOME%\manager\server\target\yes-manager.war
echo Copying new wars:
echo %YESSHOPWAR_NEW%
echo %YESMANAGERWAR_NEW%
call copy %YESSHOPWAR_NEW% %YESWEBAPPS%
call copy %YESMANAGERWAR_NEW% %YESWEBAPPS%
echo done...
echo Copy demo import data...
call copy "%YC_HOME%\env\sampledata\demo-data\yc\import\import.zip" "%YC_HOME%\demo\import-data\"
call copy "%YC_HOME%\env\sampledata\demo-data\icecat\import\import-EN,UK,RU.zip" "%YC_HOME%\demo\import-data\"
call copy "%YC_HOME%\env\sampledata\demo-data\icecat\import\import-EN,UK,RU-img.zip" "%YC_HOME%\demo\import-data\"
echo done...
echo Creating zip package...
call cd %YC_HOME%
call del /Q yescart.zip
call zip -r yescart.zip .\demo -x *.svn*
echo done...
echo.
echo ================================================
echo Demo package created
echo ================================================
goto %comeBack%
:start_luke
echo ================================================
echo Starting Luke (lucene index browser)
echo ================================================
call java -jar "%YC_HOME%\env\luke\lukeall-3.5.0.jar"
goto %comeBack%
:finish