1
# IVLE - Informatics Virtual Learning Environment
2
# Copyright (C) 2007-2009 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# Author: Matt Giuca, Will Grant
21
Temporary emulation layer for the old-style conf.py configuration file.
22
Loads the IVLE config file and provides all of the legacy config variables.
24
May raise a RuntimeError on import if it cannot find the config file.
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")
50
conffile = search_conffile()
51
except RuntimeError, e:
52
raise ImportError(str(e))
54
conf = configobj.ConfigObj(conffile)
56
# This dict maps legacy config option names to new config option paths
57
# ('section/option_name')
59
'root_dir': 'urls/root',
60
'prefix': 'paths/prefix',
61
'data_path': 'paths/data',
62
'log_path': 'paths/logs',
63
'python_site_packages_override': 'paths/site_packages',
64
'public_host': 'urls/public_host',
65
'allowed_uids': 'os/allowed_uids',
66
'db_host': 'database/host',
67
'db_port': 'database/port',
68
'db_dbname': 'database/name',
69
'db_forumdbname': 'plugins/forum/dbname',
70
'db_user': 'database/username',
71
'db_password': 'database/password',
72
'auth_modules': 'auth/modules',
73
'ldap_url': 'auth/ldap_url',
74
'ldap_format_string': 'auth/ldap_format_string',
75
'subject_pulldown_modules': 'auth/subject_pulldown_modules',
76
'svn_addr': 'urls/svn_addr',
77
'usrmgt_host': 'usrmgt/host',
78
'usrmgt_port': 'usrmgt/port',
79
'usrmgt_magic': 'usrmgt/magic',
80
'forum_secret': 'plugins/forum/secret',
83
for legacyopt, newopt_path in CONFIG_OPTIONS.iteritems():
84
# Iterate over each segment of the path, and find the value in conf file
87
for seg in newopt_path.split('/'):
89
globals()[legacyopt] = value
91
globals()[legacyopt] = None
93
# XXX Munge some nice shiny new-style values into horrible old-style values
94
# IRONY: These have just been split from commas. We need to re-join it so that
95
# pulldown_subj and auth_modules can re-split them.
96
subject_pulldown_modules = ','.join(subject_pulldown_modules)
97
auth_modules = ','.join(auth_modules)
99
# XXX Convert db_port and usrmgt_port to int.
101
db_port = int(db_port)
102
usrmgt_port = int(usrmgt_port)
104
# Additional auto-generated config options
106
# Path where architecture-dependent data (including non-user-executable
107
# binaries) is installed.
108
lib_path = os.path.join(prefix, 'lib/ivle')
110
# Path where arch-independent data is installed.
111
share_path = os.path.join(prefix, 'share/ivle')
113
# Path where user-executable binaries are installed.
114
bin_path = os.path.join(prefix, 'bin')
116
# 'site-packages' directory in Python, where Python libraries are to be
118
if python_site_packages_override is None:
119
PYTHON_VERSION = sys.version[0:3] # eg. "2.5"
120
python_site_packages = os.path.join(prefix,
121
'lib/python%s/site-packages' % PYTHON_VERSION)
123
python_site_packages = python_site_packages_override
125
# In the local file system, where the student/user jails will be mounted.
126
# Only a single copy of the jail's system components will be stored here -
127
# all user jails will be virtually mounted here.
128
jail_base = os.path.join(data_path, 'jailmounts')
130
# In the local file system, where are the student/user file spaces located.
131
# The user jails are expected to be located immediately in subdirectories of
132
# this location. Note that no complete jails reside here - only user
134
jail_src_base = os.path.join(data_path, 'jails')
136
# In the local file system, where the template system jail will be stored.
137
jail_system = os.path.join(jail_src_base, '__base__')
139
# In the local file system, where the template system jail will be stored.
140
jail_system_build = os.path.join(jail_src_base, '__base_build__')
142
# In the local file system, where the subject content files are located.
143
# (The 'subjects' and 'exercises' directories).
144
content_path = os.path.join(data_path, 'content')
146
# In the local file system, where are the per-subject file spaces located.
147
# The individual subject directories are expected to be located immediately
148
# in subdirectories of this location.
149
subjects_base = os.path.join(content_path, 'subjects')
151
# In the local file system, where are the subject-independent exercise sheet
152
# file spaces located.
153
exercises_base = os.path.join(content_path, 'exercises')
155
# In the local file system, where the system notices are stored (such as terms
156
# of service and MOTD).
157
notices_path = os.path.join(data_path, 'notices')
159
# In the local file system, where is the Terms of Service document located.
160
tos_path = os.path.join(notices_path, 'tos.html')
162
# In the local file system, where is the Message of the Day document
163
# located. This is an HTML file (just the body fragment), which will
164
# be displayed on the login page. It is optional.
165
motd_path = os.path.join(notices_path, 'motd.html')
167
# The location of all the subversion config and repositories.
168
svn_path = os.path.join(data_path, 'svn')
170
# The location of the subversion configuration file used by
171
# apache to host the user repositories.
172
svn_conf = os.path.join(svn_path, 'svn.conf')
174
# The location of the subversion configuration file used by
175
# apache to host the user repositories.
176
svn_group_conf = os.path.join(svn_path, 'svn-group.conf')
178
# The root directory for the subversion repositories.
179
svn_repo_path = os.path.join(svn_path, 'repositories')
181
# The location of the password file used to authenticate users
182
# of the subversion repository from the ivle server.
183
svn_auth_ivle = os.path.join(svn_path, 'ivle.auth')