@@ -103,7 +103,8 @@ def install_config(doit, src, dst):
103
103
sys .exit (1 )
104
104
105
105
106
- def config_refresh (doit , logger , basedir , uri , configmerge , roconfig ):
106
+ def config_refresh (doit , logger , basedir , uri , configmerge , jar_file ,
107
+ roconfig ):
107
108
"""
108
109
Refresh current configuration file with configuration retrieved
109
110
from webapp. If roconfig is not None, the current config is merged with
@@ -137,7 +138,8 @@ def config_refresh(doit, logger, basedir, uri, configmerge, roconfig):
137
138
logger .info ('Refreshing configuration '
138
139
'(merging with read-only config)' )
139
140
merged_config = exec_command (doit , logger ,
140
- [configmerge , roconfig , fcur .name ],
141
+ [configmerge , '-a' , jar_file ,
142
+ roconfig , fcur .name ],
141
143
"cannot merge configuration" )
142
144
with tempfile .NamedTemporaryFile () as fmerged :
143
145
logger .debug ("Temporary file for merged config: {}" .
@@ -193,8 +195,7 @@ def project_delete(logger, project, uri, doit=True, deletesource=False):
193
195
194
196
195
197
if __name__ == '__main__' :
196
- parser = argparse .ArgumentParser (description = 'grok configuration '
197
- 'management.' ,
198
+ parser = argparse .ArgumentParser (description = 'project management.' ,
198
199
formatter_class = argparse .
199
200
ArgumentDefaultsHelpFormatter )
200
201
parser .add_argument ('-D' , '--debug' , action = 'store_true' ,
@@ -204,9 +205,10 @@ def project_delete(logger, project, uri, doit=True, deletesource=False):
204
205
parser .add_argument ('-R' , '--roconfig' ,
205
206
help = 'OpenGrok read-only configuration file' )
206
207
parser .add_argument ('-U' , '--uri' , default = 'http://localhost:8080/source' ,
207
- help = 'uri of the webapp with context path' )
208
+ help = 'URI of the webapp with context path' )
208
209
parser .add_argument ('-c' , '--configmerge' ,
209
210
help = 'path to the ConfigMerge binary' )
211
+ parser .add_argument ('--jar' , help = 'Path to jar archive to run' )
210
212
parser .add_argument ('-u' , '--upload' , action = 'store_true' ,
211
213
help = 'Upload configuration at the end' )
212
214
parser .add_argument ('-n' , '--noop' , action = 'store_true' , default = False ,
@@ -256,23 +258,32 @@ def project_delete(logger, project, uri, doit=True, deletesource=False):
256
258
.format (args .base ))
257
259
sys .exit (1 )
258
260
259
- # read-only configuration file.
261
+ # If read-only configuration file is specified, this means read-only
262
+ # configuration will need to be merged with active webapp configuration.
263
+ # This requires config merge tool to be run so couple of other things
264
+ # need to be checked.
260
265
if args .roconfig :
261
266
if path .isfile (args .roconfig ):
262
267
logger .debug ("Using {} as read-only config" .format (args .roconfig ))
263
268
else :
264
269
logger .error ("File {} does not exist" .format (args .roconfig ))
265
270
sys .exit (1 )
266
271
272
+ configmerge_file = get_command (logger , args .configmerge ,
273
+ "config-merge.py" )
274
+ if configmerge_file is None :
275
+ logger .error ("Use the --configmerge option to specify the path to"
276
+ "the config merge script" )
277
+ sys .exit (1 )
278
+
279
+ if args .jar is None :
280
+ logger .error ('jar file needed for config merge tool, '
281
+ 'use --jar to specify one' )
282
+ sys .exit (1 )
283
+
267
284
uri = args .uri
268
285
if not uri :
269
- logger .error ("uri of the webapp not specified" )
270
- sys .exit (1 )
271
-
272
- configmerge_file = get_command (logger , args .configmerge , "ConfigMerge" )
273
- if not configmerge_file :
274
- logger .error ("Use the --configmerge option to specify the path to"
275
- "the ConfigMerge script" )
286
+ logger .error ("URI of the webapp not specified" )
276
287
sys .exit (1 )
277
288
278
289
lock = filelock .FileLock (os .path .join (tempfile .gettempdir (),
@@ -289,6 +300,7 @@ def project_delete(logger, project, uri, doit=True, deletesource=False):
289
300
basedir = args .base ,
290
301
uri = uri ,
291
302
configmerge = configmerge_file ,
303
+ jar_file = args .jar ,
292
304
roconfig = args .roconfig )
293
305
elif args .delete :
294
306
for proj in args .delete :
@@ -301,12 +313,14 @@ def project_delete(logger, project, uri, doit=True, deletesource=False):
301
313
basedir = args .base ,
302
314
uri = uri ,
303
315
configmerge = configmerge_file ,
316
+ jar_file = args .jar ,
304
317
roconfig = args .roconfig )
305
318
elif args .refresh :
306
319
config_refresh (doit = doit , logger = logger ,
307
320
basedir = args .base ,
308
321
uri = uri ,
309
322
configmerge = configmerge_file ,
323
+ jar_file = args .jar ,
310
324
roconfig = args .roconfig )
311
325
else :
312
326
parser .print_help ()
0 commit comments