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

« back to all changes in this revision

Viewing changes to bin/ivle-config

Move trampoline UID configuration out of config.

conf.h is now generated during the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
1
2
# IVLE - Informatics Virtual Learning Environment
2
 
# Copyright (C) 2007-2008 The University of Melbourne
 
3
# Copyright (C) 2007-2009 The University of Melbourne
3
4
#
4
5
# This program is free software; you can redistribute it and/or modify
5
6
# it under the terms of the GNU General Public License as published by
15
16
# along with this program; if not, write to the Free Software
16
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18
 
18
 
# Module: setup/config
19
19
# Author: Matt Giuca, Refactored by David Coles
20
 
# Date:   03/07/2008
21
 
 
22
 
# setup/config.py
23
 
# Configures IVLE with machine-specific details, most notably, various paths.
24
 
# Either prompts the administrator for these details or accepts them as
25
 
# command-line args.
26
 
# Creates lib/conf/conf.py and bin/trampoline/conf.h.
 
20
 
 
21
'''Configures IVLE with machine-specific details, most notably, various paths.
 
22
Either prompts the administrator for these details or accepts them as
 
23
command-line args.
 
24
 
 
25
Creates etc/ivle.conf
 
26
'''
27
27
 
28
28
import optparse
29
29
import getopt
32
32
import hashlib
33
33
import uuid
34
34
 
35
 
from setup.util import query_user
 
35
import ivle.config
 
36
 
 
37
import configobj
36
38
 
37
39
class ConfigOption:
38
40
    """A configuration option; one of the things written to conf.py."""
56
58
# Configuration options, defaults and descriptions
57
59
config_options = []
58
60
 
59
 
