~azzar1/unity/add-show-desktop-key

803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
1
# IVLE - Informatics Virtual Learning Environment
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
2
# Copyright (C) 2007-2009 The University of Melbourne
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
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
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
22
'''Configures IVLE with machine-specific details, most notably, various paths.
23
Either prompts the administrator for these details or accepts them as
24
command-line args.
25
26
Creates ivle/conf/conf.py and bin/trampoline/trampoline/conf.h.
27
'''
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
28
29
import optparse
30
import getopt
31
import os
819 by mattgiuca
setup/configure.py: Added "import sys".
32
import sys
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
33
import hashlib
34
import uuid
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
35
36
from setup.util import query_user
1092.1.34 by Matt Giuca
setup.configure: Replaced use of legacy conf.py for loading existing values.
37
import ivle.config
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
38
1092.1.11 by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using
39
import configobj
40
1092.1.31 by Matt Giuca
configure.py: Replaced use of globals() dictionary for conf options with a
41
# conf_options maps option names to values
42
conf_options = {}
43
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
44
class ConfigOption:
45
    """A configuration option; one of the things written to conf.py."""
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
46
    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
47
        """Creates a configuration option.
48
        option_name: Name of the variable in conf.py. Also name of the
49
            command-line argument to setup.py conf.
50
        default: Default value for this variable.
51
        prompt: (Short) string presented during the interactive prompt in
52
            setup.py conf.
53
        comment: (Long) comment string stored in conf.py. Each line of this
54
            string should begin with a '#'.
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
55
        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
56
        """
57
        self.option_name = option_name
58
        self.default = default
59
        self.prompt = prompt
60
        self.comment = comment
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
61
        self.ask = ask
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
62
63
# Configuration options, defaults and descriptions
64
config_options = []
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
65
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
66
config_options.append(ConfigOption("urls/root", "/",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
67
    """Root directory where IVLE is located (in URL space):""",
68
    """
69
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
70
# with this).
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
71
# eg. "/" or "/ivle".""", ask=False))
72
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
73
config_options.append(ConfigOption("paths/prefix", "/usr/local",
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
74
    """In the local file system, the prefix to the system directory where IVLE
75
is installed. (This should either be /usr or /usr/local):""",
76
    """
77
# In the local file system, the prefix to the system directory where IVLE is
78
# installed. This should either be '/usr' or '/usr/local'.
79
# ('/usr/local' for the usual install, '/usr' for distribution packages)""",
80
    ask=False))
81
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
82
config_options.append(ConfigOption("paths/site_packages",
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
83
    None,
84
    """site-packages directory in Python, where Python libraries are to be
85
installed. May be left as the default, in which case the value will be
86
computed from prefix and the current Python version:""",
87
    """
88
# 'site-packages' directory in Python, where Python libraries are to be
89
# installed. May be None (recommended), in which case the value will be
90
# computed from prefix and the current Python version.""", ask=False))
91
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
92
config_options.append(ConfigOption("paths/data",
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
93
    "/var/lib/ivle",
94
    "In the local file system, where user-modifiable data files should be "
95
    "located:",
96
    """
97
# In the local file system, where user-modifiable data files should be
98
# located.""", ask=False))
99
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
100
config_options.append(ConfigOption("paths/logs",
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
101
    "/var/log/ivle",
893 by dcoles
Dispatch: Now attempts to log unhandled exceptions to a log directory specified
102
    """Directory where IVLE log files are stored (on the local
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
103
file system). Note - this must be writable by the user the IVLE server 
104
process runs as (usually www-data):""",
893 by dcoles
Dispatch: Now attempts to log unhandled exceptions to a log directory specified
105
    """
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
106
# In the local file system, where IVLE error logs should be located.""",
107
    ask=False))
