-
Notifications
You must be signed in to change notification settings - Fork 10
/
invenio-create-deploy-recipe
executable file
·650 lines (564 loc) · 23.5 KB
/
invenio-create-deploy-recipe
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#!/usr/bin/env python
#
# Tibor Simko <[email protected]>
#
# Copyright (C) 2011, 2012 CERN.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
"""
Usage: invenio-create-deploy-recipe [options] [sha1a[..sha1b]][,sha1c[..sha1d]]
Create deploy recipe for Invenio sites out of commit ID or commit ID
range. (If not supplied, take latest commit in current branch.) If
another commit ID or commit ID range is given after a comma, then
deploy the second repository after the first.
General options:
-h, --help Print this help.
-v, --verbose=LEVEL Verbose level (0=min, 1=default, 9=max).
Target options:
--cds Generate recipe for CDS.
--inspire Generate recipe for INSPIRE.
Deployment options:
--via-install Generate recipe with install instructions. [default]
--via-filecopy Generate recipe with file copy, not `make install'.
Optional environment variables:
CFG_INVENIO_SRCDIR Path to local Invenio sources. [~/private/src/invenio]
CFG_INVENIO_USER User name of the target Apache process. [apache]
Examples:
$ invenio-create-deploy-recipe --inspire --via-filecopy
$ invenio-create-deploy-recipe --cds HEAD~10..
$ invenio-create-deploy-recipe --inspire HEAD,HEAD
"""
import os
import sys
import subprocess
if os.environ.get('CFG_INVENIO_SRCDIR'):
CFG_INVENIO_SRCDIR = os.environ.get('CFG_INVENIO_SRCDIR')
else:
CFG_INVENIO_SRCDIR = os.path.join(os.environ.get('HOME'),
'private/src/invenio')
if os.environ.get('CFG_INVENIO_USER'):
CFG_INVENIO_USER = os.environ.get('CFG_INVENIO_USER')
else:
CFG_INVENIO_USER = 'apache'
if '--cds' in sys.argv:
CFG_PREFIX = '/opt/cdsweb'
CFG_MSG_HEADING = 'CDS logbook: PCUDSSX150[2-3,5,7],PCCIS9[7,9]:'
CFG_MSG_MACHINE = 'on PROD (PCUDSSX150[2-3,5,7],PCCIS9[7,9])'
elif '--inspire' in sys.argv:
CFG_PREFIX = '/opt/cds-invenio'
CFG_MSG_HEADING = 'INSPIRE logbook:'
CFG_MSG_MACHINE = 'on DEV (PCUDSSW1508), TEST (PCUDSSW1505)' + \
' and PROD (PCUDSSW150[4,6-7],PCUDSSX1506)'
else:
CFG_PREFIX = '/opt/invenio'
CFG_MSG_HEADING = 'logbook:'
CFG_MSG_MACHINE = 'on the server'
def get_target_source_pathname(local_source_pathname):
"""
Helper function that returns source pathname on target system from
the pathname on the local system.
"""
out = local_source_pathname
out = out.replace('/home/simko/private','/opt/simko')
out = out.replace('/afs/cern.ch/user/s/simko/private', '/opt/simko')
out = out.replace('/opt/simko/afs-only/src', '$HOME/private/afs-only/src')
return out
def get_toplevel_dir(dirname):
"""
Return git repository's toplevel directory given that DIRNAME is
part of that repository somewhere down the line.
"""
toplevel_dirname=''
os.chdir(dirname)
process = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate()
if err:
print "[ERROR]", err
if out:
toplevel_dirname = out.strip() # pylint: disable=E1103
if not os.path.exists(toplevel_dirname):
# maybe dirname is not under git control, or maybe we have
# older git version that does not support show-toplevel CLI
# option to rev-parse; so find it by iterating:
foundp = False
possible_toplevel_dirname = dirname
while not (foundp or possible_toplevel_dirname == '/'):
if os.path.exists(os.path.join(possible_toplevel_dirname, '.git')):
foundp = True
else:
possible_toplevel_dirname = os.path.dirname(possible_toplevel_dirname)
if foundp:
toplevel_dirname = possible_toplevel_dirname
else:
print "[ERROR] Cannot find git toplevel directory for %s." % gitname
return toplevel_dirname
def get_reponame_from_repodir(repodir):
"""
Return repository name for given repository directory.
"""
return os.path.basename(get_toplevel_dir(repodir))
def get_commit_msg(commitid, repodir):
"""
Return commit message corresponding to COMMITID which can be
either a SHA1 or range SHA1a..SHA1b.
"""
msg_commit = ''
os.chdir(repodir)
if '..' in commitid:
process = subprocess.Popen(['git', 'log', commitid, '--format=oneline'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
else:
process = subprocess.Popen(['git', 'log', '-n1', commitid, '--stat'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate()
if err:
print "[ERROR]", err
if out:
msg_commit = out.strip() # pylint: disable=E1103
return msg_commit
def get_commit_headline(commitid, repodir):
"""
Return commit message headline corresponding to COMMITID which can be
either a SHA1 or range SHA1a..SHA1b.
"""
msg_headline = ''
os.chdir(repodir)
if '..' in commitid:
sha1a, sha1b = commitid.split('..')
return get_commit_headline(sha1b, repodir)
else:
process = subprocess.Popen(['git', 'log', '-n1',
'--format=oneline', commitid],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate()
if err:
print "[ERROR]", err
if out:
msg_headline = out[40:]
return msg_headline.strip()
def get_commit_files(commitid, repodir):
"""
Return list of files modified in commit COMMITID which can be
either a SHA1 or range SHA1a..SHA1b.
"""
dfiles = {}
os.chdir(repodir)
process = subprocess.Popen(['git', 'show', '--pretty=format:',
'--name-only', commitid],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate()
if err:
print "[ERROR]", err
if out:
lines = out.split('\n') # pylint: disable=E1103
for line in lines:
if line:
dfiles[line] = 1
lfiles = dfiles.keys()
lfiles.sort()
if '--verbose' in sys.argv:
print lfiles
return lfiles
def detect_commitid(cliargs):
"""
Detect wanted commit ID or commit ID range we should deploy, as
was passed by the user via CLI parameters in CLIARGS.
"""
cliargs = [x for x in cliargs if not x.startswith('-')]
if len(cliargs) == 2:
commitid = cliargs[1]
else: # if nothing was asked for, take tip of the current branch
commitid = 'HEAD'
if commitid.endswith('..'):
# add branch tip explicitly, if omitted:
commitid += 'HEAD'
return commitid
def normalise_commitid(commitid, repodir):
"""
Normalise COMMITID's SHA1.
COMMITID may be either a `SHA1' or `SHA1a..SHA1b' or already, or
it may be some reference like `HEAD~20' or tag like `v1.0.0-rc0'.
These values are typically passed via command line by the user.
The final `SHA1' or `SHA1a..SHA1b' output values are then
normalised to the first 7 characters.
"""
if '..' in commitid: # we have commit range situation
commitida, commitidb = commitid.split('..', 1)
return normalise_commitid(commitida, repodir) + '..' + \
normalise_commitid(commitidb, repodir)
# we have single commit situation, so detect commitid's sha1:
os.chdir(repodir)
process = subprocess.Popen(['git', 'log', commitid, '-n1',
'--pretty=oneline', '--abbrev-commit'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate()
if err:
print "[ERROR]", err
if 'Not a git repository' in err:
print '[ERROR] Either invoke this command in an Invenio repository, ' + \
'or else supply two comma-separated commit IDs.'
print '[ERROR] See `%s --help\'.' % sys.argv[0]
sys.exit(1)
if out:
return out.split()[0].strip().split(' ', 1)[0] # pylint: disable=E1103
raise StandardError('[ERROR] Whoops, this should not have happened.')
def detect_db_changes(commitid, repodir):
"""
Detect whether there were DB schema changes in COMMITID which can
be either a SHA1 or range SHA1a..SHA1b.
"""
os.chdir(repodir)
if '..' in commitid:
process = subprocess.Popen(['git', 'diff', commitid,
'--', 'modules/miscutil/sql/tabcreate.sql'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
else:
process = subprocess.Popen(['git', 'show', commitid,
'--', 'modules/miscutil/sql/tabcreate.sql'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate()
if err:
print "[ERROR]", err
if out:
print '[ERROR] Database changes needed!'
print
print '#+BEGIN_EXAMPLE'
print out
print '#+END_EXAMPLE'
def detect_submission_change(afile):
"""
Detect whether file is a submission dump. Assume that dump files
are named *_db_dump.sql
Return (0, None, '') when the file is not a submission dump.
Return (1, None, msg) when the file is a submission dump that could not be clearly identified
Return (2, METHOD, SUBMISSION_DOCTYPE) when the file is a submission dump for SUBMISSION_DOCTYPE, dumped using --method=METHOD
"""
if afile.lower().endswith('_db_dump.sql'):
try:
fd = open(afile)
submission_doctype_line = fd.readline().rstrip()
submission_method_line = fd.readline().rstrip()
except Exception, e:
return (1, None, "Could not read submission dump parameters for %s: %s" % (afile, e))
try:
submission_doctype = submission_doctype_line.split(' ')[1]
except Exception, e:
return (1, None, "Unknown submission doctype for %s: %s" % (afile, submission_doctype_line))
if submission_method_line.startswith('-- Extra:NAMES'):
return (2, 'NAMES', submission_doctype)
elif submission_method_line.startswith('-- Extra:RELATIONS'):
return (2, 'RELATIONS', submission_doctype)
else:
return (1, None, "Unknown dump method for %s: %s" % (afile, submission_method_line))
return (0, None, '')
def detect_file_installation_place(afile):
"""
Detect where to install file AFILE depending on either file
existence in target directory tree, or via guesswork depending on
the file extension (Python files here, BTFs there, etc.)
If non-installable (e.g. Makefile), then return empty string.
If not known how to install it, then return
`/tmp/ERROR-UNKNOWN-DESTINATION-PLEASE-INSPECT-AND-ENRICH-RULES'.
"""
afile_name, afile_extension = os.path.splitext(afile)
afile_basename = os.path.basename(afile)
# 1st: try to find the file pathname:
process = subprocess.Popen(['find', CFG_PREFIX,
'(', '-path', CFG_PREFIX + '/var/cache',
'-o', '-path', CFG_PREFIX + '/var/tmp',
'-o', '-path', CFG_PREFIX + '/var/tmp-shared',
'-o', '-path', CFG_PREFIX + '/var/data',
'-o', '-path', CFG_PREFIX + '/var/log',
')', '-prune',
'-o', '-name', afile_basename, '-print'
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate()
if out:
return out.strip() # pylint: disable=E1103
# 2nd: if not found, try to guess by extension:
if not afile_extension:
return '/tmp/ERROR-UNKNOWN-DESTINATION-PLEASE-INSPECT-AND-ENRICH-RULES'
elif afile_extension in ('.py'):
if afile_name.lower().startswith('bfe_'):
return CFG_PREFIX + '/lib/python/invenio/bibformat_elements/'
elif afile_name.lower().startswith('wsm_'):
return CFG_PREFIX + '/lib/python/invenio/websubmit_file_metadata_plugins/'
elif afile_name.lower().startswith('bst_'):
return CFG_PREFIX + '/lib/python/invenio/bibsched_tasklets/'
elif afile_name.lower().startswith('bom_'):
return CFG_PREFIX + '/lib/python/invenio/bibdocfile_plugins/'
elif os.path.exists(afile):
# detect based on content
file_content = open(afile).read()
if afile_name.lower().endswith('Service') and \
"Search Service Plugin" in file_content:
return CFG_PREFIX + '/lib/python/invenio/goto_plugins/'
elif '(parameters, curdir, form, user_info=None' in file_content:
return CFG_PREFIX + '/lib/python/invenio/websubmit_functions/'
else:
return CFG_PREFIX + '/lib/python/invenio/'
elif afile_extension in ('.js'):
return CFG_PREFIX + '/var/www/js/'
elif afile_extension in ('.css', '.png', '.gif', '.jpg'):
return CFG_PREFIX + '/var/www/img/'
elif afile_extension in ('.bft'):
return CFG_PREFIX + '/etc/bibformat/format_templates/'
elif afile_extension in ('.bfo'):
return CFG_PREFIX + '/etc/bibformat/output_formats/'
elif afile_extension in ('.conf'):
return CFG_PREFIX + '/etc/'
elif afile_extension in ('.webdoc'):
return CFG_PREFIX + '/lib/webdoc/invenio/'
elif afile_extension in ('.sql'):
return CFG_PREFIX + '/lib/sql/invenio/'
elif afile_extension in ('.html'):
return CFG_PREFIX + '/lib/webtest/invenio/'
elif afile_extension in ('.wsgi'):
return CFG_PREFIX + '/var/www-wsgi/'
elif afile_extension in ('.po'):
return '' # cannot install PO files, need to create GMO ones
elif afile_extension in ('.ac', '.am', '.m4', '.in', '.rpath'):
return '' # ignore autotools files like Makefile.am and the like
else:
return '/tmp/ERROR-UNKNOWN-DESTINATION-PLEASE-INSPECT-AND-ENRICH-RULES'
def write_single_repo_deploy_recipe_header(commitid, repodir):
"""
Write recipe header for deploying COMMITID from REPODIR.
"""
print """\
%(heading)s deployed %(patch)s (%(summary)s)
""" % {'heading': CFG_MSG_HEADING, 'patch': commitid,
'summary': get_commit_headline(commitid, repodir)}
if '..' in commitid:
print "Deployed patches from =%s= repository:" % get_reponame_from_repodir(repodir)
else:
print "Deployed patch from =%s= repository:" % get_reponame_from_repodir(repodir)
print """\
#+BEGIN_EXAMPLE
%(msg_commit)s
#+END_EXAMPLE
%(txt)s:
""" % {'msg_commit': get_commit_msg(commitid, repodir), 'txt': CFG_MSG_MACHINE}
def write_single_repo_deploy_recipe_body(commitid, repodir):
"""
Write recipe body for deploying COMMITID from REPODIR.
"""
if '--via-filecopy' in sys.argv:
write_single_repo_deploy_recipe_body_via_filecopy(commitid, repodir)
elif '--via-install' in sys.argv:
write_single_repo_deploy_recipe_body_via_install(commitid, repodir)
else:
write_single_repo_deploy_recipe_body_via_install(commitid, repodir)
detect_db_changes(commitid, repodir)
def write_single_repo_deploy_recipe_body_via_install(commitid, repodir):
"""
Write recipe body for deploying commitid from REPODIR via make install.
"""
print """\
#+BEGIN_SRC sh
sudo -u %(apache)s /usr/bin/id
cd %(repodir)s/%(subdir)s
git pull
make -s
sudo -u %(apache)s make install
sudo -u %(apache)s %(prefixdir)s/bin/inveniocfg --update-all
sudo /etc/init.d/httpd graceful
#+END_SRC
""" % {'repodir': get_target_source_pathname(repodir),
'apache': CFG_INVENIO_USER,
'subdir': os.path.dirname(os.path.commonprefix(get_commit_files(commitid,
repodir))),
'prefixdir': CFG_PREFIX}
def write_single_repo_deploy_recipe_body_via_filecopy(commitid, repodir):
"""
Write recipe body for deploying commitid from REPODIR via file copy.
"""
l_file_targetdir = [] # list of tuples (afile, afile_target_dir) to install
l_file_submissiondump = [] # list of tuples (afile, dump_method, sbm_doctype) to install as submission
for afile in get_commit_files(commitid, repodir):
(is_dump_file_p, relation, msg) = detect_submission_change(afile)
if is_dump_file_p:
l_file_submissiondump.append((afile, relation, msg))
else:
afile_target_dir = detect_file_installation_place(afile)
if afile_target_dir:
l_file_targetdir.append((afile, afile_target_dir))
print """\
#+BEGIN_SRC sh
sudo -u %(apache)s /usr/bin/id
cd %(repodir)s
git pull""" % {'repodir': get_target_source_pathname(repodir),
'apache': CFG_INVENIO_USER,}
for afile, afile_target_dir in l_file_targetdir:
print """\
colordiff %(afile)s %(afile_target_dir)s""" % \
{'afile': afile, 'afile_target_dir': afile_target_dir}
for afile, afile_target_dir in l_file_targetdir:
print """\
sudo -u %(apache)s cp %(afile)s %(afile_target_dir)s""" % \
{'afile': afile, 'afile_target_dir': afile_target_dir,
'apache': CFG_INVENIO_USER}
for afile, afile_target_dir in l_file_targetdir:
print """\
colordiff %(afile)s %(afile_target_dir)s""" % \
{'afile': afile, 'afile_target_dir': afile_target_dir}
for afile, afile_sbm_method, afile_sbm_doctype in l_file_submissiondump:
if afile_sbm_method:
print "\
%(prefixdir)s/bin/websubmitadmin --diff=%(sbm_doctype)s -id,o -m %(sbm_dump_method)s < %(afile)s | less -S" % \
{'prefixdir': CFG_PREFIX,
'sbm_doctype': afile_sbm_doctype,
'sbm_dump_method': afile_sbm_method,
'afile': afile}
for afile, afile_sbm_method, afile_sbm_doctype in l_file_submissiondump:
if afile_sbm_method:
print """\
sudo -u %(apache)s %(prefixdir)s/bin/dbexec < %(afile)s""" % \
{'afile': afile,
'apache': CFG_INVENIO_USER,
'prefixdir': CFG_PREFIX}
else:
print "[ERROR]", afile_sbm_doctype
for afile, afile_sbm_method, afile_sbm_doctype in l_file_submissiondump:
if afile_sbm_method:
print "\
%(prefixdir)s/bin/websubmitadmin --diff=%(sbm_doctype)s -id,o -m %(sbm_dump_method)s < %(afile)s | less -S" % \
{'prefixdir': CFG_PREFIX,
'sbm_doctype': afile_sbm_doctype,
'sbm_dump_method': afile_sbm_method,
'afile': afile}
print """\
sudo /etc/init.d/httpd graceful
#+END_SRC
"""
def write_twin_repo_deploy_recipe_header(commitid1, repodir1,
commitid2, repodir2):
"""
Write recipe header for deploying COMMITID1 from REPODIR1 followed by
COMMITID2 from REPODIR2 via full re-installation.
"""
print """\
%(heading)s upgraded DEV/TEST/PROD to latest master (%(reponame1)s %(patch1)s, %(reponame2)s %(patch2)s)
""" % {'heading': CFG_MSG_HEADING, 'reponame1': get_reponame_from_repodir(repodir1),
'patch1': commitid1, 'reponame2': get_reponame_from_repodir(repodir2),
'patch2': commitid2}
return
def write_twin_repo_deploy_recipe_body(commitid1, repodir1,
commitid2, repodir2):
"""
Write recipe body for deploying COMMITID1 from REPODIR1 followed
by COMMITID2 from REPODIR2 via full re-installation.
FIXME: This function generates recipe for INSPIRE site at the
moment only. Not generalised yet.
"""
print """\
Upgraded DEV (PCUDSSW1508), TEST (PCUDSSW1505) and PROD
(PCUDSSW150[4,6-7],PCUDSSX1506) to latest git master sources
(%(reponame1)s %(commitid1)s, %(reponame2)s %(commitid2)s).
First, wait for bibsched jobs to stop and put the queue to manual mode
(on the first worker node). Then run upgrade in the following way:
On PROD, where we run with four worker nodes, you may want to
inactivate individual nodes in the load balancer manager (PCUDSSW1503)
as you progressively update them.
On every individual worker node:
#+BEGIN_SRC sh
sudo -u %(apache)s /usr/bin/id
cd %(repodir1)s
git pull
make -s
sudo -u %(apache)s make install
sudo -u %(apache)s %(prefixdir)s/bin/inveniocfg --update-all
sudo %(prefixdir)s/bin/inveniocfg --update-dbexec
cd %(repodir2)s
git pull
sudo -u %(apache)s make install
#+END_SRC
On DEV, uglify interface:
#+BEGIN_SRC sh
sudo -u %(apache)s make reset-ugly-ui
#+END_SRC
On TEST, uglify interface like this:
#+BEGIN_SRC sh
sudo -u %(apache)s make reset-ugly-ui
sudo -u %(apache)s cp webstyle/inspire_logo_beta_ugly_test.png \
%(prefixdir)s/var/www/img/inspire_logo_beta.png
#+END_SRC
Now restart Apache:
#+BEGIN_SRC sh
sudo /etc/init.d/httpd restart
#+END_SRC
Note that on PROD we have higher safety for =dbexec= which is to be
reset now:
#+BEGIN_SRC sh
sudo %(prefixdir)s/bin/inveniocfg --update-dbexec
sudo chmod go-rxw %(prefixdir)s/bin/dbexec*
sudo chown root.root %(prefixdir)s/bin/dbexec*
ls -l %(prefixdir)s/bin/dbexec*
#+END_SRC
Also on PROD the bibsched rights on the second worker node should be
revoked:
#+BEGIN_SRC sh
sudo chmod a-rwx %(prefixdir)s/bin/bibsched
ls -l %(prefixdir)s/bin/bibsched
#+END_SRC
Now put the bibsched queue back to automatic mode on the first worker
node and we are done.
""" % {'repodir1': get_target_source_pathname(repodir1),
'reponame1': os.path.basename(repodir1),
'commitid1': commitid1,
'repodir2': get_target_source_pathname(repodir2),
'reponame2': os.path.basename(repodir2),
'commitid2': commitid2,
'apache': CFG_INVENIO_USER,
'prefixdir': CFG_PREFIX}
def main():
"""
Do the job.
"""
if '--help' in sys.argv or '-h' in sys.argv:
print __doc__
sys.exit(0)
commitid = detect_commitid(sys.argv)
if ',' in commitid:
# deploying from two repositories: FIXME: 1st is assumed to be
# Invenio, 2nd assumed to be INSPIRE
repodir1 = CFG_INVENIO_SRCDIR
repodir2 = os.path.join(os.path.dirname(repodir1), 'inspire')
commitid1, commitid2 = commitid.split(',', 1)
commitid1 = normalise_commitid(commitid1, repodir1)
commitid2 = normalise_commitid(commitid2, repodir2)
write_twin_repo_deploy_recipe_header(commitid1, repodir1,
commitid2, repodir2)
write_twin_repo_deploy_recipe_body(commitid1, repodir1,
commitid2, repodir2)
else:
# deploying from single repository:
repodir = get_toplevel_dir(os.getcwd())
commitid1 = normalise_commitid(commitid, repodir)
write_single_repo_deploy_recipe_header(commitid1, repodir)
write_single_repo_deploy_recipe_body(commitid, repodir)
return
if __name__ == '__main__':
main()