config_options.append(ConfigOption("root_dir", "/",
 
61
config_options.append(ConfigOption("urls/root", "/",
60
62
    """Root directory where IVLE is located (in URL space):""",
61
63
    """
62
64
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
63
65
# with this).
64
66
# eg. "/" or "/ivle".""", ask=False))
65
67
 
66
 
config_options.append(ConfigOption("prefix", "/usr/local",
 
68
config_options.append(ConfigOption("paths/prefix", "/usr/local",
67
69
    """In the local file system, the prefix to the system directory where IVLE
68
70
is installed. (This should either be /usr or /usr/local):""",
69
71
    """
72
74
# ('/usr/local' for the usual install, '/usr' for distribution packages)""",
73
75
    ask=False))
74
76
 
75
 
config_options.append(ConfigOption("python_site_packages_override",
 
77
config_options.append(ConfigOption("paths/site_packages",
76
78
    None,
77
79
    """site-packages directory in Python, where Python libraries are to be
78
80
installed. May be left as the default, in which case the value will be
79
81
computed from prefix and the current Python version:""",
80
82
    """
81
83
# 'site-packages' directory in Python, where Python libraries are to be
82
 
# installed. May be None (recommended), in which case the value will be
 
84
# installed. May be omitted (recommended), in which case the value will be
83
85
# computed from prefix and the current Python version.""", ask=False))
84
86
 
85
 
config_options.append(ConfigOption("data_path",
 
87
config_options.append(ConfigOption("paths/data",
86
88
    "/var/lib/ivle",
87
89
    "In the local file system, where user-modifiable data files should be "
88
90
    "located:",
90
92
# In the local file system, where user-modifiable data files should be
91
93
# located.""", ask=False))
92
94
 
93
 
config_options.append(ConfigOption("log_path",
 
95
config_options.append(ConfigOption("paths/logs",
94
96
    "/var/log/ivle",
95
97
    """Directory where IVLE log files are stored (on the local
96
98
file system). Note - this must be writable by the user the IVLE server 
99
101
# In the local file system, where IVLE error logs should be located.""",
100
102
    ask=False))
101
103
 
102
 
config_options.append(ConfigOption("public_host", "public.localhost",
 
104
config_options.append(ConfigOption("urls/public_host", "public.localhost",
103
105
    """Hostname which will cause the server to go into "public mode",
104
106
providing login-free access to student's published work:""",
105
107
    """
110
112
# Private mode (normal mode) requires login, and only serves files relevant to
111
113
# the logged-in user."""))
112
114
 
113
 
config_options.append(ConfigOption("allowed_uids", "33",
114
 
    """UID of the web server process which will run IVLE.
115
 
Only this user may execute the trampoline. May specify multiple users as
116
 
a comma-separated list.
117
 
    (eg. "1002,78")""",
118
 
    """
119
 
# The User-ID of the web server process which will run IVLE, and any other
120
 
# users who are allowed to run the trampoline. This is stores as a string of
121
 
# comma-separated integers, simply because it is not used within Python, only
122
 
# used by the setup program to write to conf.h (see setup.py config).""",
123
 
    ask=False))
124
 
 
125
 
config_options.append(ConfigOption("db_host", "localhost",
 
115
config_options.append(ConfigOption("database/host", "localhost",
126
116
    """PostgreSQL Database config
127
117
==========================
128
118
Hostname of the DB server:""",
129
119
    """
130
 
### PostgreSQL Database config ###
131
120
# Database server hostname"""))
132
121
 
133
 
config_options.append(ConfigOption("db_port", "5432",
 
122
config_options.append(ConfigOption("database/port", "5432",
134
123
    """Port of the DB server:""",
135
124
    """
136
125
# Database server port"""))
137
126
 
138
 
config_options.append(ConfigOption("db_dbname", "ivle",
 
127
config_options.append(ConfigOption("database/name", "ivle",
139
128
    """Database name:""",
140
129
    """
141
130
# Database name"""))
142
131
 
143
 
config_options.append(ConfigOption("db_forumdbname", "ivle_forum",
 
132
config_options.append(ConfigOption("plugins/forum/dbname", "ivle_forum",
144
133
    """Forum Database name:""",
145
134
    """
146
135
# Forum Database name"""))
147
136
 
148
 
config_options.append(ConfigOption("db_user", "postgres",
 
137
config_options.append(ConfigOption("database/username", "postgres",
149
138
    """Username for DB server login:""",
150
139
    """
151
140
# Database username"""))
152
141
 
153
 
config_options.append(ConfigOption("db_password", "",
 
142
config_options.append(ConfigOption("database/password", "",
154
143
    """Password for DB server login:
155
144
    (Caution: This password is stored in plaintext in ivle/conf/conf.py)""",
156
145
    """
157
146
# Database password"""))
158
147
 
159
 
config_options.append(ConfigOption("auth_modules", "",
 
148
config_options.append(ConfigOption("auth/modules", "",
160
149
    """Authentication config
161
150
=====================
162
151
Comma-separated list of authentication modules.""",
170
159
# other modules may be plugged in to auth against organisation-specific
171
160
# auth backends.""", ask=False))
172
161
 
173
 
config_options.append(ConfigOption("ldap_url", "ldaps://www.example.com",
 
162
config_options.append(ConfigOption("auth/ldap_url", "ldaps://www.example.com",
174
163
    """(LDAP options are only relevant if "ldap" is included in the list of
175
164
auth modules).
176
165
URL for LDAP authentication server:""",
177
166
    """
178
167
# URL for LDAP authentication server""", ask=False))
179
168
 
180
 
config_options.append(ConfigOption("ldap_format_string",
 
169
config_options.append(ConfigOption("auth/ldap_format_string",
181
170
    "uid=%s,ou=users,o=example",
182
171
    """Format string for LDAP auth request:
183
172
    (Must contain a single "%s" for the user's login name)""",
185
174
# Format string for LDAP auth request
186
175
# (Must contain a single "%s" for the user's login name)""", ask=False))
187
176
 
188
 
config_options.append(ConfigOption("subject_pulldown_modules", "",
 
177
config_options.append(ConfigOption("auth/subject_pulldown_modules", "",
189
178
    """Comma-separated list of subject pulldown modules.
190
179
Add proprietary modules to automatically enrol students in subjects.""",
191
180
    """
195
184
# other modules may be plugged in to pulldown against organisation-specific
196
185
# pulldown backends.""", ask=False))
197
186
 
198
 
config_options.append(ConfigOption("svn_addr", "http://svn.localhost/",
 
187
config_options.append(ConfigOption("urls/svn_addr", "http://svn.localhost/",
199
188
    """Subversion config
200
189
=================
201
190
The base url for accessing subversion repositories:""",
202
191
    """
203
192
# The base url for accessing subversion repositories."""))
204
193
 
205
 
config_options.append(ConfigOption("usrmgt_host", "localhost",
 
194
config_options.append(ConfigOption("usrmgt/host", "localhost",
206
195
    """User Management Server config
207
196
============================
208
197
The hostname where the usrmgt-server runs:""",
209
198
    """
210
199
# The hostname where the usrmgt-server runs."""))
211
200
 
212
 
config_options.append(ConfigOption("usrmgt_port", "2178",
 
201
config_options.append(ConfigOption("usrmgt/port", "2178",
213
202
    """The port where the usrmgt-server runs:""",
214
203
    """
215
204
# The port where the usrmgt-server runs.""", ask=False))
216
205
 
217
 
config_options.append(ConfigOption("usrmgt_magic", None,
 
206
config_options.append(ConfigOption("usrmgt/magic", None,
218
207
    """The password for the usrmgt-server:""",
219
208
    """
220
209
# The password for the usrmgt-server.""", ask=False))
221
210
 
 
211
def query_user(default, prompt):
 
212
    """Prompts the user for a string, which is read from a line of stdin.
 
213
    Exits silently if EOF is encountered. Returns the string, with spaces
 
214
    removed from the beginning and end.
 
215
 
 
216
    Returns default if a 0-length line (after spaces removed) was read.
 
217
    """
 
218
    if default is None:
 
219
        # A default of None means the value will be computed specially, so we
 
220
        # can't really tell you what it is
 
221
        defaultstr = "computed"
 
222
    elif isinstance(default, basestring):
 
223
        defaultstr = '"%s"' % default
 
224
    else:
 
225
        defaultstr = repr(default)
 
226
    sys.stdout.write('%s\n    (default: %s)\n>' % (prompt, defaultstr))
 
227
    try:
 
228
        val = sys.stdin.readline()
 
229
    except KeyboardInterrupt:
 
230
        # Ctrl+C
 
231
        sys.stdout.write("\n")
 
232
        sys.exit(1)
 
233
    sys.stdout.write("\n")
 
234
    # If EOF, exit
 
235
    if val == '': sys.exit(1)
 
236
    # If empty line, return default
 
237
    val = val.strip()
 
238
    if val == '': return default
 
239
    return val
 
240
 
222
241
def configure(args):
223
 
    usage = """usage: %prog config [options]
224
 
Creates lib/conf/conf.py (and a few other config files).
225
 
Interactively asks questions to set this up."""
226
 
 
227
 
    # Parse arguments
228
 
    parser = optparse.OptionParser(usage)
229
 
    (options, args) = parser.parse_args(args)
230
 
 
231
 
    # Call the real function
232
 
    return __configure(args)
233
 
 
234
 
def __configure(args):
235
 
    global db_port, usrmgt_port
236
 
 
237
242
    # Try importing existing conf, but if we can't just set up defaults
238
243
    # The reason for this is that these settings are used by other phases
239
244
    # of setup besides conf, so we need to know them.
240
245
    # Also this allows you to hit Return to accept the existing value.
241
246
    try:
242
 
        confmodule = __import__("ivle/conf/conf")
243
 
        for opt in config_options:
244
 
            try:
245
 
                globals()[opt.option_name] = \
246
 
                confmodule.__dict__[opt.option_name]
247
 
            except:
248
 
                globals()[opt.option_name] = opt.default
249
 
    except ImportError:
250
 
        # Just set reasonable defaults
251
 
        for opt in config_options:
252
 
            globals()[opt.option_name] = opt.default
 
247
        conf = ivle.config.Config()
 
248
    except ivle.config.ConfigError:
 
249
        # Couldn't find a config file anywhere.
 
250
        # Create a new blank config object (not yet bound to a file)
 
251
        # All lookups (below) will fail, so it will be initialised with all
 
252
        # the default values.
 
253
        conf = ivle.config.Config(blank=True)
 
254
 
 
255
    # Check that all the options are present, and if not, load the default
 
256
    for opt in config_options:
 
257
        try:
 
258
            conf.get_by_path(opt.option_name)
 
259
        except KeyError:
 
260
            # If the default is None, omit it
 
261
            # Else ConfigObj will write the string 'None' to the conf file
 
262
            if opt.default is not None:
 
263
                conf.set_by_path(opt.option_name, opt.default)
 
264
 
 
265
    # Store comments in the conf object
 
266
    for opt in config_options:
 
267
        # Omitted if the key doesn't exist
 
268
        conf.set_by_path(opt.option_name, comment=opt.comment)
253
269
 
254
270
    # Set up some variables
255
271
    cwd = os.getcwd()
256
272
 
257
273
    # the files that will be created/overwritten
258
 
    conffile = os.path.join(cwd, "ivle/conf/conf.py")
259
 
    jailconffile = os.path.join(cwd, "ivle/conf/jailconf.py")
260
 
    conf_hfile = os.path.join(cwd, "bin/trampoline/conf.h")
 
274
    conffile = os.path.join(cwd, "etc/ivle.conf")
261
275
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
262
276
 
263
277
    # Get command-line arguments to avoid asking questions.
277
291
        print """This tool will create the following files:
278
292
    %s
279
293
    %s
280
 
    %s
281
 
    %s
282
294
prompting you for details about your configuration. The file will be
283
295
overwritten if it already exists. It will *not* install or deploy IVLE.
284
296
 
285
297
Please hit Ctrl+C now if you do not wish to do this.
286
 
""" % (conffile, jailconffile, conf_hfile, phpBBconffile)
 
298
""" % (conffile, phpBBconffile)
287
299
 
288
300
        # Get information from the administrator
289
301
        # If EOF is encountered at any time during the questioning, just exit
291
303
 
292
304
        for opt in config_options:
293
305
            if opt.ask:
294
 
                globals()[opt.option_name] = \
295
 
                    query_user(globals()[opt.option_name], opt.prompt)
 
306
                conf.set_by_path(opt.option_name,
 
307
                    query_user(conf.get_by_path(opt.option_name), opt.prompt))
296
308
    else:
297
309
        opts = dict(opts)
298
310
        # Non-interactive mode. Parse the options.
299
311
        for opt in config_options:
300
312
            if '--' + opt.option_name in opts:
301
 
                globals()[opt.option_name] = opts['--' + opt.option_name]
 
313
                conf.set_by_path(opt.option_name,
 
314
                                 opts['--' + opt.option_name])
302
315
 
303
316
    # Error handling on input values
304
317
    try:
305
 
        allowed_uids_list = map(int, allowed_uids.split(','))
306
 
    except ValueError:
307
 
        print >>sys.stderr, (
308
 
        "Invalid UID list (%s).\n"
309
 
        "Must be a comma-separated list of integers." % allowed_uids)
310
 
        return 1
311
 
    try:
312
 
        db_port = int(db_port)
313
 
        if db_port < 0 or db_port >= 65536: raise ValueError()
 
318
        conf['database']['port'] = int(conf['database']['port'])
 
319
        if (conf['database']['port'] < 0
 
320
            or conf['database']['port'] >= 65536):
 
321
            raise ValueError()
314
322
    except ValueError:
315
323
        print >>sys.stderr, (
316
324
        "Invalid DB port (%s).\n"
317
 
        "Must be an integer between 0 and 65535." % repr(db_port))
 
325
        "Must be an integer between 0 and 65535." %
 
326
            repr(conf['database']['port']))
318
327
        return 1
319
328
    try:
320
 
        usrmgt_port = int(usrmgt_port)
321
 
        if usrmgt_port < 0 or usrmgt_port >= 65536: raise ValueError()
 
329
        conf['usrmgt']['port'] = int(conf['usrmgt']['port'])
 
330
        if (conf['usrmgt']['port'] < 0 or conf['usrmgt']['port'] >= 65536):
 
331
            raise ValueError()
322
332
    except ValueError:
323
333
        print >>sys.stderr, (
324
334
        "Invalid user management port (%s).\n"
325
 
        "Must be an integer between 0 and 65535." % repr(usrmgt_port))
 
335
        "Must be an integer between 0 and 65535." %
 
336
            repr(conf['usrmgt']['port']))
326
337
        return 1
327
338
 
328
339
    # By default we generate the magic randomly.
329
 
    if globals()['usrmgt_magic'] is None:
330
 
        globals()['usrmgt_magic'] = hashlib.md5(uuid.uuid4().bytes).hexdigest()
 
340
    try:
 
341
        conf['usrmgt']['magic']     # Throw away; just check for KeyError
 
342
    except KeyError:
 
343
        conf['usrmgt']['magic'] = hashlib.md5(uuid.uuid4().bytes).hexdigest()
331
344
 
332
345
    # Generate the forum secret
333
346
    forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
334
347
 
335
 
    # Write lib/conf/conf.py
336
 
 
337
 
    try:
338
 
        conf = open(conffile, "w")
339
 
 
340
 
        conf.write("""# IVLE Configuration File
341
 
# conf.py
342
 
# Miscellaneous application settings
343
 
 
344
 
import os
345
 
import sys
346
 
""")
347
 
        for opt in config_options:
348
 
            conf.write('%s\n%s = %r\n' % (opt.comment, opt.option_name,
349
 
                globals()[opt.option_name]))
350
 
 
351
 
            # Add the forum secret to the config file (regenerated each config)
352
 
        conf.write('forum_secret = "%s"\n\n' % (forum_secret))
353
 
 
354
 
        write_conf_file_boilerplate(conf)
355
 
 
356
 
        conf.close()
357
 
    except IOError, (errno, strerror):
358
 
        print "IO error(%s): %s" % (errno, strerror)
359
 
        sys.exit(1)
 
348
    # Write ./etc/ivle.conf (even if we loaded from a different filename)
 
349
    conf.filename = conffile
 
350
 
 
351
    conf.initial_comment = ["# IVLE Configuration File"]
 
352
 
 
353
    # Add the forum secret to the config file (regenerated each config)
 
354
    config_options.append(ConfigOption('plugins/forum/secret', None, '', ''))
 
355
    conf['plugins']['forum']['secret'] = forum_secret
 
356
 
 
357
    conf.write()
360
358
 
361
359
    print "Successfully wrote %s" % conffile
362
360
 
363
 
    # Write conf/jailconf.py
364
 
 
365
 
    try:
366
 
        conf = open(jailconffile, "w")
367
 
 
368
 
        # In the "in-jail" version of conf, we don't need MOST of the details
369
 
        # (it would be a security risk to have them here).
370
 
        # So we just write root_dir, and jail_base is "/".
371
 
        # (jail_base being "/" means "jail-relative" paths are relative to "/"
372
 
        # when inside the jail.)
373
 
        conf.write("""# IVLE Configuration File
374
 
# conf.py
375
 
# Miscellaneous application settings
376
 
# (User jail version)
377
 
 
378
 
 
379
 
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
380
 
# with this).
381
 
# eg. "/" or "/ivle".
382
 
root_dir = %s
383
 
 
384
 
# In the local file system, where are the student/user file spaces located.
385
 
# The user jails are expected to be located immediately in subdirectories of
386
 
# this location.
387
 
jail_base = '/'
388
 
 
389
 
# The hostname for serving publicly accessible pages
390
 
public_host = %s
391
 
 
392
 
# The URL under which the Subversion repositories are located.
393
 
svn_addr = %s
394
 
""" % (repr(root_dir),repr(public_host),repr(svn_addr)))
395
 
 
396
 
        conf.close()
397
 
    except IOError, (errno, strerror):
398
 
        print "IO error(%s): %s" % (errno, strerror)
399
 
        sys.exit(1)
400
 
 
401
 
    print "Successfully wrote %s" % jailconffile
402
 
 
403
 
    # Write bin/trampoline/conf.h
404
 
 
405
 
    try:
406
 
        conf = open(conf_hfile, "w")
407
 
 
408
 
        # XXX Compute jail_base, jail_src_base and jail_system. These will
409
 
        # ALSO be done by the boilerplate code, but we need them here in order
410
 
        # to write to the C file.
411
 
        jail_base = os.path.join(data_path, 'jailmounts')
412
 
        jail_src_base = os.path.join(data_path, 'jails')
413
 
        jail_system = os.path.join(jail_src_base, '__base__')
414
 
 
415
 
        conf.write("""/* IVLE Configuration File
416
 
 * conf.h
417
 
 * Administrator settings required by trampoline.
418
 
 * Note: trampoline will have to be rebuilt in order for changes to this file
419
 
 * to take effect.
420
 
 */
421
 
 
422
 
#define IVLE_AUFS_JAILS
423
 
 
424
 
/* In the local file system, where are the jails located.
425
 
 * The trampoline does not allow the creation of a jail anywhere besides
426
 
 * jail_base or a subdirectory of jail_base.
427
 
 */
428
 
static const char* jail_base = "%s";
429
 
static const char* jail_src_base = "%s";
430
 
static const char* jail_system = "%s";
431
 
 
432
 
/* Which user IDs are allowed to run the trampoline.
433
 
 * This list should be limited to the web server user.
434
 
 * (Note that root is an implicit member of this list).
435
 
 */
436
 
static const int allowed_uids[] = { %s };
437
 
""" % (repr(jail_base)[1:-1], repr(jail_src_base)[1:-1],
438
 
       repr(jail_system)[1:-1], repr(allowed_uids_list)[1:-1]))
439
 
    # Note: The above uses PYTHON reprs, not C reprs
440
 
    # However they should be the same with the exception of the outer
441
 
    # characters, which are stripped off and replaced
442
 
 
443
 
        conf.close()
444
 
    except IOError, (errno, strerror):
445
 
        print "IO error(%s): %s" % (errno, strerror)
446
 
        sys.exit(1)
447
 
 
448
 
    print "Successfully wrote %s" % conf_hfile
449
 
 
450
361
    # Write www/php/phpBB3/config.php
451
362
 
452
 
    try:
453
 
        conf = open(phpBBconffile, "w")
454
 
        
455
 
        # php-pg work around
456
 
        if db_host == 'localhost':
457
 
            forumdb_host = '127.0.0.1'
458
 
        else:
459
 
            forumdb_host = db_host
 
363
    conf_php = open(phpBBconffile, "w")
 
364
    
 
365
    # php-pg work around
 
366
    if conf['database']['host'] == 'localhost':
 
367
        forumdb_host = '127.0.0.1'
 
368
    else:
 
369
        forumdb_host = conf['database']['host']
460
370
 
461
 
        conf.write( """<?php
 
371
    conf_php.write( """<?php
462
372
// phpBB 3.0.x auto-generated configuration file
463
373
// Do not change anything in this file!
464
374
$dbms = 'postgres';
465
375
$dbhost = '""" + forumdb_host + """';
466
 
$dbport = '""" + str(db_port) + """';
467
 
$dbname = '""" + db_forumdbname + """';
468
 
$dbuser = '""" + db_user + """';
469
 
$dbpasswd = '""" + db_password + """';
 
376
$dbport = '""" + str(conf['database']['port']) + """';
 
377
$dbname = '""" + conf['plugins']['forum']['dbname'] + """';
 
378
$dbuser = '""" + conf['database']['username'] + """';
 
379
$dbpasswd = '""" + conf['database']['password'] + """';
470
380
 
471
381
$table_prefix = 'phpbb_';
472
382
$acm_type = 'file';
478
388
$forum_secret = '""" + forum_secret +"""';
479
389
?>"""   )
480
390
    
481
 
        conf.close()
482
 
    except IOError, (errno, strerror):
483
 
        print "IO error(%s): %s" % (errno, strerror)
484
 
        sys.exit(1)
 
391
    conf_php.close()
485
392
 
486
393
    print "Successfully wrote %s" % phpBBconffile
487
394
 
488
395
    print
489
396
    print "You may modify the configuration at any time by editing"
490
397
    print conffile
491
 
    print jailconffile
492
 
    print conf_hfile
493
398
    print phpBBconffile
494
399
    print
495
400
    
496
401
    return 0
497
402
 
498
 
def write_conf_file_boilerplate(conf_file):
499
 
    conf_file.write("""\
500
 
### Below is boilerplate code, appended by ./setup.py config ###
501
 
 
502
 
# Path where architecture-dependent data (including non-user-executable
503
 
# binaries) is installed.
504
 
lib_path = os.path.join(prefix, 'lib/ivle')
505
 
 
506
 
# Path where arch-independent data is installed.
507
 
share_path = os.path.join(prefix, 'share/ivle')
508
 
 
509
 
# Path where user-executable binaries are installed.
510
 
bin_path = os.path.join(prefix, 'bin')
511
 
 
512
 
# 'site-packages' directory in Python, where Python libraries are to be
513
 
# installed.
514
 
if python_site_packages_override is None:
515
 
    PYTHON_VERSION = sys.version[0:3]   # eg. "2.5"
516
 
    python_site_packages = os.path.join(prefix,
517
 
                               'lib/python%s/site-packages' % PYTHON_VERSION)
518
 
else:
519
 
    python_site_packages = python_site_packages_override
520
 
 
521
 
# In the local file system, where the student/user jails will be mounted.
522
 
# Only a single copy of the jail's system components will be stored here -
523
 
# all user jails will be virtually mounted here.
524
 
jail_base = os.path.join(data_path, 'jailmounts')
525
 
 
526
 
# In the local file system, where are the student/user file spaces located.
527
 
# The user jails are expected to be located immediately in subdirectories of
528
 
# this location. Note that no complete jails reside here - only user
529
 
# modifications.
530
 
jail_src_base = os.path.join(data_path, 'jails')
531
 
 
532
 
# In the local file system, where the template system jail will be stored.
533
 
jail_system = os.path.join(jail_src_base, '__base__')
534
 
 
535
 
# In the local file system, where the subject content files are located.
536
 
# (The 'subjects' and 'exercises' directories).
537
 
content_path = os.path.join(data_path, 'content')
538
 
 
539
 
# In the local file system, where are the per-subject file spaces located.
540
 
# The individual subject directories are expected to be located immediately
541
 
# in subdirectories of this location.
542
 
subjects_base = os.path.join(content_path, 'subjects')
543
 
 
544
 
# In the local file system, where are the subject-independent exercise sheet
545
 
# file spaces located.
546
 
exercises_base = os.path.join(content_path, 'exercises')
547
 
 
548
 
# In the local file system, where the system notices are stored (such as terms
549
 
# of service and MOTD).
550
 
notices_path = os.path.join(data_path, 'notices')
551
 
 
552
 
# In the local file system, where is the Terms of Service document located.
553
 
tos_path = os.path.join(notices_path, 'tos.html')
554
 
 
555
 
# In the local file system, where is the Message of the Day document
556
 
# located. This is an HTML file (just the body fragment), which will
557
 
# be displayed on the login page. It is optional.
558
 
motd_path = os.path.join(notices_path, 'motd.html')
559
 
 
560
 
# The location of all the subversion config and repositories.
561
 
svn_path = os.path.join(data_path, 'svn')
562
 
 
563
 
# The location of the subversion configuration file used by
564
 
# apache to host the user repositories.
565
 
svn_conf = os.path.join(svn_path, 'svn.conf')
566
 
 
567
 
# The location of the subversion configuration file used by
568
 
# apache to host the user repositories.
569
 
svn_group_conf = os.path.join(svn_path, 'svn-group.conf')
570
 
 
571
 
# The root directory for the subversion repositories.
572
 
svn_repo_path = os.path.join(svn_path, 'repositories')
573
 
 
574
 
# The location of the password file used to authenticate users
575
 
# of the subversion repository from the ivle server.
576
 
svn_auth_ivle = os.path.join(svn_path, 'ivle.auth')
577
 
""")
 
403
def main(argv=None):
 
404
    if argv is None:
 
405
        argv = sys.argv
 
406
 
 
407
    # Print the opening spiel including the GPL notice
 
408
 
 
409
    print """IVLE - Informatics Virtual Learning Environment Setup
 
410
Copyright (C) 2007-2009 The University of Melbourne
 
411
IVLE comes with ABSOLUTELY NO WARRANTY.
 
412
This is free software, and you are welcome to redistribute it
 
413
under certain conditions. See LICENSE.txt for details.
 
414
 
 
415
IVLE Configuration
 
416
"""
 
417
 
 
418
    return configure(argv[1:])
 
419
 
 
420
if __name__ == "__main__":
 
421
    sys.exit(main())