803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
1 |
# IVLE - Informatics Virtual Learning Environment
|
2 |
# Copyright (C) 2007-2008 The University of Melbourne
|
|
3 |
#
|
|
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.
|
|
8 |
#
|
|
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.
|
|
13 |
#
|
|
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
|
|
17 |
||
18 |
# Module: setup/config
|
|
19 |
# Author: Matt Giuca, Refactored by David Coles
|
|
20 |
# Date: 03/07/2008
|
|
21 |
||
22 |
# setup/config.py
|
|
23 |
# Configures IVLE with machine-specific details, most notably, various paths.
|
|
24 |
# Either prompts the administrator for these details or accepts them as
|
|
25 |
# command-line args.
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
26 |
# Creates lib/conf/conf.py and bin/trampoline/conf.h.
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
27 |
|
28 |
import optparse |
|
29 |
import getopt |
|
30 |
import os |
|
819
by mattgiuca
setup/configure.py: Added "import sys". |
31 |
import sys |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
32 |
import hashlib |
33 |
import uuid |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
34 |
|
35 |
from setup.util import query_user |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
36 |
|
37 |
class ConfigOption: |
|
38 |
"""A configuration option; one of the things written to conf.py."""
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
39 |
def __init__(self, option_name, default, prompt, comment, ask=True): |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
40 |
"""Creates a configuration option.
|
41 |
option_name: Name of the variable in conf.py. Also name of the
|
|
42 |
command-line argument to setup.py conf.
|
|
43 |
default: Default value for this variable.
|
|
44 |
prompt: (Short) string presented during the interactive prompt in
|
|
45 |
setup.py conf.
|
|
46 |
comment: (Long) comment string stored in conf.py. Each line of this
|
|
47 |
string should begin with a '#'.
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
48 |
ask: Whether to ask the question in the default config run.
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
49 |
"""
|
50 |
self.option_name = option_name |
|
51 |
self.default = default |
|
52 |
self.prompt = prompt |
|
53 |
self.comment = comment |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
54 |
self.ask = ask |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
55 |
|
56 |
# Configuration options, defaults and descriptions
|
|
57 |
config_options = [] |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
58 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
59 |
config_options.append(ConfigOption("root_dir", "/", |
60 |
"""Root directory where IVLE is located (in URL space):""", |
|
61 |
"""
|
|
62 |
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
|
|
63 |
# with this).
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
64 |
# eg. "/" or "/ivle".""", ask=False)) |
65 |
||
66 |
config_options.append(ConfigOption("prefix", "/usr/local", |
|
67 |
"""In the local file system, the prefix to the system directory where IVLE
|
|
68 |
is installed. (This should either be /usr or /usr/local):""", |
|
69 |
"""
|
|
70 |
# In the local file system, the prefix to the system directory where IVLE is
|
|
71 |
# installed. This should either be '/usr' or '/usr/local'.
|
|
72 |
# ('/usr/local' for the usual install, '/usr' for distribution packages)""", |
|
73 |
ask=False)) |
|
74 |
||
75 |
config_options.append(ConfigOption("python_site_packages_override", |
|
76 |
None, |
|
77 |
"""site-packages directory in Python, where Python libraries are to be
|
|
78 |
installed. May be left as the default, in which case the value will be
|
|
79 |
computed from prefix and the current Python version:""", |
|
80 |
"""
|
|
81 |
# 'site-packages' directory in Python, where Python libraries are to be
|
|
82 |
# installed. May be None (recommended), in which case the value will be
|
|
83 |
# computed from prefix and the current Python version.""", ask=False)) |
|
84 |
||
85 |
config_options.append(ConfigOption("data_path", |
|
86 |
"/var/lib/ivle", |
|
87 |
"In the local file system, where user-modifiable data files should be "
|
|
88 |
"located:", |
|
89 |
"""
|
|
90 |
# In the local file system, where user-modifiable data files should be
|
|
91 |
# located.""", ask=False)) |
|
92 |
||
893
by dcoles
Dispatch: Now attempts to log unhandled exceptions to a log directory specified |
93 |
config_options.append(ConfigOption("log_path", |
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
94 |
"/var/log/ivle", |
893
by dcoles
Dispatch: Now attempts to log unhandled exceptions to a log directory specified |
95 |
"""Directory where IVLE log files are stored (on the local
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
96 |
file system). Note - this must be writable by the user the IVLE server
|
97 |
process runs as (usually www-data):""", |
|
893
by dcoles
Dispatch: Now attempts to log unhandled exceptions to a log directory specified |
98 |
"""
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
99 |
# In the local file system, where IVLE error logs should be located.""", |
100 |
ask=False)) |
|
101 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
102 |
config_options.append(ConfigOption("public_host", "public.localhost", |
103 |
"""Hostname which will cause the server to go into "public mode",
|
|
104 |
providing login-free access to student's published work:""", |
|
105 |
"""
|
|
106 |
# The server goes into "public mode" if the browser sends a request with this
|
|
107 |
# host. This is for security reasons - we only serve public student files on a
|
|
108 |
# separate domain to the main IVLE site.
|
|
109 |
# Public mode does not use cookies, and serves only public content.
|
|
110 |
# Private mode (normal mode) requires login, and only serves files relevant to
|
|
111 |
# the logged-in user.""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
112 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
113 |
config_options.append(ConfigOption("allowed_uids", "33", |
114 |
"""UID of the web server process which will run IVLE.
|
|
115 |
Only this user may execute the trampoline. May specify multiple users as
|
|
116 |
a comma-separated list.
|
|
117 |
(eg. "1002,78")""", |
|
118 |
"""
|
|
119 |
# The User-ID of the web server process which will run IVLE, and any other
|
|
120 |
# users who are allowed to run the trampoline. This is stores as a string of
|
|
121 |
# comma-separated integers, simply because it is not used within Python, only
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
122 |
# used by the setup program to write to conf.h (see setup.py config).""", |
123 |
ask=False)) |
|
124 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
125 |
config_options.append(ConfigOption("db_host", "localhost", |
126 |
"""PostgreSQL Database config
|
|
127 |
==========================
|
|
128 |
Hostname of the DB server:""", |
|
129 |
"""
|
|
130 |
### PostgreSQL Database config ###
|
|
131 |
# Database server hostname""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
132 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
133 |
config_options.append(ConfigOption("db_port", "5432", |
134 |
"""Port of the DB server:""", |
|
135 |
"""
|
|
136 |
# Database server port""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
137 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
138 |
config_options.append(ConfigOption("db_dbname", "ivle", |
139 |
"""Database name:""", |
|
140 |
"""
|
|
141 |
# Database name""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
142 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
143 |
config_options.append(ConfigOption("db_forumdbname", "ivle_forum", |
144 |
"""Forum Database name:""", |
|
145 |
"""
|
|
146 |
# Forum Database name""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
147 |
|
1075
by matt.giuca
Reverted revisions 1059 and 1069 - renaming the DB user from 'postgres' to |
148 |
config_options.append(ConfigOption("db_user", "postgres", |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
149 |
"""Username for DB server login:""", |
150 |
"""
|
|
151 |
# Database username""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
152 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
153 |
config_options.append(ConfigOption("db_password", "", |
154 |
"""Password for DB server login:
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
155 |
(Caution: This password is stored in plaintext in ivle/conf/conf.py)""", |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
156 |
"""
|
157 |
# Database password""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
158 |
|
159 |
config_options.append(ConfigOption("auth_modules", "", |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
160 |
"""Authentication config
|
161 |
=====================
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
162 |
Comma-separated list of authentication modules.""", |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
163 |
"""
|
164 |
# Comma-separated list of authentication modules.
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
165 |
# Note that auth is always enabled against the local database, and NO OTHER
|
166 |
# auth is enabled by default. This section is for specifying additional auth
|
|
167 |
# modules.
|
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
168 |
# These refer to importable Python modules in the www/auth directory.
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
169 |
# Modules "ldap_auth" and "guest" are available in the source tree, but
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
170 |
# other modules may be plugged in to auth against organisation-specific
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
171 |
# auth backends.""", ask=False)) |
172 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
173 |
config_options.append(ConfigOption("ldap_url", "ldaps://www.example.com", |
174 |
"""(LDAP options are only relevant if "ldap" is included in the list of
|
|
175 |
auth modules).
|
|
176 |
URL for LDAP authentication server:""", |
|
177 |
"""
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
178 |
# URL for LDAP authentication server""", ask=False)) |
179 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
180 |
config_options.append(ConfigOption("ldap_format_string", |
181 |
"uid=%s,ou=users,o=example", |
|
182 |
"""Format string for LDAP auth request:
|
|
183 |
(Must contain a single "%s" for the user's login name)""", |
|
184 |
"""
|
|
185 |
# Format string for LDAP auth request
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
186 |
# (Must contain a single "%s" for the user's login name)""", ask=False)) |
187 |
||
819
by mattgiuca
setup/configure.py: Added "import sys". |
188 |
config_options.append(ConfigOption("subject_pulldown_modules", "", |
189 |
"""Comma-separated list of subject pulldown modules.
|
|
190 |
Add proprietary modules to automatically enrol students in subjects.""", |
|
191 |
"""
|
|
192 |
# Comma-separated list of subject pulldown modules.
|
|
193 |
# These refer to importable Python modules in the lib/pulldown_subj directory.
|
|
820
by mattgiuca
lib: Added new package pulldown_subj, a collection of modules designed to |
194 |
# Only "dummy_subj" is available in the source tree (an example), but
|
819
by mattgiuca
setup/configure.py: Added "import sys". |
195 |
# other modules may be plugged in to pulldown against organisation-specific
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
196 |
# pulldown backends.""", ask=False)) |
197 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
198 |
config_options.append(ConfigOption("svn_addr", "http://svn.localhost/", |
199 |
"""Subversion config
|
|
200 |
=================
|
|
201 |
The base url for accessing subversion repositories:""", |
|
202 |
"""
|
|
203 |
# The base url for accessing subversion repositories.""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
204 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
205 |
config_options.append(ConfigOption("usrmgt_host", "localhost", |
206 |
"""User Management Server config
|
|
207 |
============================
|
|
208 |
The hostname where the usrmgt-server runs:""", |
|
209 |
"""
|
|
210 |
# The hostname where the usrmgt-server runs.""")) |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
211 |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
212 |
config_options.append(ConfigOption("usrmgt_port", "2178", |
213 |
"""The port where the usrmgt-server runs:""", |
|
214 |
"""
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
215 |
# The port where the usrmgt-server runs.""", ask=False)) |
216 |
||
217 |
config_options.append(ConfigOption("usrmgt_magic", None, |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
218 |
"""The password for the usrmgt-server:""", |
219 |
"""
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
220 |
# The password for the usrmgt-server.""", ask=False)) |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
221 |
|
222 |
def configure(args): |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
223 |
usage = """usage: %prog config [options] |
224 |
Creates lib/conf/conf.py (and a few other config files).
|
|
225 |
Interactively asks questions to set this up."""
|
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
226 |
|
227 |
# Parse arguments
|
|
228 |
parser = optparse.OptionParser(usage) |
|
229 |
(options, args) = parser.parse_args(args) |
|
230 |
||
231 |
# Call the real function
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
232 |
return __configure(args) |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
233 |
|
234 |
def __configure(args): |
|
235 |
global db_port, usrmgt_port |
|
236 |
||
237 |
# Try importing existing conf, but if we can't just set up defaults
|
|
238 |
# The reason for this is that these settings are used by other phases
|
|
239 |
# of setup besides conf, so we need to know them.
|
|
240 |
# Also this allows you to hit Return to accept the existing value.
|
|
241 |
try: |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
242 |
confmodule = __import__("ivle/conf/conf") |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
243 |
for opt in config_options: |
244 |
try: |
|
245 |
globals()[opt.option_name] = \ |
|
246 |
confmodule.__dict__[opt.option_name] |
|
247 |
except: |
|
248 |
globals()[opt.option_name] = opt.default |
|
249 |
except ImportError: |
|
250 |
# Just set reasonable defaults
|
|
251 |
for opt in config_options: |
|
252 |
globals()[opt.option_name] = opt.default |
|
253 |
||
254 |
# Set up some variables
|
|
255 |
cwd = os.getcwd() |
|
256 |
||
257 |
# the files that will be created/overwritten
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
258 |
conffile = os.path.join(cwd, "ivle/conf/conf.py") |
259 |
jailconffile = os.path.join(cwd, "ivle/conf/jailconf.py") |
|
260 |
conf_hfile = os.path.join(cwd, "bin/trampoline/conf.h") |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
261 |
phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php") |
262 |
||
263 |
# Get command-line arguments to avoid asking questions.
|
|
264 |
||
265 |
optnames = [] |
|
266 |
for opt in config_options: |
|
267 |
optnames.append(opt.option_name + "=") |
|
268 |
(opts, args) = getopt.gnu_getopt(args, "", optnames) |
|
269 |
||
270 |
if args != []: |
|
271 |
print >>sys.stderr, "Invalid arguments:", string.join(args, ' ') |
|
272 |
return 2 |
|
273 |
||
274 |
if opts == []: |
|
275 |
# Interactive mode. Prompt the user for all the values.
|
|
276 |
||
277 |
print """This tool will create the following files: |
|
278 |
%s |
|
279 |
%s |
|
280 |
%s |
|
281 |
%s |
|
282 |
prompting you for details about your configuration. The file will be
|
|
283 |
overwritten if it already exists. It will *not* install or deploy IVLE.
|
|
284 |
||
285 |
Please hit Ctrl+C now if you do not wish to do this.
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
286 |
""" % (conffile, jailconffile, conf_hfile, phpBBconffile) |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
287 |
|
288 |
# Get information from the administrator
|
|
289 |
# If EOF is encountered at any time during the questioning, just exit
|
|
290 |
# silently
|
|
291 |
||
292 |
for opt in config_options: |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
293 |
if opt.ask: |
294 |
globals()[opt.option_name] = \ |
|
295 |
query_user(globals()[opt.option_name], opt.prompt) |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
296 |
else: |
297 |
opts = dict(opts) |
|
298 |
# Non-interactive mode. Parse the options.
|
|
299 |
for opt in config_options: |
|
300 |
if '--' + opt.option_name in opts: |
|
301 |
globals()[opt.option_name] = opts['--' + opt.option_name] |
|
302 |
||
303 |
# Error handling on input values
|
|
304 |
try: |
|
305 |
allowed_uids_list = map(int, allowed_uids.split(',')) |
|
306 |
except ValueError: |
|
307 |
print >>sys.stderr, ( |
|
308 |
"Invalid UID list (%s).\n" |
|
309 |
"Must be a comma-separated list of integers." % allowed_uids) |
|
310 |
return 1 |
|
311 |
try: |
|
312 |
db_port = int(db_port) |
|
313 |
if db_port < 0 or db_port >= 65536: raise ValueError() |
|
314 |
except ValueError: |
|
315 |
print >>sys.stderr, ( |
|
316 |
"Invalid DB port (%s).\n" |
|
317 |
"Must be an integer between 0 and 65535." % repr(db_port)) |
|
318 |
return 1 |
|
319 |
try: |
|
320 |
usrmgt_port = int(usrmgt_port) |
|
321 |
if usrmgt_port < 0 or usrmgt_port >= 65536: raise ValueError() |
|
322 |
except ValueError: |
|
323 |
print >>sys.stderr, ( |
|
324 |
"Invalid user management port (%s).\n" |
|
325 |
"Must be an integer between 0 and 65535." % repr(usrmgt_port)) |
|
326 |
return 1 |
|
327 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
328 |
# By default we generate the magic randomly.
|
329 |
if globals()['usrmgt_magic'] is None: |
|
330 |
globals()['usrmgt_magic'] = hashlib.md5(uuid.uuid4().bytes).hexdigest() |
|
331 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
332 |
# Generate the forum secret
|
333 |
forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest() |
|
334 |
||
335 |
# Write lib/conf/conf.py
|
|
336 |
||
337 |
try: |
|
338 |
conf = open(conffile, "w") |
|
339 |
||
340 |
conf.write("""# IVLE Configuration File |
|
341 |
# conf.py
|
|
342 |
# Miscellaneous application settings
|
|
343 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
344 |
import os
|
345 |
import sys
|
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
346 |
""") |
347 |
for opt in config_options: |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
348 |
conf.write('%s\n%s = %r\n' % (opt.comment, opt.option_name, |
349 |
globals()[opt.option_name])) |
|
350 |
||
351 |
# Add the forum secret to the config file (regenerated each config)
|
|
352 |
conf.write('forum_secret = "%s"\n\n' % (forum_secret)) |
|
353 |
||
354 |
write_conf_file_boilerplate(conf) |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
355 |
|
356 |
conf.close() |
|
357 |
except IOError, (errno, strerror): |
|
358 |
print "IO error(%s): %s" % (errno, strerror) |
|
359 |
sys.exit(1) |
|
360 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
361 |
print "Successfully wrote %s" % conffile |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
362 |
|
363 |
# Write conf/jailconf.py
|
|
364 |
||
365 |
try: |
|
366 |
conf = open(jailconffile, "w") |
|
367 |
||
368 |
# In the "in-jail" version of conf, we don't need MOST of the details
|
|
369 |
# (it would be a security risk to have them here).
|
|
370 |
# So we just write root_dir, and jail_base is "/".
|
|
371 |
# (jail_base being "/" means "jail-relative" paths are relative to "/"
|
|
372 |
# when inside the jail.)
|
|
373 |
conf.write("""# IVLE Configuration File |
|
374 |
# conf.py
|
|
375 |
# Miscellaneous application settings
|
|
376 |
# (User jail version)
|
|
377 |
||
378 |
||
379 |
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
|
|
380 |
# with this).
|
|
381 |
# eg. "/" or "/ivle".
|
|
382 |
root_dir = %s |
|
383 |
||
384 |
# In the local file system, where are the student/user file spaces located.
|
|
385 |
# The user jails are expected to be located immediately in subdirectories of
|
|
386 |
# this location.
|
|
387 |
jail_base = '/'
|
|
388 |
||
389 |
# The hostname for serving publicly accessible pages
|
|
390 |
public_host = %s |
|
938
by wagrant
fileservice_lib: Make the svncheckout action (not to be confused with |
391 |
|
392 |
# The URL under which the Subversion repositories are located.
|
|
393 |
svn_addr = %s |
|
394 |
""" % (repr(root_dir),repr(public_host),repr(svn_addr))) |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
395 |
|
396 |
conf.close() |
|
397 |
except IOError, (errno, strerror): |
|
398 |
print "IO error(%s): %s" % (errno, strerror) |
|
399 |
sys.exit(1) |
|
400 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
401 |
print "Successfully wrote %s" % jailconffile |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
402 |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
403 |
# Write bin/trampoline/conf.h
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
404 |
|
405 |
try: |
|
406 |
conf = open(conf_hfile, "w") |
|
407 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
408 |
# XXX Compute jail_base, jail_src_base and jail_system. These will
|
409 |
# ALSO be done by the boilerplate code, but we need them here in order
|
|
410 |
# to write to the C file.
|
|
411 |
jail_base = os.path.join(data_path, 'jailmounts') |
|
412 |
jail_src_base = os.path.join(data_path, 'jails') |
|
413 |
jail_system = os.path.join(jail_src_base, '__base__') |
|
414 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
415 |
conf.write("""/* IVLE Configuration File |
416 |
* conf.h
|
|
417 |
* Administrator settings required by trampoline.
|
|
418 |
* Note: trampoline will have to be rebuilt in order for changes to this file
|
|
419 |
* to take effect.
|
|
420 |
*/
|
|
421 |
||
813
by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens |
422 |
#define IVLE_AUFS_JAILS
|
423 |
||
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
424 |
/* In the local file system, where are the jails located.
|
425 |
* The trampoline does not allow the creation of a jail anywhere besides
|
|
426 |
* jail_base or a subdirectory of jail_base.
|
|
427 |
*/
|
|
428 |
static const char* jail_base = "%s"; |
|
813
by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens |
429 |
static const char* jail_src_base = "%s"; |
430 |
static const char* jail_system = "%s"; |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
431 |
|
432 |
/* Which user IDs are allowed to run the trampoline.
|
|
433 |
* This list should be limited to the web server user.
|
|
434 |
* (Note that root is an implicit member of this list).
|
|
435 |
*/
|
|
436 |
static const int allowed_uids[] = { %s }; |
|
813
by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens |
437 |
""" % (repr(jail_base)[1:-1], repr(jail_src_base)[1:-1], |
438 |
repr(jail_system)[1:-1], repr(allowed_uids_list)[1:-1])) |
|
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
439 |
# Note: The above uses PYTHON reprs, not C reprs
|
440 |
# However they should be the same with the exception of the outer
|
|
441 |
# characters, which are stripped off and replaced
|
|
442 |
||
443 |
conf.close() |
|
444 |
except IOError, (errno, strerror): |
|
445 |
print "IO error(%s): %s" % (errno, strerror) |
|
446 |
sys.exit(1) |
|
447 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
448 |
print "Successfully wrote %s" % conf_hfile |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
449 |
|
450 |
# Write www/php/phpBB3/config.php
|
|
451 |
||
452 |
try: |
|
453 |
conf = open(phpBBconffile, "w") |
|
454 |
||
455 |
# php-pg work around
|
|
456 |
if db_host == 'localhost': |
|
457 |
forumdb_host = '127.0.0.1' |
|
458 |
else: |
|
459 |
forumdb_host = db_host |
|
460 |
||
461 |
conf.write( """<?php |
|
462 |
// phpBB 3.0.x auto-generated configuration file
|
|
463 |
// Do not change anything in this file!
|
|
464 |
$dbms = 'postgres';
|
|
465 |
$dbhost = '""" + forumdb_host + """'; |
|
466 |
$dbport = '""" + str(db_port) + """'; |
|
467 |
$dbname = '""" + db_forumdbname + """'; |
|
468 |
$dbuser = '""" + db_user + """'; |
|
469 |
$dbpasswd = '""" + db_password + """'; |
|
470 |
||
471 |
$table_prefix = 'phpbb_';
|
|
472 |
$acm_type = 'file';
|
|
473 |
$load_extensions = '';
|
|
474 |
@define('PHPBB_INSTALLED', true);
|
|
475 |
// @define('DEBUG', true);
|
|
476 |
//@define('DEBUG_EXTRA', true);
|
|
477 |
||
478 |
$forum_secret = '""" + forum_secret +"""'; |
|
479 |
?>""" ) |
|
480 |
||
481 |
conf.close() |
|
482 |
except IOError, (errno, strerror): |
|
483 |
print "IO error(%s): %s" % (errno, strerror) |
|
484 |
sys.exit(1) |
|
485 |
||
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
486 |
print "Successfully wrote %s" % phpBBconffile |
803
by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should |
487 |
|
488 |
print
|
|
489 |
print "You may modify the configuration at any time by editing" |
|
490 |
print conffile |
|
491 |
print jailconffile |
|
492 |
print conf_hfile |
|
493 |
print phpBBconffile |
|
494 |
print
|
|
495 |
||
496 |
return 0 |
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
497 |
|
498 |
def write_conf_file_boilerplate(conf_file): |
|
499 |
conf_file.write("""\ |
|
500 |
### Below is boilerplate code, appended by ./setup.py config ###
|
|
501 |
||
502 |
# Path where architecture-dependent data (including non-user-executable
|
|
503 |
# binaries) is installed.
|
|
504 |
lib_path = os.path.join(prefix, 'lib/ivle')
|
|
505 |
||
506 |
# Path where arch-independent data is installed.
|
|
507 |
share_path = os.path.join(prefix, 'share/ivle')
|
|
508 |
||
509 |
# Path where user-executable binaries are installed.
|
|
510 |
bin_path = os.path.join(prefix, 'bin')
|
|
511 |
||
512 |
# 'site-packages' directory in Python, where Python libraries are to be
|
|
513 |
# installed.
|
|
514 |
if python_site_packages_override is None:
|
|
515 |
PYTHON_VERSION = sys.version[0:3] # eg. "2.5"
|
|
516 |
python_site_packages = os.path.join(prefix,
|
|
517 |
'lib/python%s/site-packages' % PYTHON_VERSION) |
|
518 |
else:
|
|
519 |
python_site_packages = python_site_packages_override
|
|
520 |
||
521 |
# In the local file system, where the student/user jails will be mounted.
|
|
522 |
# Only a single copy of the jail's system components will be stored here -
|
|
523 |
# all user jails will be virtually mounted here.
|
|
524 |
jail_base = os.path.join(data_path, 'jailmounts')
|
|
525 |
||
526 |
# In the local file system, where are the student/user file spaces located.
|
|
527 |
# The user jails are expected to be located immediately in subdirectories of
|
|
528 |
# this location. Note that no complete jails reside here - only user
|
|
529 |
# modifications.
|
|
530 |
jail_src_base = os.path.join(data_path, 'jails')
|
|
531 |
||
532 |
# In the local file system, where the template system jail will be stored.
|
|
533 |
jail_system = os.path.join(jail_src_base, '__base__')
|
|
534 |
||
535 |
# In the local file system, where the subject content files are located.
|
|
536 |
# (The 'subjects' and 'exercises' directories).
|
|
537 |
content_path = os.path.join(data_path, 'content')
|
|
538 |
||
539 |
# In the local file system, where are the per-subject file spaces located.
|
|
540 |
# The individual subject directories are expected to be located immediately
|
|
541 |
# in subdirectories of this location.
|
|
542 |
subjects_base = os.path.join(content_path, 'subjects')
|
|
543 |
||
544 |
# In the local file system, where are the subject-independent exercise sheet
|
|
545 |
# file spaces located.
|
|
546 |
exercises_base = os.path.join(content_path, 'exercises')
|
|
547 |
||
548 |
# In the local file system, where the system notices are stored (such as terms
|
|
549 |
# of service and MOTD).
|
|
550 |
notices_path = os.path.join(data_path, 'notices')
|
|
551 |
||
552 |
# In the local file system, where is the Terms of Service document located.
|
|
553 |
tos_path = os.path.join(notices_path, 'tos.html')
|
|
554 |
||
555 |
# In the local file system, where is the Message of the Day document
|
|
556 |
# located. This is an HTML file (just the body fragment), which will
|
|
557 |
# be displayed on the login page. It is optional.
|
|
558 |
motd_path = os.path.join(notices_path, 'motd.html')
|
|
559 |
||
560 |
# The location of all the subversion config and repositories.
|
|
561 |
svn_path = os.path.join(data_path, 'svn')
|
|
562 |
||
563 |
# The location of the subversion configuration file used by
|
|
564 |
# apache to host the user repositories.
|
|
565 |
svn_conf = os.path.join(svn_path, 'svn.conf')
|
|
566 |
||
567 |
# The location of the subversion configuration file used by
|
|
568 |
# apache to host the user repositories.
|
|
569 |
svn_group_conf = os.path.join(svn_path, 'svn-group.conf')
|
|
570 |
||
571 |
# The root directory for the subversion repositories.
|
|
572 |
svn_repo_path = os.path.join(svn_path, 'repositories')
|
|
573 |
||
574 |
# The location of the password file used to authenticate users
|
|
575 |
# of the subversion repository from the ivle server.
|
|
576 |
svn_auth_ivle = os.path.join(svn_path, 'ivle.auth')
|
|
577 |
""") |