40
# This dict maps legacy config option names to new config option paths
41
# ('section/option_name')
42
# NOTE: This is copied from ivle/conf/conf.py (because neither of these files
43
# can see each other).
40
# This dict maps new config option paths ('section/option_name') to legacy
41
# config option names ('option_name').
42
# NOTE: This is the inverse of the dictionary from ivle/conf/conf.py.
45
'root_dir': 'urls/root',
46
'prefix': 'paths/prefix',
47
'data_path': 'paths/data',
48
'log_path': 'paths/logs',
49
'python_site_packages_override': 'paths/site_packages',
50
'public_host': 'urls/public_host',
51
'allowed_uids': 'os/allowed_uids',
52
'db_host': 'database/host',
53
'db_port': 'database/port',
54
'db_dbname': 'database/name',
55
'db_forumdbname': 'plugins/forum/dbname',
56
'db_user': 'database/username',
57
'db_password': 'database/password',
58
'auth_modules': 'auth/modules',
59
'ldap_url': 'auth/ldap_url',
60
'ldap_format_string': 'auth/ldap_format_string',
61
'subject_pulldown_modules': 'auth/subject_pulldown_modules',
62
'svn_addr': 'urls/svn_addr',
63
'usrmgt_host': 'usrmgt/host',
64
'usrmgt_port': 'usrmgt/port',
65
'usrmgt_magic': 'usrmgt/magic',
66
'forum_secret': 'plugins/forum/secret',
44
'urls/root': 'root_dir',
45
'paths/prefix': 'prefix',
46
'paths/data': 'data_path',
47
'paths/logs': 'log_path',
48
'paths/site_packages': 'python_site_packages_override',
49
'urls/public_host': 'public_host',
50
'os/allowed_uids': 'allowed_uids',
51
'database/host': 'db_host',
52
'database/port': 'db_port',
53
'database/name': 'db_dbname',
54
'plugins/forum/dbname': 'db_forumdbname',
55
'database/username': 'db_user',
56
'database/password': 'db_password',
57
'auth/modules': 'auth_modules',
58
'auth/ldap_url': 'ldap_url',
59
'auth/ldap_format_string': 'ldap_format_string',
60
'auth/subject_pulldown_modules': 'subject_pulldown_modules',
61
'urls/svn_addr': 'svn_addr',
62
'usrmgt/host': 'usrmgt_host',
63
'usrmgt/port': 'usrmgt_port',
64
'usrmgt/magic': 'usrmgt_magic',
65
'plugins/forum/secret': 'forum_secret',
69
68
# conf_options maps option names to values
91
90
# Configuration options, defaults and descriptions
92
91
config_options = []
94
config_options.append(ConfigOption("root_dir", "/",
93
config_options.append(ConfigOption("urls/root", "/",
95
94
"""Root directory where IVLE is located (in URL space):""",
97
96
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
99
98
# eg. "/" or "/ivle".""", ask=False))
101
config_options.append(ConfigOption("prefix", "/usr/local",
100
config_options.append(ConfigOption("paths/prefix", "/usr/local",
102
101
"""In the local file system, the prefix to the system directory where IVLE
103
102
is installed. (This should either be /usr or /usr/local):""",
157
156
# used by the setup program to write to conf.h (see setup.py config).""",
160
config_options.append(ConfigOption("db_host", "localhost",
159
config_options.append(ConfigOption("database/host", "localhost",
161
160
"""PostgreSQL Database config
162
161
==========================
163
162
Hostname of the DB server:""",
165
164
# Database server hostname"""))
167
config_options.append(ConfigOption("db_port", "5432",
166
config_options.append(ConfigOption("database/port", "5432",
168
167
"""Port of the DB server:""",
170
169
# Database server port"""))
172
config_options.append(ConfigOption("db_dbname", "ivle",
171
config_options.append(ConfigOption("database/name", "ivle",
173
172
"""Database name:""",
175
174
# Database name"""))
177
config_options.append(ConfigOption("db_forumdbname", "ivle_forum",
176
config_options.append(ConfigOption("plugins/forum/dbname", "ivle_forum",
178
177
"""Forum Database name:""",
180
179
# Forum Database name"""))
182
config_options.append(ConfigOption("db_user", "postgres",
181
config_options.append(ConfigOption("database/username", "postgres",
183
182
"""Username for DB server login:""",
185
184
# Database username"""))
187
config_options.append(ConfigOption("db_password", "",
186
config_options.append(ConfigOption("database/password", "",
188
187
"""Password for DB server login:
189
188
(Caution: This password is stored in plaintext in ivle/conf/conf.py)""",
191
190
# Database password"""))
193
config_options.append(ConfigOption("auth_modules", "",
192
config_options.append(ConfigOption("auth/modules", "",
194
193
"""Authentication config
195
194
=====================
196
195
Comma-separated list of authentication modules.""",
204
203
# other modules may be plugged in to auth against organisation-specific
205
204
# auth backends.""", ask=False))
207
config_options.append(ConfigOption("ldap_url", "ldaps://www.example.com",
206
config_options.append(ConfigOption("auth/ldap_url", "ldaps://www.example.com",
208
207
"""(LDAP options are only relevant if "ldap" is included in the list of
210
209
URL for LDAP authentication server:""",
212
211
# URL for LDAP authentication server""", ask=False))
214
config_options.append(ConfigOption("ldap_format_string",
213
config_options.append(ConfigOption("auth/ldap_format_string",
215
214
"uid=%s,ou=users,o=example",
216
215
"""Format string for LDAP auth request:
217
216
(Must contain a single "%s" for the user's login name)""",
229
228
# other modules may be plugged in to pulldown against organisation-specific
230
229
# pulldown backends.""", ask=False))
232
config_options.append(ConfigOption("svn_addr", "http://svn.localhost/",
231
config_options.append(ConfigOption("urls/svn_addr", "http://svn.localhost/",
233
232
"""Subversion config
234
233
=================
235
234
The base url for accessing subversion repositories:""",
237
236
# The base url for accessing subversion repositories."""))
239
config_options.append(ConfigOption("usrmgt_host", "localhost",
238
config_options.append(ConfigOption("usrmgt/host", "localhost",
240
239
"""User Management Server config
241
240
============================
242
241
The hostname where the usrmgt-server runs:""",
244
243
# The hostname where the usrmgt-server runs."""))
246
config_options.append(ConfigOption("usrmgt_port", "2178",
245
config_options.append(ConfigOption("usrmgt/port", "2178",
247
246
"""The port where the usrmgt-server runs:""",
249
248
# The port where the usrmgt-server runs.""", ask=False))
251
config_options.append(ConfigOption("usrmgt_magic", None,
250
config_options.append(ConfigOption("usrmgt/magic", None,
252
251
"""The password for the usrmgt-server:""",
254
253
# The password for the usrmgt-server.""", ask=False))
325
324
# Error handling on input values
327
allowed_uids_list = map(int, conf_options['allowed_uids'].split(','))
326
allowed_uids_list = map(int,
327
conf_options['os/allowed_uids'].split(','))
328
328
except ValueError:
329
329
print >>sys.stderr, (
330
330
"Invalid UID list (%s).\n"
331
331
"Must be a comma-separated list of integers." %
332
conf_options['allowed_uids'])
332
conf_options['os/allowed_uids'])
335
conf_options['db_port'] = int(conf_options['db_port'])
336
if conf_options['db_port'] < 0 or conf_options['db_port'] >= 65536:
335
conf_options['database/port'] = int(conf_options['database/port'])
336
if (conf_options['database/port'] < 0
337
or conf_options['database/port'] >= 65536):
337
338
raise ValueError()
338
339
except ValueError:
339
340
print >>sys.stderr, (
340
341
"Invalid DB port (%s).\n"
341
342
"Must be an integer between 0 and 65535." %
342
repr(conf_options['db_port']))
343
repr(conf_options['database/port']))
345
conf_options['usrmgt_port'] = int(conf_options['usrmgt_port'])
346
if (conf_options['usrmgt_port'] < 0
347
or conf_options['usrmgt_port'] >= 65536):
346
conf_options['usrmgt/port'] = int(conf_options['usrmgt/port'])
347
if (conf_options['usrmgt/port'] < 0
348
or conf_options['usrmgt/port'] >= 65536):
348
349
raise ValueError()
349
350
except ValueError:
350
351
print >>sys.stderr, (
351
352
"Invalid user management port (%s).\n"
352
353
"Must be an integer between 0 and 65535." %
353
repr(conf_options['usrmgt_port']))
354
repr(conf_options['usrmgt/port']))
356
357
# By default we generate the magic randomly.
357
if conf_options['usrmgt_magic'] is None:
358
conf_options['usrmgt_magic'] = \
358
if conf_options['usrmgt/magic'] is None:
359
conf_options['usrmgt/magic'] = \
359
360
hashlib.md5(uuid.uuid4().bytes).hexdigest()
361
362
# Generate the forum secret
369
370
conf.initial_comment = ["# IVLE Configuration File"]
371
372
# Add the forum secret to the config file (regenerated each config)
372
config_options.append(ConfigOption('forum_secret', None, '', ''))
373
conf_options['forum_secret'] = forum_secret
373
config_options.append(ConfigOption('plugins/forum/secret', None, '', ''))
374
conf_options['plugins/forum/secret'] = forum_secret
375
for legacyopt in config_options:
376
newopt_path = CONFIG_OPTIONS[legacyopt.option_name].split('/')
376
for opt in config_options:
377
newopt_path = opt.option_name.split('/')
377
378
# Iterate over each segment of the path, and find the section in conf
378
379
# file to insert the value into (use all but the last path segment)
379
380
conf_section = conf
400
401
# XXX Compute jail_base, jail_src_base and jail_system. These will
401
402
# ALSO be done by the boilerplate code, but we need them here in order
402
403
# to write to the C file.
403
jail_base = os.path.join(conf_options['data_path'], 'jailmounts')
404
jail_src_base = os.path.join(conf_options['data_path'], 'jails')
404
jail_base = os.path.join(conf_options['paths/data'], 'jailmounts')
405
jail_src_base = os.path.join(conf_options['paths/data'], 'jails')
405
406
jail_system = os.path.join(jail_src_base, '__base__')
407
408
conf.write("""/* IVLE Configuration File
441
442
conf = open(phpBBconffile, "w")
443
444
# php-pg work around
444
if conf_options['db_host'] == 'localhost':
445
if conf_options['database/host'] == 'localhost':
445
446
forumdb_host = '127.0.0.1'
447
forumdb_host = conf_options['db_host']
448
forumdb_host = conf_options['database/host']
449
450
conf.write( """<?php
450
451
// phpBB 3.0.x auto-generated configuration file
451
452
// Do not change anything in this file!
452
453
$dbms = 'postgres';
453
454
$dbhost = '""" + forumdb_host + """';
454
$dbport = '""" + str(conf_options['db_port']) + """';
455
$dbname = '""" + conf_options['db_forumdbname'] + """';
456
$dbuser = '""" + conf_options['db_user'] + """';
457
$dbpasswd = '""" + conf_options['db_password'] + """';
455
$dbport = '""" + str(conf_options['database/port']) + """';
456
$dbname = '""" + conf_options['plugins/forum/dbname'] + """';
457
$dbuser = '""" + conf_options['database/username'] + """';
458
$dbpasswd = '""" + conf_options['database/password'] + """';
459
460
$table_prefix = 'phpbb_';
460
461
$acm_type = 'file';