48
48
print ("Need Python 3, you are running {}" .format (MAJOR_VERSION ))
49
49
sys .exit (1 )
50
50
51
- __version__ = "0.2 "
51
+ __version__ = "0.3 "
52
52
53
53
54
54
def exec_command (doit , logger , cmd , msg ):
@@ -103,7 +103,7 @@ 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 , roconfig ):
107
107
"""
108
108
Refresh current configuration file with configuration retrieved
109
109
from webapp. If roconfig is not None, the current config is merged with
@@ -137,7 +137,8 @@ def config_refresh(doit, logger, basedir, uri, configmerge, roconfig):
137
137
logger .info ('Refreshing configuration '
138
138
'(merging with read-only config)' )
139
139
merged_config = exec_command (doit , logger ,
140
- [configmerge , roconfig , fcur .name ],
140
+ [configmerge , '-a' , jar_file ,
141
+ roconfig , fcur .name ],
141
142
"cannot merge configuration" )
142
143
with tempfile .NamedTemporaryFile () as fmerged :
143
144
logger .debug ("Temporary file for merged config: {}" .
@@ -192,8 +193,7 @@ def project_delete(doit, logger, project, uri):
192
193
193
194
194
195
if __name__ == '__main__' :
195
- parser = argparse .ArgumentParser (description = 'grok configuration '
196
- 'management.' ,
196
+ parser = argparse .ArgumentParser (description = 'project management.' ,
197
197
formatter_class = argparse .
198
198
ArgumentDefaultsHelpFormatter )
199
199
parser .add_argument ('-D' , '--debug' , action = 'store_true' ,
@@ -203,9 +203,10 @@ def project_delete(doit, logger, project, uri):
203
203
parser .add_argument ('-R' , '--roconfig' ,
204
204
help = 'OpenGrok read-only configuration file' )
205
205
parser .add_argument ('-U' , '--uri' , default = 'http://localhost:8080/source' ,
206
- help = 'uri of the webapp with context path' )
206
+ help = 'URI of the webapp with context path' )
207
207
parser .add_argument ('-c' , '--configmerge' ,
208
208
help = 'path to the ConfigMerge binary' )
209
+ parser .add_argument ('--jar' , help = 'Path to jar archive to run' )
209
210
parser .add_argument ('-u' , '--upload' , action = 'store_true' ,
210
211
help = 'Upload configuration at the end' )
211
212
parser .add_argument ('-n' , '--noop' , action = 'store_true' , default = False ,
@@ -248,23 +249,31 @@ def project_delete(doit, logger, project, uri):
248
249
.format (args .base ))
249
250
sys .exit (1 )
250
251
251
- # read-only configuration file.
252
+ # If read-only configuration file is specified, this means read-only
253
+ # configuration will need to be merged with active webapp configuration.
254
+ # This requires config merge tool to be run so couple of other things
255
+ # need to be checked.
252
256
if args .roconfig :
253
257
if path .isfile (args .roconfig ):
254
258
logger .debug ("Using {} as read-only config" .format (args .roconfig ))
255
259
else :
256
260
logger .error ("File {} does not exist" .format (args .roconfig ))
257
261
sys .exit (1 )
258
262
263
+ configmerge_file = get_command (logger , args .configmerge , "config-merge.py" )
264
+ if configmerge_file is None :
265
+ logger .error ("Use the --configmerge option to specify the path to"
266
+ "the config merge script" )
267
+ sys .exit (1 )
268
+
269
+ if args .jar is None :
270
+ logger .error ('jar file needed for config merge tool, '
271
+ 'use --jar to specify one' )
272
+ sys .exit (1 )
273
+
259
274
uri = args .uri
260
275
if not uri :
261
- logger .error ("uri of the webapp not specified" )
262
- sys .exit (1 )
263
-
264
- configmerge_file = get_command (logger , args .configmerge , "ConfigMerge" )
265
- if not configmerge_file :
266
- logger .error ("Use the --configmerge option to specify the path to"
267
- "the ConfigMerge script" )
276
+ logger .error ("URI of the webapp not specified" )
268
277
sys .exit (1 )
269
278
270
279
lock = filelock .FileLock (os .path .join (tempfile .gettempdir (),
@@ -281,6 +290,7 @@ def project_delete(doit, logger, project, uri):
281
290
basedir = args .base ,
282
291
uri = uri ,
283
292
configmerge = configmerge_file ,
293
+ jar_file = args .jar ,
284
294
roconfig = args .roconfig )
285
295
elif args .delete :
286
296
for proj in args .delete :
@@ -292,12 +302,14 @@ def project_delete(doit, logger, project, uri):
292
302
basedir = args .base ,
293
303
uri = uri ,
294
304
configmerge = configmerge_file ,
305
+ jar_file = args .jar ,
295
306
roconfig = args .roconfig )
296
307
elif args .refresh :
297
308
config_refresh (doit = doit , logger = logger ,
298
309
basedir = args .base ,
299
310
uri = uri ,
300
311
configmerge = configmerge_file ,
312
+ jar_file = args .jar ,
301
313
roconfig = args .roconfig )
302
314
else :
303
315
parser .print_help ()
0 commit comments