75
74
# ('/usr/local' for the usual install, '/usr' for distribution packages)""",
77
config_options.append(ConfigOption("paths/site_packages",
79
"""site-packages directory in Python, where Python libraries are to be
80
installed. May be left as the default, in which case the value will be
81
computed from prefix and the current Python version:""",
83
# 'site-packages' directory in Python, where Python libraries are to be
84
# installed. May be omitted (recommended), in which case the value will be
85
# computed from prefix and the current Python version.""", ask=False))
78
87
config_options.append(ConfigOption("paths/data",
80
89
"In the local file system, where user-modifiable data files should be "
92
101
# In the local file system, where IVLE error logs should be located.""",
95
config_options.append(ConfigOption("urls/public_host",
96
"public.ivle.localhost",
104
config_options.append(ConfigOption("urls/public_host", "public.localhost",
97
105
"""Hostname which will cause the server to go into "public mode",
98
106
providing login-free access to student's published work:""",
104
112
# Private mode (normal mode) requires login, and only serves files relevant to
105
113
# the logged-in user."""))
107
config_options.append(ConfigOption("media/version", None,
108
"""Version of IVLE media resources (must change on each upgrade):""",
110
# Version string for IVLE media resource URLs. When set, they are aggressively
111
# cached by the browser, so it must be either left unset or changed each time
112
# a media file is changed.""", ask=False))
114
115
config_options.append(ConfigOption("database/host", "localhost",
115
116
"""PostgreSQL Database config
116
117
==========================
136
137
config_options.append(ConfigOption("database/password", "",
137
138
"""Password for DB server login:
138
(Caution: This password is stored in plaintext!)""",
139
(Caution: This password is stored in plaintext in ivle/conf/conf.py)""",
140
141
# Database password"""))
178
179
# other modules may be plugged in to pulldown against organisation-specific
179
180
# pulldown backends.""", ask=False))
181
config_options.append(ConfigOption("urls/svn_addr",
182
"http://svn.ivle.localhost/",
182
config_options.append(ConfigOption("urls/svn_addr", "http://svn.localhost/",
183
183
"""Subversion config
184
184
=================
185
185
The base url for accessing subversion repositories:""",
266
266
cwd = os.getcwd()
268
268
# the files that will be created/overwritten
270
confdir = os.environ['IVLECONF']
272
confdir = '/etc/ivle'
274
conffile = os.path.join(confdir, 'ivle.conf')
275
plugindefaultfile = os.path.join(confdir, 'plugins.d/000default.conf')
269
conffile = os.path.join(cwd, "etc/ivle.conf")
277
271
# Get command-line arguments to avoid asking questions.
289
283
# Interactive mode. Prompt the user for all the values.
291
285
print """This tool will create %s, prompting you for details about
292
your configuration. The file will be updated with modified options if it already
293
exists. If it does not already exist, it will be created with sane defaults and
294
restrictive permissions.
296
%s will also be overwritten with the default list of plugins.
286
your configuration. The file will be overwritten if it already exists.
298
288
Please hit Ctrl+C now if you do not wish to do this.
299
""" % (conffile, plugindefaultfile)
301
291
# Get information from the administrator
302
292
# If EOF is encountered at any time during the questioning, just exit
321
311
or conf['database']['port'] >= 65536):
322
312
raise ValueError()
323
313
except ValueError:
324
if conf['database']['port'] == '' or conf['database']['port'] is None:
327
print >>sys.stderr, (
328
"Invalid DB port (%s).\n"
329
"Must be an integer between 0 and 65535." %
330
repr(conf['database']['port']))
314
print >>sys.stderr, (
315
"Invalid DB port (%s).\n"
316
"Must be an integer between 0 and 65535." %
317
repr(conf['database']['port']))
333
320
conf['usrmgt']['port'] = int(conf['usrmgt']['port'])
334
321
if (conf['usrmgt']['port'] < 0 or conf['usrmgt']['port'] >= 65536):
347
334
conf['usrmgt']['magic'] = hashlib.md5(uuid.uuid4().bytes).hexdigest()
349
clobber_permissions = not os.path.exists(conffile)
351
337
# Write ./etc/ivle.conf (even if we loaded from a different filename)
352
338
conf.filename = conffile
353
340
conf.initial_comment = ["# IVLE Configuration File"]
343
conf['plugins']['forum']['secret']
345
# Generate the forum secret.
346
forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
347
conf['plugins']['forum']['secret'] = forum_secret
356
# We need to restrict permissions on a new file, as it contains
357
# a nice database password.
358
if clobber_permissions:
359
os.chown(conffile, 33, 33) # chown to www-data
360
os.chmod(conffile, stat.S_IRUSR | stat.S_IWUSR) # No g/o perms!
362
351
print "Successfully wrote %s" % conffile
364
plugindefault = open(plugindefaultfile, 'w')
365
plugindefault.write("""# IVLE default plugin configuration file
366
[ivle.webapp.core#Plugin]
367
[ivle.webapp.admin.user#Plugin]
368
[ivle.webapp.tutorial#Plugin]
369
[ivle.webapp.admin.subject#Plugin]
370
[ivle.webapp.filesystem.browser#Plugin]
371
[ivle.webapp.filesystem.diff#Plugin]
372
[ivle.webapp.filesystem.svnlog#Plugin]
373
[ivle.webapp.filesystem.serve#Plugin]
374
[ivle.webapp.groups#Plugin]
375
[ivle.webapp.console#Plugin]
376
[ivle.webapp.security#Plugin]
377
[ivle.webapp.media#Plugin]
378
[ivle.webapp.help#Plugin]
379
[ivle.webapp.tos#Plugin]
380
[ivle.webapp.userservice#Plugin]
381
[ivle.webapp.fileservice#Plugin]
382
[ivle.webapp.submit#Plugin]
384
plugindefault.close()
385
print "Successfully wrote %s" % plugindefaultfile
388
353
print "You may modify the configuration at any time by editing " + conffile