~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/ivle-config

  • Committer: William Grant
  • Date: 2009-06-24 10:36:40 UTC
  • Revision ID: grantw@unimelb.edu.au-20090624103640-os28zap2wkyz2udb
Simplify (and deprettify) the crash handler. It's now only used to handle crashes, so needn't be pretty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
# ('/usr/local' for the usual install, '/usr' for distribution packages)""",
76
76
    ask=False))
77
77
 
78
 
config_options.append(ConfigOption("paths/site_packages",
79
 
    None,
80
 
    """site-packages directory in Python, where Python libraries are to be
81
 
installed. May be left as the default, in which case the value will be
82
 
computed from prefix and the current Python version:""",
83
 
    """
84
 
# 'site-packages' directory in Python, where Python libraries are to be
85
 
# installed. May be omitted (recommended), in which case the value will be
86
 
# computed from prefix and the current Python version.""", ask=False))
87
 
 
88
78
config_options.append(ConfigOption("paths/data",
89
79
    "/var/lib/ivle",
90
80
    "In the local file system, where user-modifiable data files should be "
113
103
# Private mode (normal mode) requires login, and only serves files relevant to
114
104
# the logged-in user."""))
115
105
 
 
106
config_options.append(ConfigOption("media/version", None,
 
107
    """Version of IVLE media resources (must change on each upgrade):""",
 
108
    """
 
109
# Version string for IVLE media resource URLs. When set, they are aggressively
 
110
# cached by the browser, so it must be either left unset or changed each time
 
111
# a media file is changed.""", ask=False))
 
112
 
116
113
config_options.append(ConfigOption("database/host", "localhost",
117
114
    """PostgreSQL Database config
118
115
==========================
273
270
        confdir = '/etc/ivle'
274
271
 
275
272
    conffile = os.path.join(confdir, 'ivle.conf')
 
273
    plugindefaultfile = os.path.join(confdir, 'plugins.d/000default.conf')
276
274
 
277
275
    # Get command-line arguments to avoid asking questions.
278
276
 
293
291
exists. If it does not already exist, it will be created with sane defaults and
294
292
restrictive permissions.
295
293
 
 
294
%s will also be overwritten with the default list of plugins.
 
295
 
296
296
Please hit Ctrl+C now if you do not wish to do this.
297
 
""" % conffile
 
297
""" % (conffile, plugindefaultfile)
298
298
 
299
299
        # Get information from the administrator
300
300
        # If EOF is encountered at any time during the questioning, just exit
319
319
            or conf['database']['port'] >= 65536):
320
320
            raise ValueError()
321
321
    except ValueError:
322
 
        print >>sys.stderr, (
323
 
        "Invalid DB port (%s).\n"
324
 
        "Must be an integer between 0 and 65535." %
325
 
            repr(conf['database']['port']))
326
 
        return 1
 
322
        if conf['database']['port'] == '' or conf['database']['port'] is None:
 
323
            pass
 
324
        else:
 
325
            print >>sys.stderr, (
 
326
            "Invalid DB port (%s).\n"
 
327
            "Must be an integer between 0 and 65535." %
 
328
                repr(conf['database']['port']))
 
329
            return 1
327
330
    try:
328
331
        conf['usrmgt']['port'] = int(conf['usrmgt']['port'])
329
332
        if (conf['usrmgt']['port'] < 0 or conf['usrmgt']['port'] >= 65536):
346
349
    # Write ./etc/ivle.conf (even if we loaded from a different filename)
347
350
    conf.filename = conffile
348
351
    conf.initial_comment = ["# IVLE Configuration File"]
349
 
 
350
 
    try:
351
 
        conf['plugins']['forum']['secret']
352
 
    except KeyError:
353
 
        # Generate the forum secret.
354
 
        forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
355
 
        conf['plugins']['forum']['secret'] = forum_secret
356
 
 
357
352
    conf.write()
358
353
 
359
354
    # We need to restrict permissions on a new file, as it contains
363
358
        os.chmod(conffile, stat.S_IRUSR | stat.S_IWUSR) # No g/o perms!
364
359
 
365
360
    print "Successfully wrote %s" % conffile
 
361
 
 
362
    plugindefault = open(plugindefaultfile, 'w')
 
363
    plugindefault.write("""# IVLE default plugin configuration file
 
364
[ivle.webapp.core#Plugin]
 
365
[ivle.webapp.admin.user#Plugin]
 
366
[ivle.webapp.tutorial#Plugin]
 
367
[ivle.webapp.admin.subject#Plugin]
 
368
[ivle.webapp.filesystem.browser#Plugin]
 
369
[ivle.webapp.filesystem.diff#Plugin]
 
370
[ivle.webapp.filesystem.svnlog#Plugin]
 
371
[ivle.webapp.filesystem.serve#Plugin]
 
372
[ivle.webapp.groups#Plugin]
 
373
[ivle.webapp.console#Plugin]
 
374
[ivle.webapp.security#Plugin]
 
375
[ivle.webapp.media#Plugin]
 
376
[ivle.webapp.help#Plugin]
 
377
[ivle.webapp.tos#Plugin]
 
378
[ivle.webapp.userservice#Plugin]
 
379
[ivle.webapp.fileservice#Plugin]
 
380
[ivle.webapp.submit#Plugin]
 
381
""")
 
382
    plugindefault.close()
 
383
    print "Successfully wrote %s" % plugindefaultfile
 
384
 
366
385
    print
367
386
    print "You may modify the configuration at any time by editing " + conffile
368
387