35
conf = ivle.config.Config(plugins=False)
36
except ivle.config.ConfigError, e:
37
raise ImportError(str(e))
39
# This dict maps legacy config option names to new config option paths
40
# ('section/option_name')
42
'root_dir': 'urls/root',
43
'prefix': 'paths/prefix',
44
'data_path': 'paths/data',
45
'log_path': 'paths/logs',
46
'public_host': 'urls/public_host',
47
'db_host': 'database/host',
48
'db_port': 'database/port',
49
'db_dbname': 'database/name',
50
'db_user': 'database/username',
51
'db_password': 'database/password',
52
'auth_modules': 'auth/modules',
53
'ldap_url': 'auth/ldap_url',
54
'ldap_format_string': 'auth/ldap_format_string',
55
'subject_pulldown_modules': 'auth/subject_pulldown_modules',
56
'svn_addr': 'urls/svn_addr',
57
'usrmgt_host': 'usrmgt/host',
58
'usrmgt_port': 'usrmgt/port',
59
'usrmgt_magic': 'usrmgt/magic',
61
# These two are only relevant inside the jail.
62
'login': 'user_info/login',
63
'svn_pass': 'user_info/svn_pass',
66
for legacyopt, newopt_path in CONFIG_OPTIONS.iteritems():
67
# Iterate over each segment of the path, and find the value in conf file
70
for seg in newopt_path.split('/'):
72
globals()[legacyopt] = value
74
globals()[legacyopt] = None
76
# XXX Munge some nice shiny new-style values into horrible old-style values
77
# IRONY: These have just been split from commas. We need to re-join it so that
78
# pulldown_subj and auth_modules can re-split them.
79
subject_pulldown_modules = ','.join(subject_pulldown_modules)
80
auth_modules = ','.join(auth_modules)
32
def search_conffile():
34
Search for the config file, and return it as a filename.
35
1. Environment var IVLECONF (full filename).
37
3. /etc/ivle/ivle.conf
39
if 'IVLECONF' in os.environ:
40
fname = os.environ['IVLECONF']
41
if os.path.exists(fname):
43
if os.path.exists('./etc/ivle.conf'):
44
return './etc/ivle.conf'
45
if os.path.exists('/etc/ivle/ivle.conf'):
46
return '/etc/ivle/ivle.conf'
47
raise RuntimeError("Could not find IVLE config file")
49
conffile = search_conffile()
50
conf = configobj.ConfigObj(conffile)
52
CONFIG_OPTIONS = ('root_dir', 'prefix', 'data_path', 'log_path',
53
'public_host', 'allowed_uids', 'db_host', 'db_port', 'db_dbname',
54
'db_forumdbname', 'db_user', 'db_password', 'auth_modules', 'ldap_url',
55
'ldap_format_string', 'subject_pulldown_modules', 'svn_addr',
56
'usrmgt_host', 'usrmgt_port', 'usrmgt_magic', 'forum_secret'
59
for opt in CONFIG_OPTIONS:
60
globals()[opt] = conf[opt]
62
# XXX Convert db_port and usrmgt_port to int.
64
db_port = int(db_port)
65
usrmgt_port = int(usrmgt_port)
82
67
# Additional auto-generated config options
91
76
# Path where user-executable binaries are installed.
92
77
bin_path = os.path.join(prefix, 'bin')
79
# 'site-packages' directory in Python, where Python libraries are to be
81
PYTHON_VERSION = sys.version[0:3] # eg. "2.5"
82
python_site_packages = os.path.join(prefix,
83
'lib/python%s/site-packages' % PYTHON_VERSION)
94
85
# In the local file system, where the student/user jails will be mounted.
95
86
# Only a single copy of the jail's system components will be stored here -
96
87
# all user jails will be virtually mounted here.
97
# XXX: Some jail code calls ivle.studpath.url_to_{local,jailpaths}, both
98
# of which use jail_base. Note that they don't use the bits of the
99
# return value that depend on jail_base, so it can be any string inside
100
# the jail. The value computed here may be meaningless inside the jail,
101
# but that's OK for now.
102
88
jail_base = os.path.join(data_path, 'jailmounts')
104
90
# In the local file system, where are the student/user file spaces located.
117
103
# (The 'subjects' and 'exercises' directories).
118
104
content_path = os.path.join(data_path, 'content')
106
# In the local file system, where are the per-subject file spaces located.
107
# The individual subject directories are expected to be located immediately
108
# in subdirectories of this location.
109
subjects_base = os.path.join(content_path, 'subjects')
111
# In the local file system, where are the subject-independent exercise sheet
112
# file spaces located.
113
exercises_base = os.path.join(content_path, 'exercises')
120
115
# In the local file system, where the system notices are stored (such as terms
121
116
# of service and MOTD).
122
117
notices_path = os.path.join(data_path, 'notices')