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

« back to all changes in this revision

Viewing changes to bin/ivle-config

  • Committer: William Grant
  • Date: 2009-03-31 05:53:01 UTC
  • mto: (1165.3.1 submissions)
  • mto: This revision was merged to the branch mainline in revision 1174.
  • Revision ID: grantw@unimelb.edu.au-20090331055301-rlbw9lqg9f3d0bar
Display times in 12 hour - not 24 hour - format, by popular demand.

Show diffs side-by-side

added added

removed removed

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