108
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
109
config_options.append(ConfigOption("urls/public_host", "public.localhost",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
110
    """Hostname which will cause the server to go into "public mode",
111
providing login-free access to student's published work:""",
112
    """
113
# The server goes into "public mode" if the browser sends a request with this
114
# host. This is for security reasons - we only serve public student files on a
115
# separate domain to the main IVLE site.
116
# Public mode does not use cookies, and serves only public content.
117
# Private mode (normal mode) requires login, and only serves files relevant to
118
# the logged-in user."""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
119
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
120
config_options.append(ConfigOption("os/allowed_uids", "33",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
121
    """UID of the web server process which will run IVLE.
122
Only this user may execute the trampoline. May specify multiple users as
123
a comma-separated list.
124
    (eg. "1002,78")""",
125
    """
126
# The User-ID of the web server process which will run IVLE, and any other
127
# users who are allowed to run the trampoline. This is stores as a string of
128
# 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;
129
# used by the setup program to write to conf.h (see setup.py config).""",
130
    ask=False))
131
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
132
config_options.append(ConfigOption("database/host", "localhost",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
133
    """PostgreSQL Database config
134
==========================
135
Hostname of the DB server:""",
136
    """
137
# Database server hostname"""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
138
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
139
config_options.append(ConfigOption("database/port", "5432",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
140
    """Port of the DB server:""",
141
    """
142
# Database server port"""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
143
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
144
config_options.append(ConfigOption("database/name", "ivle",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
145
    """Database name:""",
146
    """
147
# Database name"""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
148
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
149
config_options.append(ConfigOption("plugins/forum/dbname", "ivle_forum",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
150
    """Forum Database name:""",
151
    """
152
# Forum Database name"""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
153
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
154
config_options.append(ConfigOption("database/username", "postgres",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
155
    """Username for DB server login:""",
156
    """
157
# Database username"""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
158
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
159
config_options.append(ConfigOption("database/password", "",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
160
    """Password for DB server login:
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
161
    (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
162
    """
163
# Database password"""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
164
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
165
config_options.append(ConfigOption("auth/modules", "",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
166
    """Authentication config
167
=====================
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
168
Comma-separated list of authentication modules.""",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
169
    """
170
# Comma-separated list of authentication modules.
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
171
# Note that auth is always enabled against the local database, and NO OTHER
172
# auth is enabled by default. This section is for specifying additional auth
173
# modules.
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
174
# These refer to importable Python modules in the www/auth directory.
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
175
# 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
176
# other modules may be plugged in to auth against organisation-specific
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
177
# auth backends.""", ask=False))
178
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
179
config_options.append(ConfigOption("auth/ldap_url", "ldaps://www.example.com",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
180
    """(LDAP options are only relevant if "ldap" is included in the list of
181
auth modules).
182
URL for LDAP authentication server:""",
183
    """
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
184
# URL for LDAP authentication server""", ask=False))
185
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
186
config_options.append(ConfigOption("auth/ldap_format_string",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
187
    "uid=%s,ou=users,o=example",
188
    """Format string for LDAP auth request:
189
    (Must contain a single "%s" for the user's login name)""",
190
    """
191
# Format string for LDAP auth request
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
192
# (Must contain a single "%s" for the user's login name)""", ask=False))
193
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
194
config_options.append(ConfigOption("auth/subject_pulldown_modules", "",
819 by mattgiuca
setup/configure.py: Added "import sys".
195
    """Comma-separated list of subject pulldown modules.
196
Add proprietary modules to automatically enrol students in subjects.""",
197
    """
198
# Comma-separated list of subject pulldown modules.
199
# 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
200
# Only "dummy_subj" is available in the source tree (an example), but
819 by mattgiuca
setup/configure.py: Added "import sys".
201
# other modules may be plugged in to pulldown against organisation-specific
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
202
# pulldown backends.""", ask=False))
203
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
204
config_options.append(ConfigOption("urls/svn_addr", "http://svn.localhost/",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
205
    """Subversion config
206
=================
207
The base url for accessing subversion repositories:""",
208
    """
209
# The base url for accessing subversion repositories."""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
210
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
211
config_options.append(ConfigOption("usrmgt/host", "localhost",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
212
    """User Management Server config
213
============================
214
The hostname where the usrmgt-server runs:""",
215
    """
216
# The hostname where the usrmgt-server runs."""))
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
217
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
218
config_options.append(ConfigOption("usrmgt/port", "2178",
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
219
    """The port where the usrmgt-server runs:""",
220
    """
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
221
# The port where the usrmgt-server runs.""", ask=False))
222
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
223
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
224
    """The password for the usrmgt-server:""",
225
    """
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
226
# 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
227
228
def configure(args):
229
    # Call the real function
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
230
    return __configure(args)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
231
232
def __configure(args):
233
    # Try importing existing conf, but if we can't just set up defaults
234
    # The reason for this is that these settings are used by other phases
235
    # of setup besides conf, so we need to know them.
236
    # Also this allows you to hit Return to accept the existing value.
1092.1.37 by Matt Giuca
setup.configure: Now handles the case of a missing config file.
237
    try:
238
        conf = ivle.config.Config()
239
    except ivle.config.ConfigError:
240
        # Couldn't find a config file anywhere.
241
        # Create a new blank config object (not yet bound to a file)
242
        # All lookups (below) will fail, so it will be initialised with all
243
        # the default values.
244
        conf = ivle.config.Config(blank=True)
245
1092.1.34 by Matt Giuca
setup.configure: Replaced use of legacy conf.py for loading existing values.
246
    for opt in config_options:
247
        try:
248
            conf_options[opt.option_name] = conf.get_by_path(opt.option_name)
249
        except KeyError:
1092.1.31 by Matt Giuca
configure.py: Replaced use of globals() dictionary for conf options with a
250
            conf_options[opt.option_name] = opt.default
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
251
252
    # Set up some variables
253
    cwd = os.getcwd()
254
255
    # the files that will be created/overwritten
1092.1.11 by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using
256
    conffile = os.path.join(cwd, "etc/ivle.conf")
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
257
    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
258
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
259
260
    # Get command-line arguments to avoid asking questions.
261
262
    optnames = []
263
    for opt in config_options:
264
        optnames.append(opt.option_name + "=")
265
    (opts, args) = getopt.gnu_getopt(args, "", optnames)
266
267
    if args != []:
268
        print >>sys.stderr, "Invalid arguments:", string.join(args, ' ')
269
        return 2
270
271
    if opts == []:
272
        # Interactive mode. Prompt the user for all the values.
273
274
        print """This tool will create the following files:
275
    %s
276
    %s
277
    %s
278
prompting you for details about your configuration. The file will be
279
overwritten if it already exists. It will *not* install or deploy IVLE.
280
281
Please hit Ctrl+C now if you do not wish to do this.
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
282
""" % (conffile, conf_hfile, phpBBconffile)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
283
284
        # Get information from the administrator
285
        # If EOF is encountered at any time during the questioning, just exit
286
        # silently
287
288
        for opt in config_options:
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
289
            if opt.ask:
1092.1.31 by Matt Giuca
configure.py: Replaced use of globals() dictionary for conf options with a
290
                conf_options[opt.option_name] = \
291
                    query_user(conf_options[opt.option_name], opt.prompt)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
292
    else:
293
        opts = dict(opts)
294
        # Non-interactive mode. Parse the options.
295
        for opt in config_options:
296
            if '--' + opt.option_name in opts:
1092.1.31 by Matt Giuca
configure.py: Replaced use of globals() dictionary for conf options with a
297
                conf_options[opt.option_name] = opts['--' + opt.option_name]
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
298
299
    # Error handling on input values
300
    try:
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
301
        allowed_uids_list = map(int,
302
                                conf_options['os/allowed_uids'].split(','))
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
303
    except ValueError:
304
        print >>sys.stderr, (
305
        "Invalid UID list (%s).\n"
1092.1.30 by Matt Giuca
setup.configure: Replaced all uses of config-variable global variables with
306
        "Must be a comma-separated list of integers." %
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
307
            conf_options['os/allowed_uids'])
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
308
        return 1
309
    try:
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
310
        conf_options['database/port'] = int(conf_options['database/port'])
311
        if (conf_options['database/port'] < 0
312
            or conf_options['database/port'] >= 65536):
1092.1.30 by Matt Giuca
setup.configure: Replaced all uses of config-variable global variables with
313
            raise ValueError()
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
314
    except ValueError:
315
        print >>sys.stderr, (
316
        "Invalid DB port (%s).\n"
1092.1.32 by Matt Giuca
configure.py: Fixed missing reference to conf_options in error case.
317
        "Must be an integer between 0 and 65535." %
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
318
            repr(conf_options['database/port']))
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
319
        return 1
320
    try:
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
321
        conf_options['usrmgt/port'] = int(conf_options['usrmgt/port'])
322
        if (conf_options['usrmgt/port'] < 0
323
            or conf_options['usrmgt/port'] >= 65536):
1092.1.30 by Matt Giuca
setup.configure: Replaced all uses of config-variable global variables with
324
            raise ValueError()
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
325
    except ValueError:
326
        print >>sys.stderr, (
327
        "Invalid user management port (%s).\n"
1092.1.32 by Matt Giuca
configure.py: Fixed missing reference to conf_options in error case.
328
        "Must be an integer between 0 and 65535." %
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
329
            repr(conf_options['usrmgt/port']))
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
330
        return 1
331
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
332
    # By default we generate the magic randomly.
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
333
    if conf_options['usrmgt/magic'] is None:
334
        conf_options['usrmgt/magic'] = \
1092.1.31 by Matt Giuca
configure.py: Replaced use of globals() dictionary for conf options with a
335
            hashlib.md5(uuid.uuid4().bytes).hexdigest()
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
336
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
337
    # Generate the forum secret
338
    forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
339
1092.1.37 by Matt Giuca
setup.configure: Now handles the case of a missing config file.
340
    # Write ./etc/ivle.conf (even if we loaded from a different filename)
1092.1.11 by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using
341
    conf.filename = conffile
342
343
    conf.initial_comment = ["# IVLE Configuration File"]
344
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
345
    # Add the forum secret to the config file (regenerated each config)
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
346
    config_options.append(ConfigOption('plugins/forum/secret', None, '', ''))
347
    conf_options['plugins/forum/secret'] = forum_secret
1092.1.12 by Matt Giuca
Changed new-style config file to a hierarchical one with nice shiny new names.
348
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
349
    for opt in config_options:
350
        value = conf_options[opt.option_name]
1092.1.12 by Matt Giuca
Changed new-style config file to a hierarchical one with nice shiny new names.
351
        if value is not None:
1092.1.36 by Matt Giuca
ivle.config.Config: Added set_by_path method (based on code from
352
            conf.set_by_path(opt.option_name, value, opt.comment)
1092.1.11 by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using
353
354
    conf.write()
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
355
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
356
    print "Successfully wrote %s" % conffile
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
357
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
358
    # Write bin/trampoline/conf.h
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
359
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
360
    conf = open(conf_hfile, "w")
361
362
    # XXX Compute jail_base, jail_src_base and jail_system. These will
363
    # ALSO be done by the boilerplate code, but we need them here in order
364
    # to write to the C file.
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
365
    jail_base = os.path.join(conf_options['paths/data'], 'jailmounts')
366
    jail_src_base = os.path.join(conf_options['paths/data'], 'jails')
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
367
    jail_system = os.path.join(jail_src_base, '__base__')
368
369
    conf.write("""/* IVLE Configuration File
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
370
 * conf.h
371
 * Administrator settings required by trampoline.
372
 * Note: trampoline will have to be rebuilt in order for changes to this file
373
 * to take effect.
374
 */
375
813 by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens
376
#define IVLE_AUFS_JAILS
377
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
378
/* In the local file system, where are the jails located.
379
 * The trampoline does not allow the creation of a jail anywhere besides
380
 * jail_base or a subdirectory of jail_base.
381
 */
382
static const char* jail_base = "%s";
813 by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens
383
static const char* jail_src_base = "%s";
384
static const char* jail_system = "%s";
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
385
386
/* Which user IDs are allowed to run the trampoline.
387
 * This list should be limited to the web server user.
388
 * (Note that root is an implicit member of this list).
389
 */
390
static const int allowed_uids[] = { %s };
813 by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens
391
""" % (repr(jail_base)[1:-1], repr(jail_src_base)[1:-1],
392
       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
393
    # Note: The above uses PYTHON reprs, not C reprs
394
    # However they should be the same with the exception of the outer
395
    # characters, which are stripped off and replaced
396
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
397
    conf.close()
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
398
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
399
    print "Successfully wrote %s" % conf_hfile
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
400
401
    # Write www/php/phpBB3/config.php
402
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
403
    conf = open(phpBBconffile, "w")
404
    
405
    # php-pg work around
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
406
    if conf_options['database/host'] == 'localhost':
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
407
        forumdb_host = '127.0.0.1'
408
    else:
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
409
        forumdb_host = conf_options['database/host']
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
410
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
411
    conf.write( """<?php
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
412
// phpBB 3.0.x auto-generated configuration file
413
// Do not change anything in this file!
414
$dbms = 'postgres';
415
$dbhost = '""" + forumdb_host + """';
1092.1.33 by Matt Giuca
setup.configure: Replaced all of the config option names with the new path
416
$dbport = '""" + str(conf_options['database/port']) + """';
417
$dbname = '""" + conf_options['plugins/forum/dbname'] + """';
418
$dbuser = '""" + conf_options['database/username'] + """';
419
$dbpasswd = '""" + conf_options['database/password'] + """';
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
420
421
$table_prefix = 'phpbb_';
422
$acm_type = 'file';
423
$load_extensions = '';
424
@define('PHPBB_INSTALLED', true);
425
// @define('DEBUG', true);
426
//@define('DEBUG_EXTRA', true);
427
428
$forum_secret = '""" + forum_secret +"""';
429
?>"""   )
430
    
1092.1.10 by Matt Giuca
setup/configure.py: Removed exception handling of IOErrors when writing conf.
431
    conf.close()
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
432
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
433
    print "Successfully wrote %s" % phpBBconffile
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
434
435
    print
436
    print "You may modify the configuration at any time by editing"
437
    print conffile
438
    print conf_hfile
439
    print phpBBconffile
440
    print
441
    
442
    return 0