124
119
# Symlinks to make within the jail. Src mapped to dst.
126
'python%s' % PYTHON_VERSION: 'jail/usr/bin/python',
121
'python2.5': 'jail/usr/bin/python',
128
123
# Trees to copy. Src mapped to dst (these will be passed to action_copytree).
129
124
JAIL_COPYTREES = {
130
'/usr/lib/python%s' % PYTHON_VERSION:
131
'jail/usr/lib/python%s' % PYTHON_VERSION,
125
'/usr/lib/python2.5': 'jail/usr/lib/python2.5',
132
126
'/usr/share/matplotlib': 'jail/usr/share/matplotlib',
133
127
'/etc/ld.so.conf.d': 'jail/etc/ld.so.conf.d',
137
"""A configuration option; one of the things written to conf.py."""
138
def __init__(self, option_name, default, prompt, comment):
139
"""Creates a configuration option.
140
option_name: Name of the variable in conf.py. Also name of the
141
command-line argument to setup.py conf.
142
default: Default value for this variable.
143
prompt: (Short) string presented during the interactive prompt in
145
comment: (Long) comment string stored in conf.py. Each line of this
146
string should begin with a '#'.
148
self.option_name = option_name
149
self.default = default
151
self.comment = comment
153
# Configuration options, defaults and descriptions
155
config_options.append(ConfigOption("root_dir", "/ivle",
156
"""Root directory where IVLE is located (in URL space):""",
158
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
160
# eg. "/" or "/ivle"."""))
161
config_options.append(ConfigOption("ivle_install_dir", "/opt/ivle",
162
'Root directory where IVLE will be installed (on the local file '
165
# In the local file system, where IVLE is actually installed.
166
# This directory should contain the "www" and "bin" directories."""))
167
config_options.append(ConfigOption("jail_base", "/home/informatics/jails",
168
"""Root directory where the jails (containing user files) are stored
169
(on the local file system):""",
171
# In the local file system, where are the student/user file spaces located.
172
# The user jails are expected to be located immediately in subdirectories of
173
# this location."""))
174
config_options.append(ConfigOption("subjects_base",
175
"/home/informatics/subjects",
176
"""Root directory where the subject directories (containing worksheets
177
and other per-subject files) are stored (on the local file system):""",
179
# In the local file system, where are the per-subject file spaces located.
180
# The individual subject directories are expected to be located immediately
181
# in subdirectories of this location."""))
182
config_options.append(ConfigOption("public_host", "public.localhost",
183
"""Hostname which will cause the server to go into "public mode",
184
providing login-free access to student's published work:""",
186
# The server goes into "public mode" if the browser sends a request with this
187
# host. This is for security reasons - we only serve public student files on a
188
# separate domain to the main IVLE site.
189
# Public mode does not use cookies, and serves only public content.
190
# Private mode (normal mode) requires login, and only serves files relevant to
191
# the logged-in user."""))
192
config_options.append(ConfigOption("allowed_uids", "33",
193
"""UID of the web server process which will run IVLE.
194
Only this user may execute the trampoline. May specify multiple users as
195
a comma-separated list.
198
# The User-ID of the web server process which will run IVLE, and any other
199
# users who are allowed to run the trampoline. This is stores as a string of
200
# comma-separated integers, simply because it is not used within Python, only
201
# used by the setup program to write to conf.h (see setup.py config)."""))
202
config_options.append(ConfigOption("db_host", "localhost",
203
"""PostgreSQL Database config
204
==========================
205
Hostname of the DB server:""",
207
### PostgreSQL Database config ###
208
# Database server hostname"""))
209
config_options.append(ConfigOption("db_port", "5432",
210
"""Port of the DB server:""",
212
# Database server port"""))
213
config_options.append(ConfigOption("db_dbname", "ivle",
214
"""Database name:""",
217
config_options.append(ConfigOption("db_user", "postgres",
218
"""Username for DB server login:""",
220
# Database username"""))
221
config_options.append(ConfigOption("db_password", "",
222
"""Password for DB server login:
223
(Caution: This password is stored in plaintext in www/conf/conf.py)""",
225
# Database password"""))
227
130
# Try importing existing conf, but if we can't just set up defaults
228
131
# The reason for this is that these settings are used by other phases
229
132
# of setup besides conf, so we need to know them.
230
133
# Also this allows you to hit Return to accept the existing value.
232
135
confmodule = __import__("www/conf/conf")
233
for opt in config_options:
235
globals()[opt.option_name] = confmodule.__dict__[opt.option_name]
237
globals()[opt.option_name] = opt.default
137
root_dir = confmodule.root_dir
141
ivle_install_dir = confmodule.ivle_install_dir
143
ivle_install_dir = "/opt/ivle"
145
public_host = confmodule.public_host
147
public_host = "public.localhost"
149
jail_base = confmodule.jail_base
151
jail_base = "/home/informatics/jails"
153
subjects_base = confmodule.subjects_base
155
subjects_base = "/home/informatics/subjects"
238
156
except ImportError:
239
157
# Just set reasonable defaults
240
for opt in config_options:
241
globals()[opt.option_name] = opt.default
159
ivle_install_dir = "/opt/ivle"
160
public_host = "public.localhost"
161
jail_base = "/home/informatics/jails"
162
subjects_base = "/home/informatics/subjects"
243
166
# Try importing install_list, but don't fail if we can't, because listmake can
244
167
# function without it.
510
422
# If EOF is encountered at any time during the questioning, just exit
513
for opt in config_options:
514
globals()[opt.option_name] = \
515
query_user(globals()[opt.option_name], opt.prompt)
425
root_dir = query_user(root_dir,
426
"""Root directory where IVLE is located (in URL space):""")
427
ivle_install_dir = query_user(ivle_install_dir,
428
'Root directory where IVLE will be installed (on the local file '
430
jail_base = query_user(jail_base,
431
"""Root directory where the jails (containing user files) are stored
432
(on the local file system):""")
433
subjects_base = query_user(subjects_base,
434
"""Root directory where the subject directories (containing worksheets
435
and other per-subject files) are stored (on the local file system):""")
436
public_host = query_user(public_host,
437
"""Hostname which will cause the server to go into "public mode",
438
providing login-free access to student's published work:""")
439
allowed_uids = query_user(allowed_uids,
440
"""UID of the web server process which will run IVLE.
441
Only this user may execute the trampoline. May specify multiple users as
442
a comma-separated list.
517
446
opts = dict(opts)
518
447
# Non-interactive mode. Parse the options.
519
for opt in config_options:
520
if '--' + opt.option_name in opts:
521
globals()[opt.option_name] = opts['--' + opt.option_name]
448
if '--root_dir' in opts:
449
root_dir = opts['--root_dir']
450
if '--ivle_install_dir' in opts:
451
ivle_install_dir = opts['--ivle_install_dir']
452
if '--jail_base' in opts:
453
jail_base = opts['--jail_base']
454
if '--subjects_base' in opts:
455
jail_base = opts['--subjects_base']
456
if '--public_host' in opts:
457
public_host = opts['--public_host']
458
if '--allowed_uids' in opts:
459
allowed_uids = opts['--allowed_uids']
523
461
# Error handling on input values
525
allowed_uids_list = map(int, allowed_uids.split(','))
463
allowed_uids = map(int, allowed_uids.split(','))
526
464
except ValueError:
527
465
print >>sys.stderr, (
528
466
"Invalid UID list (%s).\n"
529
467
"Must be a comma-separated list of integers." % allowed_uids)
532
db_port = int(db_port)
533
if db_port < 0 or db_port >= 65536: raise ValueError()
535
print >>sys.stderr, (
536
"Invalid DB port (%s).\n"
537
"Must be an integer between 0 and 65535." % repr(db_port))
540
470
# Write www/conf/conf.py
547
477
# Miscellaneous application settings
550
for opt in config_options:
551
conf.write('%s\n%s = %s\n' % (opt.comment, opt.option_name,
552
repr(globals()[opt.option_name])))
480
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
482
# eg. "/" or "/ivle".
485
# In the local file system, where IVLE is actually installed.
486
# This directory should contain the "www" and "bin" directories.
487
ivle_install_dir = "%s"
489
# The server goes into "public mode" if the browser sends a request with this
490
# host. This is for security reasons - we only serve public student files on a
491
# separate domain to the main IVLE site.
492
# Public mode does not use cookies, and serves only public content.
493
# Private mode (normal mode) requires login, and only serves files relevant to
494
# the logged-in user.
497
# In the local file system, where are the student/user file spaces located.
498
# The user jails are expected to be located immediately in subdirectories of
502
# In the local file system, where are the per-subject file spaces located.
503
# The individual subject directories are expected to be located immediately
504
# in subdirectories of this location.
506
""" % (root_dir, ivle_install_dir, public_host, jail_base, subjects_base))
555
509
except IOError, (errno, strerror):