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

« back to all changes in this revision

Viewing changes to setup/configure.py

ivle-buildjail: Remove some too-new rsync options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
1
# IVLE - Informatics Virtual Learning Environment
3
2
# Copyright (C) 2007-2009 The University of Melbourne
4
3
#
16
15
# along with this program; if not, write to the Free Software
17
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
17
 
 
18
# Module: setup/config
19
19
# Author: Matt Giuca, Refactored by David Coles
 
20
# Date:   03/07/2008
20
21
 
21
22
'''Configures IVLE with machine-specific details, most notably, various paths.
22
23
Either prompts the administrator for these details or accepts them as
23
24
command-line args.
24
25
 
25
 
Creates etc/ivle.conf
 
26
Creates ivle/conf/conf.py and bin/trampoline/trampoline/conf.h.
26
27
'''
27
28
 
28
29
import optparse
29
30
import getopt
30
31
import os
31
32
import sys
32
 
import stat
33
33
import hashlib
34
34
import uuid
35
35
 
36
 
import ivle.config
37
 
 
38
 
import configobj
 
36
from setup.util import query_user
39
37
 
40
38
class ConfigOption:
41
39
    """A configuration option; one of the things written to conf.py."""
59
57
# Configuration options, defaults and descriptions
60
58
config_options = []
61
59
 
62
 
