Skip to content

Commit 0cfec0e

Browse files
committed
Allow site-specific configuration
1 parent a289cfc commit 0cfec0e

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

doc/installation.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ Prerequisites
8080
where the files for jobs that run on the cluster are placed (the 'running' directory). (If space is limited on the network
8181
storage, web services can also be configured to move the files back to the cheaper local filesystem - the 'completed'
8282
directory - when the job is done.)
83+
84+
After installation, manually install `python/saliweb/config.py` and add
85+
site-specific configuration, such as the location of your SVN and git
86+
repositories and your email domain.

python/saliweb/SConscript

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import os
33
Import('env')
44

55
ws_script = 'web_service.py'
6+
# Note that we do not install config.py, so as not to overwrite any
7+
# site-specific config
68
python_files = [ '__init__.py', 'make_web_service.py', ws_script ]
79

810
# Install .py files:

python/saliweb/make_web_service.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import pwd
77
import subprocess
8+
from saliweb import config
89

910

1011
def _run_command(prefix, cmd, cwd):
@@ -18,7 +19,7 @@ class SVNSourceControl(object):
1819
def __init__(self, short_name, topdir):
1920
self.short_name = short_name
2021
self.topdir = topdir
21-
self.svn_url = 'https://svn.salilab.org/' + short_name
22+
self.svn_url = os.path.join(config.svn_url_top, short_name)
2223
self.svn_trunk_url = self.svn_url + '/trunk'
2324

2425
def _run_svn_command(self, cmd, cwd=None):
@@ -46,7 +47,7 @@ class GitSourceControl(object):
4647
def __init__(self, short_name, topdir):
4748
self.short_name = short_name
4849
self.topdir = topdir
49-
self.url = '[email protected]:salilab/%s.git' % short_name
50+
self.url = '[email protected]:%s/%s.git' % (config.github_org, short_name)
5051

5152
def _run_git_command(self, cmd, cwd=None):
5253
_run_command('git', cmd, cwd)
@@ -85,6 +86,7 @@ def __init__(self, short_name, service_name, git):
8586
self.topdir = self.short_name
8687
self.user = self.short_name
8788
self.db = self.short_name
89+
self.email_domain = config.email_domain
8890
if git:
8991
self.source_control = GitSourceControl(short_name, self.topdir)
9092
else:
@@ -152,14 +154,15 @@ def _get_install_dir(self):
152154
print("""The %(user)s user doesn't exist. Please create it first:
153155
154156
1. Determine the UID for the new user and add it to the wiki page:
155-
https://salilab.org/internal/wiki/SysAdmin/UID
157+
%(wiki)s
156158
157159
2. Set up the %(user)s user and group by running
158160
/usr/bin/sudo /usr/sbin/groupadd -g <UID> %(user)s
159161
/usr/bin/sudo /usr/sbin/useradd -u <UID> -g <UID> -c '%(user)s service' \\
160162
-d %(dir)s %(user)s
161163
/usr/bin/sudo chmod a+rx ~%(user)s
162-
""" % {'user': self.user, 'dir': '/modbase5/home/%s' % self.user})
164+
""" % {'user': self.user, 'dir': os.path.join(config.home_top, self.user),
165+
'wiki': config.wiki_uid_page})
163166
sys.exit(1)
164167
return os.path.join(dir, 'service')
165168

@@ -231,7 +234,7 @@ def _make_sconscripts(self):
231234
def _make_config(self):
232235
with open(os.path.join(self.topdir, 'conf', 'live.conf'), 'w') as f:
233236
print("""[general]
234-
admin_email: %(user)s@salilab.org
237+
admin_email: %(user)s@%(email_domain)s
235238
socket: %(install)s/%(short_name)s.socket
236239
service_name: %(service_name)s
237240
urltop: https://modbase.compbio.ucsf.edu/%(short_name)s
@@ -380,9 +383,9 @@ def _make_templates(self):
380383
381384
{%% block body %%}
382385
<p>Please address inquiries to:<br />
383-
<script type="text/javascript">escramble('%s','salilab.org')</script></p>
386+
<script type="text/javascript">escramble('%s','%s')</script></p>
384387
{%% endblock %%}
385-
""" % (self.service_name, self.user), file=f)
388+
""" % (self.service_name, self.user, config.email_domain), file=f)
386389

387390
with open(os.path.join(template_dir, 'help.html'), 'w') as f:
388391
print("""{%% extends "layout.html" %%}
@@ -407,13 +410,15 @@ def get_options():
407410
the generated Python modules, system and MySQL users etc. An SVN
408411
(--svn option) or git (--git) repository with the same name is assumed
409412
to already exist, but to be empty (e.g. if SHORT_NAME is 'modfoo' the
410-
repository should exist at https://svn.salilab.org/modfoo or
411-
https://github.com/salilab/modfoo). A working directory with the same
412-
name is set up, and the files checked in to the trunk of the SVN or git
413-
repository. Users can then work on the service by checking out the SVN
414-
trunk (e.g. "svn co https://svn.salilab.org/modfoo/trunk modfoo")
413+
repository should exist at %(svn_url_top)s/modfoo or
414+
https://github.com/%(github_org)s/modfoo). A working directory with
415+
the same name is set up, and the files checked in to the trunk of the
416+
SVN or git repository. Users can then work on the service by checking
417+
out the SVN trunk
418+
(e.g. "svn co %(svn_url_top)s/modfoo/trunk modfoo")
415419
or cloning the git repository
416-
(e.g. "git clone https://github.com/salilab/modfoo.git").""")
420+
(e.g. "git clone https://github.com/%(github_org)s/modfoo.git")."""
421+
% {'svn_url_top': config.svn_url_top, 'github_org': config.github_org})
417422
parser.add_argument(
418423
"service_name", metavar="SERVICE_NAME",
419424
help='Human-readable name of the web service, for example "ModFoo" '

0 commit comments

Comments
 (0)