config_options.append(ConfigOption("urls/root", "/",
 
60
config_options.append(ConfigOption("root_dir", "/",
63
61
    """Root directory where IVLE is located (in URL space):""",
64
62
    """
65
63
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
66
64
# with this).
67
65
# eg. "/" or "/ivle".""", ask=False))
68
66
 
69
 
config_options.append(ConfigOption("paths/prefix", "/usr/local",
 
67
config_options.append(ConfigOption("prefix", "/usr/local",
70
68
    """In the local file system, the prefix to the system directory where IVLE
71
69
is installed. (This should either be /usr or /usr/local):""",
72
70
    """
75
73
# ('/usr/local' for the usual install, '/usr' for distribution packages)""",
76
74
    ask=False))
77
75
 
78
 
config_options.append(ConfigOption("paths/site_packages",
 
76
config_options.append(ConfigOption("python_site_packages_override",
79
77
    None,
80
78
    """site-packages directory in Python, where Python libraries are to be
81
79
installed. May be left as the default, in which case the value will be
82
80
computed from prefix and the current Python version:""",
83
81
    """
84
82
# 'site-packages' directory in Python, where Python libraries are to be
85
 
# installed. May be omitted (recommended), in which case the value will be
 
83
# installed. May be None (recommended), in which case the value will be
86
84
# computed from prefix and the current Python version.""", ask=False))
87
85
 
88
 
config_options.append(ConfigOption("paths/data",
 
86
config_options.append(ConfigOption("data_path",
89
87
    "/var/lib/ivle",
90
88
    "In the local file system, where user-modifiable data files should be "
91
89
    "located:",
93
91
# In the local file system, where user-modifiable data files should be
94
92
# located.""", ask=False))
95
93
 
96
 
config_options.append(ConfigOption("paths/logs",
 
94
config_options.append(ConfigOption("log_path",
97
95
    "/var/log/ivle",
98
96
    """Directory where IVLE log files are stored (on the local
99
97
file system). Note - this must be writable by the user the IVLE server 
102
100
# In the local file system, where IVLE error logs should be located.""",
103
101
    ask=False))
104
102
 
105
 
config_options.append(ConfigOption("urls/public_host", "public.localhost",
 
103
config_options.append(ConfigOption("public_host", "public.localhost",
106
104
    """Hostname which will cause the server to go into "public mode",
107
105
providing login-free access to student's published work:""",
108
106
    """
113
111
# Private mode (normal mode) requires login, and only serves files relevant to
114
112
# the logged-in user."""))
115
113
 
116
 
config_options.append(ConfigOption("media/version", None,
117
 
    """Version of IVLE media resources (must change on each upgrade):""",
 
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")""",
118
119
    """
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))
 
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))
122
125
 
123
 
config_options.append(ConfigOption("database/host", "localhost",
 
126
config_options.append(ConfigOption("db_host", "localhost",
124
127
    """PostgreSQL Database config
125
128
==========================
126
129
Hostname of the DB server:""",
127
130
    """
 
131
### PostgreSQL Database config ###
128
132
# Database server hostname"""))
129
133
 
130
 
config_options.append(ConfigOption("database/port", "5432",
 
134
config_options.append(ConfigOption("db_port", "5432",
131
135
    """Port of the DB server:""",
132
136
    """
133
137
# Database server port"""))
134
138
 
135
 
config_options.append(ConfigOption("database/name", "ivle",
 
139
config_options.append(ConfigOption("db_dbname", "ivle",
136
140
    """Database name:""",
137
141
    """
138
142
# Database name"""))
139
143
 
140
 
config_options.append(ConfigOption("database/username", "postgres",
 
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",
141
150
    """Username for DB server login:""",
142
151
    """
143
152
# Database username"""))
144
153
 
145
 
config_options.append(ConfigOption("database/password", "",
 
154
config_options.append(ConfigOption("db_password", "",
146
155
    """Password for DB server login:
147
 
    (Caution: This password is stored in plaintext!)""",
 
156
    (Caution: This password is stored in plaintext in ivle/conf/conf.py)""",
148
157
    """
149
158
# Database password"""))
150
159
 
151
 
config_options.append(ConfigOption("auth/modules", "",
 
160
config_options.append(ConfigOption("auth_modules", "",
152
161
    """Authentication config
153
162
=====================
154
163
Comma-separated list of authentication modules.""",
162
171
# other modules may be plugged in to auth against organisation-specific
163
172
# auth backends.""", ask=False))
164
173
 
165
 
config_options.append(ConfigOption("auth/ldap_url", "ldaps://www.example.com",
 
174
config_options.append(ConfigOption("ldap_url", "ldaps://www.example.com",
166
175
    """(LDAP options are only relevant if "ldap" is included in the list of
167
176
auth modules).
168
177
URL for LDAP authentication server:""",
169
178
    """
170
179
# URL for LDAP authentication server""", ask=False))
171
180
 
172
 
config_options.append(ConfigOption("auth/ldap_format_string",
 
181
config_options.append(ConfigOption("ldap_format_string",
173
182
    "uid=%s,ou=users,o=example",
174
183
    """Format string for LDAP auth request:
175
184
    (Must contain a single "%s" for the user's login name)""",
177
186
# Format string for LDAP auth request
178
187
# (Must contain a single "%s" for the user's login name)""", ask=False))
179
188
 
180
 
config_options.append(ConfigOption("auth/subject_pulldown_modules", "",
 
189
config_options.append(ConfigOption("subject_pulldown_modules", "",
181
190
    """Comma-separated list of subject pulldown modules.
182
191
Add proprietary modules to automatically enrol students in subjects.""",
183
192
    """
187
196
# other modules may be plugged in to pulldown against organisation-specific
188
197
# pulldown backends.""", ask=False))
189
198
 
190
 
config_options.append(ConfigOption("urls/svn_addr", "http://svn.localhost/",
 
199
config_options.append(ConfigOption("svn_addr", "http://svn.localhost/",
191
200
    """Subversion config
192
201
=================
193
202
The base url for accessing subversion repositories:""",
194
203
    """
195
204
# The base url for accessing subversion repositories."""))
196
205
 
197
 
config_options.append(ConfigOption("usrmgt/host", "localhost",
 
206
config_options.append(ConfigOption("usrmgt_host", "localhost",
198
207
    """User Management Server config
199
208
============================
200
209
The hostname where the usrmgt-server runs:""",
201
210
    """
202
211
# The hostname where the usrmgt-server runs."""))
203
212
 
204
 
config_options.append(ConfigOption("usrmgt/port", "2178",
 
213
config_options.append(ConfigOption("usrmgt_port", "2178",
205
214
    """The port where the usrmgt-server runs:""",
206
215
    """
207
216
# The port where the usrmgt-server runs.""", ask=False))
208
217
 
209
 
config_options.append(ConfigOption("usrmgt/magic", None,
 
218
config_options.append(ConfigOption("usrmgt_magic", None,
210
219
    """The password for the usrmgt-server:""",
211
220
    """
212
221
# The password for the usrmgt-server.""", ask=False))
213
222
 
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
 
 
244
223
def configure(args):
 
224
    # Call the real function
 
225
    return __configure(args)
 
226
 
 
227
def __configure(args):
 
228
    global db_port, usrmgt_port
 
229
 
245
230
    # Try importing existing conf, but if we can't just set up defaults
246
231
    # The reason for this is that these settings are used by other phases
247
232
    # of setup besides conf, so we need to know them.
248
233
    # Also this allows you to hit Return to accept the existing value.
249
234
    try:
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)
 
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
272
246
 
273
247
    # Set up some variables
274
248
    cwd = os.getcwd()
275
249
 
276
250
    # the files that will be created/overwritten
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')
 
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")
284
254
 
285
255
    # Get command-line arguments to avoid asking questions.
286
256
 
296
266
    if opts == []:
297
267
        # Interactive mode. Prompt the user for all the values.
298
268
 
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.
 
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.
305
275
 
306
276
Please hit Ctrl+C now if you do not wish to do this.
307
 
""" % (conffile, plugindefaultfile)
 
277
""" % (conffile, conf_hfile, phpBBconffile)
308
278
 
309
279
        # Get information from the administrator
310
280
        # If EOF is encountered at any time during the questioning, just exit
312
282
 
313
283
        for opt in config_options:
314
284
            if opt.ask:
315
 
                conf.set_by_path(opt.option_name,
316
 
                    query_user(conf.get_by_path(opt.option_name), opt.prompt))
 
285
                globals()[opt.option_name] = \
 
286
                    query_user(globals()[opt.option_name], opt.prompt)
317
287
    else:
318
288
        opts = dict(opts)
319
289
        # Non-interactive mode. Parse the options.
320
290
        for opt in config_options:
321
291
            if '--' + opt.option_name in opts:
322
 
                conf.set_by_path(opt.option_name,
323
 
                                 opts['--' + opt.option_name])
 
292
                globals()[opt.option_name] = opts['--' + opt.option_name]
324
293
 
325
294
    # Error handling on input values
326
295
    try:
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()
 
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()
344
313
    except ValueError:
345
314
        print >>sys.stderr, (
346
315
        "Invalid user management port (%s).\n"
347
 
        "Must be an integer between 0 and 65535." %
348
 
            repr(conf['usrmgt']['port']))
 
316
        "Must be an integer between 0 and 65535." % repr(usrmgt_port))
349
317
        return 1
350
318
 
351
319
    # 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
 
352
328
    try:
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!
 
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)
369
351
 
370
352
    print "Successfully wrote %s" % conffile
371
353
 
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
 
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
397
445
    
398
446
    return 0
399
447
 
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())
 
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
""")