97
by mattgiuca
Moved template.py and setup.py to better places. |
1 |
#!/usr/bin/env python
|
2 |
# IVLE - Informatics Virtual Learning Environment
|
|
3 |
# Copyright (C) 2007-2008 The University of Melbourne
|
|
4 |
#
|
|
5 |
# This program is free software; you can redistribute it and/or modify
|
|
6 |
# it under the terms of the GNU General Public License as published by
|
|
7 |
# the Free Software Foundation; either version 2 of the License, or
|
|
8 |
# (at your option) any later version.
|
|
9 |
#
|
|
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program; if not, write to the Free Software
|
|
17 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
||
19 |
# Module: setup
|
|
20 |
# Author: Matt Giuca
|
|
21 |
# Date: 12/12/2007
|
|
22 |
||
23 |
# This is a command-line application, for use by the administrator.
|
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
24 |
# This program configures, builds and installs IVLE in three separate steps.
|
25 |
# It is called with at least one argument, which specifies which operation to
|
|
26 |
# take.
|
|
27 |
||
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
28 |
# setup.py listmake (for developer use only)
|
29 |
# Recurses through the source tree and builds a list of all files which should
|
|
30 |
# be copied upon installation. This should be run by the developer before
|
|
31 |
# cutting a distribution, and the listfile it generates should be included in
|
|
32 |
# the distribution, avoiding the administrator having to run it.
|
|
33 |
||
316
by drtomc
setup.py - name the configuration command "config" to bring it into line with |
34 |
# setup.py config [args]
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
35 |
# Configures IVLE with machine-specific details, most notably, various paths.
|
36 |
# Either prompts the administrator for these details or accepts them as
|
|
37 |
# command-line args.
|
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
38 |
# Creates lib/conf/conf.py and trampoline/conf.h.
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
39 |
|
40 |
# setup.py build
|
|
41 |
# Compiles all files and sets up a jail template in the source directory.
|
|
42 |
# Details:
|
|
43 |
# Compiles (GCC) trampoline/trampoline.c to trampoline/trampoline.
|
|
44 |
# Creates jail/.
|
|
45 |
# Creates standard subdirs inside the jail, eg bin, opt, home, tmp.
|
|
46 |
# Copies console/ to a location within the jail.
|
|
47 |
# Copies OS programs and files to corresponding locations within the jail
|
|
48 |
# (eg. python and Python libs, ld.so, etc).
|
|
49 |
# Generates .pyc files for all the IVLE .py files.
|
|
50 |
||
51 |
# setup.py install [--nojail] [--dry|n]
|
|
52 |
# (Requires root)
|
|
53 |
# Create target install directory ($target).
|
|
54 |
# Create $target/bin.
|
|
55 |
# Copy trampoline/trampoline to $target/bin.
|
|
56 |
# chown and chmod the installed trampoline.
|
|
57 |
# Copy www/ to $target.
|
|
58 |
# Copy jail/ to jails template directory (unless --nojail specified).
|
|
97
by mattgiuca
Moved template.py and setup.py to better places. |
59 |
|
60 |
import os |
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
61 |
import stat |
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
62 |
import shutil |
97
by mattgiuca
Moved template.py and setup.py to better places. |
63 |
import sys |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
64 |
import getopt |
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
65 |
import string |
66 |
import errno |
|
117
by mattgiuca
setup.py: listmake uses mimetypes to select all files with certain mime types, |
67 |
import mimetypes |
116
by mattgiuca
setup.py: mkdir now properly obeys "dry". |
68 |
import compileall |
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
69 |
import getopt |
671
by dcoles
forum: Now uses a unique secret generated at './setup config' time for shared secret |
70 |
import hashlib |
71 |
import uuid |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
72 |
|
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
73 |
# Import modules from the website is tricky since they're in the www
|
74 |
# directory.
|
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
75 |
sys.path.append(os.path.join(os.getcwd(), 'lib')) |
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
76 |
import conf |
77 |
import common.makeuser |
|
78 |
||
317
by mattgiuca
doc/dependencies: Added dependency on matplotlib. |
79 |
# Determine which Python version (2.4 or 2.5, for example) we are running,
|
80 |
# and use that as the filename to the Python directory.
|
|
81 |
# Just get the first 3 characters of sys.version.
|
|
82 |
PYTHON_VERSION = sys.version[0:3] |
|
83 |
||
251
by mattgiuca
setup.py: Worked the "files to copy into jail" out into a separate list |
84 |
# Operating system files to copy over into the jail.
|
85 |
# These will be copied from the given place on the OS file system into the
|
|
86 |
# same place within the jail.
|
|
87 |
JAIL_FILES = [ |
|
88 |
'/lib/ld-linux.so.2', |
|
89 |
'/lib/tls/i686/cmov/libc.so.6', |
|
90 |
'/lib/tls/i686/cmov/libdl.so.2', |
|
91 |
'/lib/tls/i686/cmov/libm.so.6', |
|
92 |
'/lib/tls/i686/cmov/libpthread.so.0', |
|
93 |
'/lib/tls/i686/cmov/libutil.so.1', |
|
253
by mattgiuca
setup.py: chmods python-console when building. |
94 |
'/etc/ld.so.conf', |
95 |
'/etc/ld.so.cache', |
|
96 |
# These 2 files do not exist in Ubuntu
|
|
97 |
#'/etc/ld.so.preload',
|
|
98 |
#'/etc/ld.so.nohwcap',
|
|
99 |
# UNIX commands
|
|
100 |
'/usr/bin/strace', |
|
101 |
'/bin/ls', |
|
102 |
'/bin/echo', |
|
103 |
# Needed by python
|
|
317
by mattgiuca
doc/dependencies: Added dependency on matplotlib. |
104 |
'/usr/bin/python%s' % PYTHON_VERSION, |
434
by drtomc
setup.py: add a bunch of shared objects to be added to the jail for svn. |
105 |
# Needed by fileservice
|
106 |
'/lib/libcom_err.so.2', |
|
107 |
'/lib/libcrypt.so.1', |
|
108 |
'/lib/libkeyutils.so.1', |
|
109 |
'/lib/libresolv.so.2', |
|
110 |
'/lib/librt.so.1', |
|
111 |
'/lib/libuuid.so.1', |
|
112 |
'/usr/lib/libapr-1.so.0', |
|
113 |
'/usr/lib/libaprutil-1.so.0', |
|
114 |
'/usr/lib/libdb-4.4.so', |
|
115 |
'/usr/lib/libexpat.so.1', |
|
116 |
'/usr/lib/libgcrypt.so.11', |
|
117 |
'/usr/lib/libgnutls.so.13', |
|
118 |
'/usr/lib/libgpg-error.so.0', |
|
119 |
'/usr/lib/libgssapi_krb5.so.2', |
|
120 |
'/usr/lib/libk5crypto.so.3', |
|
121 |
'/usr/lib/libkrb5.so.3', |
|
122 |
'/usr/lib/libkrb5support.so.0', |
|
123 |
'/usr/lib/liblber.so.2', |
|
124 |
'/usr/lib/libldap_r.so.2', |
|
125 |
'/usr/lib/libneon.so.26', |
|
126 |
'/usr/lib/libpq.so.5', |
|
127 |
'/usr/lib/libsasl2.so.2', |
|
128 |
'/usr/lib/libsqlite3.so.0', |
|
129 |
'/usr/lib/libsvn_client-1.so.1', |
|
130 |
'/usr/lib/libsvn_delta-1.so.1', |
|
131 |
'/usr/lib/libsvn_diff-1.so.1', |
|
132 |
'/usr/lib/libsvn_fs-1.so.1', |
|
133 |
'/usr/lib/libsvn_fs_base-1.so.1', |
|
134 |
'/usr/lib/libsvn_fs_fs-1.so.1', |
|
135 |
'/usr/lib/libsvn_ra-1.so.1', |
|
136 |
'/usr/lib/libsvn_ra_dav-1.so.1', |
|
137 |
'/usr/lib/libsvn_ra_local-1.so.1', |
|
138 |
'/usr/lib/libsvn_ra_svn-1.so.1', |
|
139 |
'/usr/lib/libsvn_repos-1.so.1', |
|
140 |
'/usr/lib/libsvn_subr-1.so.1', |
|
141 |
'/usr/lib/libsvn_wc-1.so.1', |
|
142 |
'/usr/lib/libtasn1.so.3', |
|
143 |
'/usr/lib/libxml2.so.2', |
|
253
by mattgiuca
setup.py: chmods python-console when building. |
144 |
# Needed by matplotlib
|
145 |
'/usr/lib/i686/cmov/libssl.so.0.9.8', |
|
146 |
'/usr/lib/i686/cmov/libcrypto.so.0.9.8', |
|
147 |
'/lib/tls/i686/cmov/libnsl.so.1', |
|
148 |
'/usr/lib/libz.so.1', |
|
149 |
'/usr/lib/atlas/liblapack.so.3', |
|
150 |
'/usr/lib/atlas/libblas.so.3', |
|
151 |
'/usr/lib/libg2c.so.0', |
|
152 |
'/usr/lib/libstdc++.so.6', |
|
153 |
'/usr/lib/libfreetype.so.6', |
|
154 |
'/usr/lib/libpng12.so.0', |
|
155 |
'/usr/lib/libBLT.2.4.so.8.4', |
|
156 |
'/usr/lib/libtk8.4.so.0', |
|
157 |
'/usr/lib/libtcl8.4.so.0', |
|
158 |
'/usr/lib/tcl8.4/init.tcl', |
|
159 |
'/usr/lib/libX11.so.6', |
|
160 |
'/usr/lib/libXau.so.6', |
|
161 |
'/usr/lib/libXdmcp.so.6', |
|
162 |
'/lib/libgcc_s.so.1', |
|
163 |
'/etc/matplotlibrc', |
|
547
by dcoles
settup.py: Added nss libaries and /etc files needed for resolving hostnames. |
164 |
# Needed for resolv
|
165 |
'/lib/libnss_dns.so.2', |
|
685
by dcoles
libs: The standard nsswitch.conf in 7.10 expects mdns4_minimal module. Without |
166 |
'/lib/libnss_mdns4_minimal.so.2', |
547
by dcoles
settup.py: Added nss libaries and /etc files needed for resolving hostnames. |
167 |
'/etc/hosts', |
168 |
'/etc/resolv.conf', |
|
169 |
#'/etc/hosts.conf',
|
|
170 |
#'/etc/hostname',
|
|
171 |
'/etc/nsswitch.conf', |
|
172 |
'/lib/libnss_files.so.2', |
|
251
by mattgiuca
setup.py: Worked the "files to copy into jail" out into a separate list |
173 |
]
|
174 |
# Symlinks to make within the jail. Src mapped to dst.
|
|
175 |
JAIL_LINKS = { |
|
317
by mattgiuca
doc/dependencies: Added dependency on matplotlib. |
176 |
'python%s' % PYTHON_VERSION: 'jail/usr/bin/python', |
251
by mattgiuca
setup.py: Worked the "files to copy into jail" out into a separate list |
177 |
}
|
178 |
# Trees to copy. Src mapped to dst (these will be passed to action_copytree).
|
|
179 |
JAIL_COPYTREES = { |
|
317
by mattgiuca
doc/dependencies: Added dependency on matplotlib. |
180 |
'/usr/lib/python%s' % PYTHON_VERSION: |
181 |
'jail/usr/lib/python%s' % PYTHON_VERSION, |
|
253
by mattgiuca
setup.py: chmods python-console when building. |
182 |
'/usr/share/matplotlib': 'jail/usr/share/matplotlib', |
183 |
'/etc/ld.so.conf.d': 'jail/etc/ld.so.conf.d', |
|
682
by dcoles
Natural Language Tool Kit (nltk) for student code |
184 |
'/usr/share/nltk': 'jail/usr/share/nltk', |
251
by mattgiuca
setup.py: Worked the "files to copy into jail" out into a separate list |
185 |
}
|
186 |
||
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
187 |
class ConfigOption: |
188 |
"""A configuration option; one of the things written to conf.py."""
|
|
189 |
def __init__(self, option_name, default, prompt, comment): |
|
190 |
"""Creates a configuration option.
|
|
191 |
option_name: Name of the variable in conf.py. Also name of the
|
|
192 |
command-line argument to setup.py conf.
|
|
193 |
default: Default value for this variable.
|
|
194 |
prompt: (Short) string presented during the interactive prompt in
|
|
195 |
setup.py conf.
|
|
196 |
comment: (Long) comment string stored in conf.py. Each line of this
|
|
197 |
string should begin with a '#'.
|
|
198 |
"""
|
|
199 |
self.option_name = option_name |
|
200 |
self.default = default |
|
201 |
self.prompt = prompt |
|
202 |
self.comment = comment |
|
203 |
||
204 |
# Configuration options, defaults and descriptions
|
|
205 |
config_options = [] |
|
485
by mattgiuca
setup.py: Changed the defaut root_dir from "/ivle" to "/". |
206 |
config_options.append(ConfigOption("root_dir", "/", |
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
207 |
"""Root directory where IVLE is located (in URL space):""", |
208 |
"""
|
|
209 |
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
|
|
210 |
# with this).
|
|
211 |
# eg. "/" or "/ivle".""")) |
|
212 |
config_options.append(ConfigOption("ivle_install_dir", "/opt/ivle", |
|
213 |
'Root directory where IVLE will be installed (on the local file '
|
|
214 |
'system):', |
|
215 |
"""
|
|
216 |
# In the local file system, where IVLE is actually installed.
|
|
217 |
# This directory should contain the "www" and "bin" directories.""")) |
|
218 |
config_options.append(ConfigOption("jail_base", "/home/informatics/jails", |
|
530
by mattgiuca
setup.py: |
219 |
"""Location of Directories
|
220 |
=======================
|
|
221 |
Root directory where the jails (containing user files) are stored
|
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
222 |
(on the local file system):""", |
223 |
"""
|
|
224 |
# In the local file system, where are the student/user file spaces located.
|
|
225 |
# The user jails are expected to be located immediately in subdirectories of
|
|
226 |
# this location.""")) |
|
227 |
config_options.append(ConfigOption("subjects_base", |
|
228 |
"/home/informatics/subjects", |
|
229 |
"""Root directory where the subject directories (containing worksheets
|
|
230 |
and other per-subject files) are stored (on the local file system):""", |
|
231 |
"""
|
|
232 |
# In the local file system, where are the per-subject file spaces located.
|
|
233 |
# The individual subject directories are expected to be located immediately
|
|
234 |
# in subdirectories of this location.""")) |
|
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
235 |
config_options.append(ConfigOption("exercises_base", |
236 |
"/home/informatics/exercises", |
|
237 |
"""Root directory where the exercise directories (containing
|
|
238 |
subject-independent exercise sheets) are stored (on the local file
|
|
395
by mattgiuca
Tutorial: split subjects directory into subjects and problems. |
239 |
system):""", |
240 |
"""
|
|
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
241 |
# In the local file system, where are the subject-independent exercise sheet
|
395
by mattgiuca
Tutorial: split subjects directory into subjects and problems. |
242 |
# file spaces located.""")) |
673
by mattgiuca
Rebuilt the way Terms of Service are displayed: |
243 |
config_options.append(ConfigOption("tos_path", |
244 |
"/home/informatics/tos.html", |
|
245 |
"""Location where the Terms of Service document is stored (on the local
|
|
246 |
file system):""", |
|
247 |
"""
|
|
248 |
# In the local file system, where is the Terms of Service document located.""")) |
|
712
by mattgiuca
setup: Added config option "motd_path" to hold the path for message-of-the-day |
249 |
config_options.append(ConfigOption("motd_path", |
250 |
"/home/informatics/motd.html", |
|
251 |
"""Location where the Message of the Day document is stored (on the local
|
|
252 |
file system):""", |
|
253 |
"""
|
|
254 |
# In the local file system, where is the Message of the Day document
|
|
255 |
# located. This is an HTML file (just the body fragment), which will
|
|
256 |
# be displayed on the login page. It is optional.""")) |
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
257 |
config_options.append(ConfigOption("public_host", "public.localhost", |
258 |
"""Hostname which will cause the server to go into "public mode",
|
|
259 |
providing login-free access to student's published work:""", |
|
260 |
"""
|
|
261 |
# The server goes into "public mode" if the browser sends a request with this
|
|
262 |
# host. This is for security reasons - we only serve public student files on a
|
|
263 |
# separate domain to the main IVLE site.
|
|
264 |
# Public mode does not use cookies, and serves only public content.
|
|
265 |
# Private mode (normal mode) requires login, and only serves files relevant to
|
|
266 |
# the logged-in user.""")) |
|
267 |
config_options.append(ConfigOption("allowed_uids", "33", |
|
268 |
"""UID of the web server process which will run IVLE.
|
|
269 |
Only this user may execute the trampoline. May specify multiple users as
|
|
270 |
a comma-separated list.
|
|
271 |
(eg. "1002,78")""", |
|
272 |
"""
|
|
273 |
# The User-ID of the web server process which will run IVLE, and any other
|
|
274 |
# users who are allowed to run the trampoline. This is stores as a string of
|
|
275 |
# comma-separated integers, simply because it is not used within Python, only
|
|
276 |
# used by the setup program to write to conf.h (see setup.py config).""")) |
|
359
by mattgiuca
setup.py: Added config options for database settings. |
277 |
config_options.append(ConfigOption("db_host", "localhost", |
278 |
"""PostgreSQL Database config
|
|
279 |
==========================
|
|
280 |
Hostname of the DB server:""", |
|
281 |
"""
|
|
282 |
### PostgreSQL Database config ###
|
|
283 |
# Database server hostname""")) |
|
284 |
config_options.append(ConfigOption("db_port", "5432", |
|
285 |
"""Port of the DB server:""", |
|
286 |
"""
|
|
287 |
# Database server port""")) |
|
363
by mattgiuca
setup.py: Added new config option - "database name" |
288 |
config_options.append(ConfigOption("db_dbname", "ivle", |
289 |
"""Database name:""", |
|
290 |
"""
|
|
291 |
# Database name""")) |
|
624
by dcoles
forum: Removed the subsilver2 style and phpBB installer |
292 |
config_options.append(ConfigOption("db_forumdbname", "ivle_forum", |
293 |
"""Forum Database name:""", |
|
294 |
"""
|
|
295 |
# Forum Database name""")) |
|
359
by mattgiuca
setup.py: Added config options for database settings. |
296 |
config_options.append(ConfigOption("db_user", "postgres", |
297 |
"""Username for DB server login:""", |
|
298 |
"""
|
|
299 |
# Database username""")) |
|
300 |
config_options.append(ConfigOption("db_password", "", |
|
301 |
"""Password for DB server login:
|
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
302 |
(Caution: This password is stored in plaintext in lib/conf/conf.py)""", |
359
by mattgiuca
setup.py: Added config options for database settings. |
303 |
"""
|
304 |
# Database password""")) |
|
531
by mattgiuca
www/auth: Split authenticate.py into 3 modules: autherror and ldap_auth. |
305 |
config_options.append(ConfigOption("auth_modules", "ldap_auth", |
530
by mattgiuca
setup.py: |
306 |
"""Authentication config
|
307 |
=====================
|
|
308 |
Comma-separated list of authentication modules. Only "ldap" is available
|
|
309 |
by default.""", |
|
310 |
"""
|
|
311 |
# Comma-separated list of authentication modules.
|
|
312 |
# These refer to importable Python modules in the www/auth directory.
|
|
313 |
# Modules "ldap" and "guest" are available in the source tree, but
|
|
314 |
# other modules may be plugged in to auth against organisation-specific
|
|
315 |
# auth backends.""")) |
|
510
by mattgiuca
setup.py: Added 2 new config options for the LDAP authentication server. |
316 |
config_options.append(ConfigOption("ldap_url", "ldaps://www.example.com", |
530
by mattgiuca
setup.py: |
317 |
"""(LDAP options are only relevant if "ldap" is included in the list of
|
318 |
auth modules).
|
|
319 |
URL for LDAP authentication server:""", |
|
510
by mattgiuca
setup.py: Added 2 new config options for the LDAP authentication server. |
320 |
"""
|
321 |
# URL for LDAP authentication server""")) |
|
322 |
config_options.append(ConfigOption("ldap_format_string", |
|
323 |
"uid=%s,ou=users,o=example", |
|
324 |
"""Format string for LDAP auth request:
|
|
325 |
(Must contain a single "%s" for the user's login name)""", |
|
326 |
"""
|
|
327 |
# Format string for LDAP auth request
|
|
328 |
# (Must contain a single "%s" for the user's login name)""")) |
|
522
by drtomc
Add quite a lot of stuff to get usrmgt happening. |
329 |
config_options.append(ConfigOption("svn_addr", "http://svn.localhost/", |
530
by mattgiuca
setup.py: |
330 |
"""Subversion config
|
331 |
=================
|
|
332 |
The base url for accessing subversion repositories:""", |
|
522
by drtomc
Add quite a lot of stuff to get usrmgt happening. |
333 |
"""
|
334 |
# The base url for accessing subversion repositories.""")) |
|
460
by drtomc
setup.py: Add a bunch of config stuff we need. |
335 |
config_options.append(ConfigOption("svn_conf", "/opt/ivle/svn/svn.conf", |
336 |
"""The location of the subversion configuration file used by apache
|
|
337 |
to host the user repositories:""", |
|
338 |
"""
|
|
339 |
# The location of the subversion configuration file used by
|
|
340 |
# apache to host the user repositories.""")) |
|
467
by drtomc
makeuser: Add some of the helper functions for activating users. |
341 |
config_options.append(ConfigOption("svn_repo_path", "/home/informatics/repositories", |
342 |
"""The root directory for the subversion repositories:""", |
|
343 |
"""
|
|
344 |
# The root directory for the subversion repositories.""")) |
|
460
by drtomc
setup.py: Add a bunch of config stuff we need. |
345 |
config_options.append(ConfigOption("svn_auth_ivle", "/opt/ivle/svn/ivle.auth", |
346 |
"""The location of the password file used to authenticate users
|
|
347 |
of the subversion repository from the ivle server:""", |
|
348 |
"""
|
|
349 |
# The location of the password file used to authenticate users
|
|
350 |
# of the subversion repository from the ivle server.""")) |
|
351 |
config_options.append(ConfigOption("svn_auth_local", "/opt/ivle/svn/local.auth", |
|
352 |
"""The location of the password file used to authenticate local users
|
|
353 |
of the subversion repository:""", |
|
354 |
"""
|
|
355 |
# The location of the password file used to authenticate local users
|
|
356 |
# of the subversion repository.""")) |
|
357 |
config_options.append(ConfigOption("usrmgt_host", "localhost", |
|
530
by mattgiuca
setup.py: |
358 |
"""User Management Server config
|
359 |
============================
|
|
360 |
The hostname where the usrmgt-server runs:""", |
|
460
by drtomc
setup.py: Add a bunch of config stuff we need. |
361 |
"""
|
362 |
# The hostname where the usrmgt-server runs.""")) |
|
363 |
config_options.append(ConfigOption("usrmgt_port", "2178", |
|
364 |
"""The port where the usrmgt-server runs:""", |
|
365 |
"""
|
|
366 |
# The port where the usrmgt-server runs.""")) |
|
367 |
config_options.append(ConfigOption("usrmgt_magic", "", |
|
368 |
"""The password for the usrmgt-server:""", |
|
369 |
"""
|
|
370 |
# The password for the usrmgt-server.""")) |
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
371 |
|
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
372 |
# Try importing existing conf, but if we can't just set up defaults
|
373 |
# The reason for this is that these settings are used by other phases
|
|
374 |
# of setup besides conf, so we need to know them.
|
|
375 |
# Also this allows you to hit Return to accept the existing value.
|
|
376 |
try: |
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
377 |
confmodule = __import__("lib/conf/conf") |
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
378 |
for opt in config_options: |
379 |
try: |
|
380 |
globals()[opt.option_name] = confmodule.__dict__[opt.option_name] |
|
381 |
except: |
|
382 |
globals()[opt.option_name] = opt.default |
|
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
383 |
except ImportError: |
384 |
# Just set reasonable defaults
|
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
385 |
for opt in config_options: |
386 |
globals()[opt.option_name] = opt.default |
|
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
387 |
|
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
388 |
# Try importing install_list, but don't fail if we can't, because listmake can
|
389 |
# function without it.
|
|
390 |
try: |
|
391 |
import install_list |
|
392 |
except: |
|
393 |
pass
|
|
394 |
||
117
by mattgiuca
setup.py: listmake uses mimetypes to select all files with certain mime types, |
395 |
# Mime types which will automatically be placed in the list by listmake.
|
396 |
# Note that listmake is not intended to be run by the final user (the system
|
|
397 |
# administrator who installs this), so the developers can customize the list
|
|
398 |
# as necessary, and include it in the distribution.
|
|
399 |
listmake_mimetypes = ['text/x-python', 'text/html', |
|
400 |
'application/x-javascript', 'application/javascript', |
|
568
by mattgiuca
setup.py: Added "image/gif" to types which listmake copies over. |
401 |
'text/css', 'image/png', 'image/gif', 'application/xml'] |
117
by mattgiuca
setup.py: listmake uses mimetypes to select all files with certain mime types, |
402 |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
403 |
# Main function skeleton from Guido van Rossum
|
404 |
# http://www.artima.com/weblogs/viewpost.jsp?thread=4829
|
|
405 |
||
406 |
def main(argv=None): |
|
407 |
if argv is None: |
|
408 |
argv = sys.argv |
|
409 |
||
410 |
# Print the opening spiel including the GPL notice
|
|
411 |
||
412 |
print """IVLE - Informatics Virtual Learning Environment Setup |
|
97
by mattgiuca
Moved template.py and setup.py to better places. |
413 |
Copyright (C) 2007-2008 The University of Melbourne
|
414 |
IVLE comes with ABSOLUTELY NO WARRANTY.
|
|
415 |
This is free software, and you are welcome to redistribute it
|
|
416 |
under certain conditions. See LICENSE.txt for details.
|
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
417 |
|
418 |
IVLE Setup
|
|
419 |
"""
|
|
420 |
||
421 |
# First argument is the name of the setup operation
|
|
422 |
try: |
|
423 |
operation = argv[1] |
|
424 |
except IndexError: |
|
425 |
# Print usage message and exit
|
|
426 |
help([]) |
|
427 |
return 1 |
|
428 |
||
131
by mattgiuca
setup.py: |
429 |
# Disallow run as root unless installing
|
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
430 |
if (operation != 'install' and operation != 'updatejails' |
431 |
and os.geteuid() == 0): |
|
131
by mattgiuca
setup.py: |
432 |
print >>sys.stderr, "I do not want to run this stage as root." |
433 |
print >>sys.stderr, "Please run as a normal user." |
|
434 |
return 1 |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
435 |
# Call the requested operation's function
|
436 |
try: |
|
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
437 |
oper_func = { |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
438 |
'help' : help, |
316
by drtomc
setup.py - name the configuration command "config" to bring it into line with |
439 |
'config' : conf, |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
440 |
'build' : build, |
441 |
'listmake' : listmake, |
|
442 |
'install' : install, |
|
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
443 |
'updatejails' : updatejails, |
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
444 |
}[operation] |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
445 |
except KeyError: |
446 |
print >>sys.stderr, ( |
|
447 |
"""Invalid operation '%s'. Try python setup.py help."""
|
|
448 |
% operation) |
|
129
by mattgiuca
setup.py: Minor fix, exits cleanly if arguments are invalid. |
449 |
return 1 |
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
450 |
return oper_func(argv[2:]) |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
451 |
|
452 |
# Operation functions
|
|
453 |
||
454 |
def help(args): |
|
455 |
if args == []: |
|
456 |
print """Usage: python setup.py operation [args] |
|
457 |
Operation (and args) can be:
|
|
458 |
help [operation]
|
|
131
by mattgiuca
setup.py: |
459 |
listmake (developer use only)
|
316
by drtomc
setup.py - name the configuration command "config" to bring it into line with |
460 |
config [args]
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
461 |
build
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
462 |
install [--nojail] [--nosubjects] [-n|--dry]
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
463 |
"""
|
464 |
return 1 |
|
465 |
elif len(args) != 1: |
|
466 |
print """Usage: python setup.py help [operation]""" |
|
467 |
return 2 |
|
468 |
else: |
|
469 |
operation = args[0] |
|
470 |
||
471 |
if operation == 'help': |
|
472 |
print """python setup.py help [operation] |
|
473 |
Prints the usage message or detailed help on an operation, then exits."""
|
|
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
474 |
elif operation == 'listmake': |
475 |
print """python setup.py listmake |
|
476 |
(For developer use only)
|
|
477 |
Recurses through the source tree and builds a list of all files which should
|
|
478 |
be copied upon installation. This should be run by the developer before
|
|
479 |
cutting a distribution, and the listfile it generates should be included in
|
|
480 |
the distribution, avoiding the administrator having to run it."""
|
|
316
by drtomc
setup.py - name the configuration command "config" to bring it into line with |
481 |
elif operation == 'config': |
482 |
print """python setup.py config [args] |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
483 |
Configures IVLE with machine-specific details, most notably, various paths.
|
484 |
Either prompts the administrator for these details or accepts them as
|
|
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
485 |
command-line args. Will be interactive only if there are no arguments given.
|
486 |
Takes defaults from existing conf file if it exists.
|
|
133
by mattgiuca
setup.py: Now allows IVLE to be installed over itself, in order to allow |
487 |
|
488 |
To run IVLE out of the source directory (allowing development without having
|
|
489 |
to rebuild/install), just provide ivle_install_dir as the IVLE trunk
|
|
490 |
directory, and run build/install one time.
|
|
491 |
||
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
492 |
Creates lib/conf/conf.py and trampoline/conf.h.
|
133
by mattgiuca
setup.py: Now allows IVLE to be installed over itself, in order to allow |
493 |
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
494 |
Args are:"""
|
495 |
for opt in config_options: |
|
496 |
print " --" + opt.option_name |
|
497 |
print """As explained in the interactive prompt or conf.py. |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
498 |
"""
|
499 |
elif operation == 'build': |
|
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
500 |
print """python -O setup.py build [--dry|-n] |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
501 |
Compiles all files and sets up a jail template in the source directory.
|
116
by mattgiuca
setup.py: mkdir now properly obeys "dry". |
502 |
-O is recommended to cause compilation to be optimised.
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
503 |
Details:
|
504 |
Compiles (GCC) trampoline/trampoline.c to trampoline/trampoline.
|
|
505 |
Creates jail/.
|
|
506 |
Creates standard subdirs inside the jail, eg bin, opt, home, tmp.
|
|
507 |
Copies console/ to a location within the jail.
|
|
508 |
Copies OS programs and files to corresponding locations within the jail
|
|
509 |
(eg. python and Python libs, ld.so, etc).
|
|
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
510 |
Generates .pyc or .pyo files for all the IVLE .py files.
|
511 |
||
512 |
--dry | -n Print out the actions but don't do anything."""
|
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
513 |
elif operation == 'install': |
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
514 |
print """sudo python setup.py install [--nojail] [--nosubjects][--dry|-n] |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
515 |
(Requires root)
|
516 |
Create target install directory ($target).
|
|
517 |
Create $target/bin.
|
|
518 |
Copy trampoline/trampoline to $target/bin.
|
|
519 |
chown and chmod the installed trampoline.
|
|
520 |
Copy www/ to $target.
|
|
521 |
Copy jail/ to jails template directory (unless --nojail specified).
|
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
522 |
Copy subjects/ to subjects directory (unless --nosubjects specified).
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
523 |
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
524 |
--nojail Do not copy the jail.
|
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
525 |
--nosubjects Do not copy the subjects and exercises directories.
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
526 |
--dry | -n Print out the actions but don't do anything."""
|
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
527 |
elif operation == 'updatejails': |
528 |
print """sudo python setup.py updatejails [--dry|-n] |
|
529 |
(Requires root)
|
|
530 |
Copy jail/ to each subdirectory in jails directory.
|
|
531 |
||
532 |
--dry | -n Print out the actions but don't do anything."""
|
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
533 |
else: |
534 |
print >>sys.stderr, ( |
|
535 |
"""Invalid operation '%s'. Try python setup.py help."""
|
|
536 |
% operation) |
|
537 |
return 1 |
|
538 |
||
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
539 |
def listmake(args): |
540 |
# We build two separate lists, by walking www and console
|
|
541 |
list_www = build_list_py_files('www') |
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
542 |
list_lib = build_list_py_files('lib') |
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
543 |
list_subjects = build_list_py_files('subjects', no_top_level=True) |
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
544 |
list_exercises = build_list_py_files('exercises', no_top_level=True) |
477
by mattgiuca
setup.py: Fixed creation of "scripts" directory in listmake. |
545 |
list_scripts = [ |
546 |
"scripts/python-console", |
|
547 |
"scripts/fileservice", |
|
657
by drtomc
serve: use the trampoline to serve all files. |
548 |
"scripts/serveservice", |
477
by mattgiuca
setup.py: Fixed creation of "scripts" directory in listmake. |
549 |
"scripts/usrmgt-server", |
562
by dcoles
Added new app: Diff (SVN diff application) |
550 |
"scripts/diffservice", |
477
by mattgiuca
setup.py: Fixed creation of "scripts" directory in listmake. |
551 |
]
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
552 |
# Make sure that the files generated by conf are in the list
|
553 |
# (since listmake is typically run before conf)
|
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
554 |
if "lib/conf/conf.py" not in list_lib: |
427
by mattgiuca
setup.py: Fix (put conf.py in wrong list in listmake) |
555 |
list_lib.append("lib/conf/conf.py") |
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
556 |
# Write these out to a file
|
557 |
cwd = os.getcwd() |
|
558 |
# the files that will be created/overwritten
|
|
559 |
listfile = os.path.join(cwd, "install_list.py") |
|
560 |
||
561 |
try: |
|
562 |
file = open(listfile, "w") |
|
563 |
||
564 |
file.write("""# IVLE Configuration File |
|
565 |
# install_list.py
|
|
117
by mattgiuca
setup.py: listmake uses mimetypes to select all files with certain mime types, |
566 |
# Provides lists of all files to be installed by `setup.py install' from
|
567 |
# certain directories.
|
|
116
by mattgiuca
setup.py: mkdir now properly obeys "dry". |
568 |
# Note that any files with the given filename plus 'c' or 'o' (that is,
|
569 |
# compiled .pyc or .pyo files) will be copied as well.
|
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
570 |
|
117
by mattgiuca
setup.py: listmake uses mimetypes to select all files with certain mime types, |
571 |
# List of all installable files in www directory.
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
572 |
list_www = """) |
573 |
writelist_pretty(file, list_www) |
|
574 |
file.write(""" |
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
575 |
# List of all installable files in lib directory.
|
576 |
list_lib = """) |
|
577 |
writelist_pretty(file, list_lib) |
|
578 |
file.write(""" |
|
418
by mattgiuca
Renamed trunk/console to trunk/scripts. We are now able to put more scripts in |
579 |
# List of all installable files in scripts directory.
|
580 |
list_scripts = """) |
|
581 |
writelist_pretty(file, list_scripts) |
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
582 |
file.write(""" |
583 |
# List of all installable files in subjects directory.
|
|
584 |
# This is to install sample subjects and material.
|
|
585 |
list_subjects = """) |
|
586 |
writelist_pretty(file, list_subjects) |
|
395
by mattgiuca
Tutorial: split subjects directory into subjects and problems. |
587 |
file.write(""" |
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
588 |
# List of all installable files in exercises directory.
|
395
by mattgiuca
Tutorial: split subjects directory into subjects and problems. |
589 |
# This is to install sample exercise material.
|
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
590 |
list_exercises = """) |
591 |
writelist_pretty(file, list_exercises) |
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
592 |
|
593 |
file.close() |
|
594 |
except IOError, (errno, strerror): |
|
595 |
print "IO error(%s): %s" % (errno, strerror) |
|
596 |
sys.exit(1) |
|
597 |
||
598 |
print "Successfully wrote install_list.py" |
|
599 |
||
600 |
print
|
|
601 |
print ("You may modify the set of installable files before cutting the " |
|
602 |
"distribution:") |
|
603 |
print listfile |
|
604 |
print
|
|
605 |
||
606 |
return 0 |
|
607 |
||
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
608 |
def build_list_py_files(dir, no_top_level=False): |
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
609 |
"""Builds a list of all py files found in a directory and its
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
610 |
subdirectories. Returns this as a list of strings.
|
611 |
no_top_level=True means the file paths will not include the top-level
|
|
612 |
directory.
|
|
613 |
"""
|
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
614 |
pylist = [] |
615 |
for (dirpath, dirnames, filenames) in os.walk(dir): |
|
616 |
# Exclude directories beginning with a '.' (such as '.svn')
|
|
617 |
filter_mutate(lambda x: x[0] != '.', dirnames) |
|
618 |
# All *.py files are added to the list
|
|
619 |
pylist += [os.path.join(dirpath, item) for item in filenames |
|
117
by mattgiuca
setup.py: listmake uses mimetypes to select all files with certain mime types, |
620 |
if mimetypes.guess_type(item)[0] in listmake_mimetypes] |
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
621 |
if no_top_level: |
622 |
for i in range(0, len(pylist)): |
|
623 |
_, pylist[i] = pylist[i].split(os.sep, 1) |
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
624 |
return pylist |
625 |
||
626 |
def writelist_pretty(file, list): |
|
627 |
"""Writes a list one element per line, to a file."""
|
|
628 |
if list == []: |
|
629 |
file.write("[]\n") |
|
630 |
else: |
|
631 |
file.write('[\n') |
|
632 |
for elem in list: |
|
633 |
file.write(' %s,\n' % repr(elem)) |
|
634 |
file.write(']\n') |
|
635 |
||
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
636 |
def conf(args): |
487
by mattgiuca
setup.py: Added code to convert usrmgt_port into an int before writing to conf |
637 |
global db_port, usrmgt_port |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
638 |
# Set up some variables
|
639 |
||
640 |
cwd = os.getcwd() |
|
641 |
# the files that will be created/overwritten
|
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
642 |
conffile = os.path.join(cwd, "lib/conf/conf.py") |
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
643 |
jailconffile = os.path.join(cwd, "lib/conf/jailconf.py") |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
644 |
conf_hfile = os.path.join(cwd, "trampoline/conf.h") |
624
by dcoles
forum: Removed the subsilver2 style and phpBB installer |
645 |
phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php") |
688
by apeel
setup.py now creates the /etc/init.d script for usrmgr-server, and install_proc.txt has instructions on installing it. |
646 |
usrmgtserver_initdfile = os.path.join(cwd, "doc/setup/usrmgt-server.init") |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
647 |
|
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
648 |
# Get command-line arguments to avoid asking questions.
|
649 |
||
364
by mattgiuca
setup.py: Fixed config command-line args (forgot to make general). |
650 |
optnames = [] |
651 |
for opt in config_options: |
|
652 |
optnames.append(opt.option_name + "=") |
|
653 |
(opts, args) = getopt.gnu_getopt(args, "", optnames) |
|
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
654 |
|
655 |
if args != []: |
|
656 |
print >>sys.stderr, "Invalid arguments:", string.join(args, ' ') |
|
657 |
return 2 |
|
658 |
||
659 |
if opts == []: |
|
660 |
# Interactive mode. Prompt the user for all the values.
|
|
661 |
||
662 |
print """This tool will create the following files: |
|
100
by mattgiuca
setup.py: Added a new config variable, ivle_install_dir. |
663 |
%s |
664 |
%s |
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
665 |
%s |
671
by dcoles
forum: Now uses a unique secret generated at './setup config' time for shared secret |
666 |
%s |
688
by apeel
setup.py now creates the /etc/init.d script for usrmgr-server, and install_proc.txt has instructions on installing it. |
667 |
%s |
97
by mattgiuca
Moved template.py and setup.py to better places. |
668 |
prompting you for details about your configuration. The file will be
|
669 |
overwritten if it already exists. It will *not* install or deploy IVLE.
|
|
670 |
||
671 |
Please hit Ctrl+C now if you do not wish to do this.
|
|
688
by apeel
setup.py now creates the /etc/init.d script for usrmgr-server, and install_proc.txt has instructions on installing it. |
672 |
""" % (conffile, jailconffile, conf_hfile, phpBBconffile, usrmgtserver_initdfile) |
97
by mattgiuca
Moved template.py and setup.py to better places. |
673 |
|
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
674 |
# Get information from the administrator
|
675 |
# If EOF is encountered at any time during the questioning, just exit
|
|
676 |
# silently
|
|
97
by mattgiuca
Moved template.py and setup.py to better places. |
677 |
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
678 |
for opt in config_options: |
679 |
globals()[opt.option_name] = \ |
|
680 |
query_user(globals()[opt.option_name], opt.prompt) |
|
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
681 |
else: |
682 |
opts = dict(opts) |
|
683 |
# Non-interactive mode. Parse the options.
|
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
684 |
for opt in config_options: |
685 |
if '--' + opt.option_name in opts: |
|
686 |
globals()[opt.option_name] = opts['--' + opt.option_name] |
|
120
by mattgiuca
setup.py: Added command-line argument mode for conf. This completely works! |
687 |
|
110
by mattgiuca
setup.py: Added to trampoline/conf.h an "allowed_uids" array. Asks the user |
688 |
# Error handling on input values
|
689 |
try: |
|
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
690 |
allowed_uids_list = map(int, allowed_uids.split(',')) |
110
by mattgiuca
setup.py: Added to trampoline/conf.h an "allowed_uids" array. Asks the user |
691 |
except ValueError: |
112
by mattgiuca
setup.py: A few comment changes. |
692 |
print >>sys.stderr, ( |
693 |
"Invalid UID list (%s).\n" |
|
694 |
"Must be a comma-separated list of integers." % allowed_uids) |
|
110
by mattgiuca
setup.py: Added to trampoline/conf.h an "allowed_uids" array. Asks the user |
695 |
return 1 |
364
by mattgiuca
setup.py: Fixed config command-line args (forgot to make general). |
696 |
try: |
697 |
db_port = int(db_port) |
|
698 |
if db_port < 0 or db_port >= 65536: raise ValueError() |
|
699 |
except ValueError: |
|
700 |
print >>sys.stderr, ( |
|
701 |
"Invalid DB port (%s).\n" |
|
702 |
"Must be an integer between 0 and 65535." % repr(db_port)) |
|
703 |
return 1 |
|
487
by mattgiuca
setup.py: Added code to convert usrmgt_port into an int before writing to conf |
704 |
try: |
705 |
usrmgt_port = int(usrmgt_port) |
|
706 |
if usrmgt_port < 0 or usrmgt_port >= 65536: raise ValueError() |
|
707 |
except ValueError: |
|
708 |
print >>sys.stderr, ( |
|
709 |
"Invalid user management port (%s).\n" |
|
710 |
"Must be an integer between 0 and 65535." % repr(usrmgt_port)) |
|
711 |
return 1 |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
712 |
|
671
by dcoles
forum: Now uses a unique secret generated at './setup config' time for shared secret |
713 |
# Generate the forum secret
|
714 |
forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest() |
|
715 |
||
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
716 |
# Write lib/conf/conf.py
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
717 |
|
718 |
try: |
|
719 |
conf = open(conffile, "w") |
|
720 |
||
721 |
conf.write("""# IVLE Configuration File |
|
97
by mattgiuca
Moved template.py and setup.py to better places. |
722 |
# conf.py
|
723 |
# Miscellaneous application settings
|
|
724 |
||
358
by mattgiuca
setup.py: Gutted out the config options code. It was getting so there were |
725 |
""") |
726 |
for opt in config_options: |
|
364
by mattgiuca
setup.py: Fixed config command-line args (forgot to make general). |
727 |
conf.write('%s\n%s = %s\n' % (opt.comment, opt.option_name, |
728 |
repr(globals()[opt.option_name]))) |
|
110
by mattgiuca
setup.py: Added to trampoline/conf.h an "allowed_uids" array. Asks the user |
729 |
|
671
by dcoles
forum: Now uses a unique secret generated at './setup config' time for shared secret |
730 |
# Add the forum secret to the config file (regenerated each config)
|
731 |
conf.write('forum_secret = "%s"\n' % (forum_secret)) |
|
732 |
||
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
733 |
conf.close() |
734 |
except IOError, (errno, strerror): |
|
735 |
print "IO error(%s): %s" % (errno, strerror) |
|
736 |
sys.exit(1) |
|
737 |
||
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
738 |
print "Successfully wrote lib/conf/conf.py" |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
739 |
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
740 |
# Write conf/jailconf.py
|
741 |
||
742 |
try: |
|
743 |
conf = open(jailconffile, "w") |
|
744 |
||
745 |
# In the "in-jail" version of conf, we don't need MOST of the details
|
|
746 |
# (it would be a security risk to have them here).
|
|
747 |
# So we just write root_dir, and jail_base is "/".
|
|
748 |
# (jail_base being "/" means "jail-relative" paths are relative to "/"
|
|
749 |
# when inside the jail.)
|
|
750 |
conf.write("""# IVLE Configuration File |
|
751 |
# conf.py
|
|
752 |
# Miscellaneous application settings
|
|
753 |
# (User jail version)
|
|
754 |
||
755 |
||
756 |
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
|
|
757 |
# with this).
|
|
758 |
# eg. "/" or "/ivle".
|
|
759 |
root_dir = %s |
|
760 |
||
761 |
# In the local file system, where are the student/user file spaces located.
|
|
762 |
# The user jails are expected to be located immediately in subdirectories of
|
|
763 |
# this location.
|
|
764 |
jail_base = '/'
|
|
435
by drtomc
setup.py: Fix a couple of jail config glitches. |
765 |
|
766 |
# The hostname for serving publicly accessible pages
|
|
767 |
public_host = %s |
|
768 |
""" % (repr(root_dir),repr(public_host))) |
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
769 |
|
770 |
conf.close() |
|
771 |
except IOError, (errno, strerror): |
|
772 |
print "IO error(%s): %s" % (errno, strerror) |
|
773 |
sys.exit(1) |
|
774 |
||
775 |
print "Successfully wrote lib/conf/jailconf.py" |
|
776 |
||
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
777 |
# Write trampoline/conf.h
|
778 |
||
779 |
try: |
|
780 |
conf = open(conf_hfile, "w") |
|
781 |
||
782 |
conf.write("""/* IVLE Configuration File |
|
100
by mattgiuca
setup.py: Added a new config variable, ivle_install_dir. |
783 |
* conf.h
|
784 |
* Administrator settings required by trampoline.
|
|
785 |
* Note: trampoline will have to be rebuilt in order for changes to this file
|
|
786 |
* to take effect.
|
|
787 |
*/
|
|
788 |
||
789 |
/* In the local file system, where are the jails located.
|
|
790 |
* The trampoline does not allow the creation of a jail anywhere besides
|
|
791 |
* jail_base or a subdirectory of jail_base.
|
|
792 |
*/
|
|
793 |
static const char* jail_base = "%s"; |
|
110
by mattgiuca
setup.py: Added to trampoline/conf.h an "allowed_uids" array. Asks the user |
794 |
|
795 |
/* Which user IDs are allowed to run the trampoline.
|
|
796 |
* This list should be limited to the web server user.
|
|
797 |
* (Note that root is an implicit member of this list).
|
|
798 |
*/
|
|
112
by mattgiuca
setup.py: A few comment changes. |
799 |
static const int allowed_uids[] = { %s }; |
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
800 |
""" % (repr(jail_base)[1:-1], repr(allowed_uids_list)[1:-1])) |
801 |
# Note: The above uses PYTHON reprs, not C reprs
|
|
802 |
# However they should be the same with the exception of the outer
|
|
803 |
# characters, which are stripped off and replaced
|
|
100
by mattgiuca
setup.py: Added a new config variable, ivle_install_dir. |
804 |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
805 |
conf.close() |
806 |
except IOError, (errno, strerror): |
|
807 |
print "IO error(%s): %s" % (errno, strerror) |
|
808 |
sys.exit(1) |
|
809 |
||
810 |
print "Successfully wrote trampoline/conf.h" |
|
811 |
||
624
by dcoles
forum: Removed the subsilver2 style and phpBB installer |
812 |
# Write www/php/phpBB3/config.php
|
813 |
||
814 |
try: |
|
815 |
conf = open(phpBBconffile, "w") |
|
816 |
||
817 |
# php-pg work around
|
|
818 |
if db_host == 'localhost': |
|
819 |
forumdb_host = '127.0.0.1' |
|
820 |
else: |
|
821 |
forumdb_host = db_host |
|
822 |
||
823 |
conf.write( """<?php |
|
824 |
// phpBB 3.0.x auto-generated configuration file
|
|
825 |
// Do not change anything in this file!
|
|
826 |
$dbms = 'postgres';
|
|
827 |
$dbhost = '""" + forumdb_host + """'; |
|
828 |
$dbport = '""" + str(db_port) + """'; |
|
829 |
$dbname = '""" + db_forumdbname + """'; |
|
830 |
$dbuser = '""" + db_user + """'; |
|
831 |
$dbpasswd = '""" + db_password + """'; |
|
832 |
||
833 |
$table_prefix = 'phpbb_';
|
|
834 |
$acm_type = 'file';
|
|
835 |
$load_extensions = '';
|
|
836 |
@define('PHPBB_INSTALLED', true);
|
|
837 |
// @define('DEBUG', true);
|
|
838 |
//@define('DEBUG_EXTRA', true);
|
|
671
by dcoles
forum: Now uses a unique secret generated at './setup config' time for shared secret |
839 |
|
840 |
$forum_secret = '""" + forum_secret +"""'; |
|
624
by dcoles
forum: Removed the subsilver2 style and phpBB installer |
841 |
?>""" ) |
842 |
||
843 |
conf.close() |
|
844 |
except IOError, (errno, strerror): |
|
845 |
print "IO error(%s): %s" % (errno, strerror) |
|
846 |
sys.exit(1) |
|
847 |
||
848 |
print "Successfully wrote www/php/phpBB3/config.php" |
|
849 |
||
688
by apeel
setup.py now creates the /etc/init.d script for usrmgr-server, and install_proc.txt has instructions on installing it. |
850 |
# Write lib/conf/usrmgt-server.init
|
851 |
||
852 |
try: |
|
853 |
conf = open(usrmgtserver_initdfile, "w") |
|
854 |
||
855 |
conf.write( '''#! /bin/sh |
|
856 |
||
857 |
# Works for Ubuntu. Check before using on other distributions
|
|
858 |
||
859 |
### BEGIN INIT INFO
|
|
860 |
# Provides: usrmgt-server
|
|
861 |
# Required-Start: $syslog $networking $urandom
|
|
862 |
# Required-Stop: $syslog
|
|
863 |
# Default-Start: 2 3 4 5
|
|
864 |
# Default-Stop: 1
|
|
865 |
# Short-Description: IVLE user management server
|
|
866 |
# Description: Daemon connecting to the IVLE user management database.
|
|
867 |
### END INIT INFO
|
|
868 |
||
869 |
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
870 |
DESC="IVLE user management server"
|
|
871 |
NAME=usrmgt-server
|
|
872 |
DAEMON=/opt/ivle/scripts/$NAME
|
|
873 |
DAEMON_ARGS="''' + str(usrmgt_port) + ''' ''' + usrmgt_magic + '''" |
|
874 |
PIDFILE=/var/run/$NAME.pid
|
|
875 |
SCRIPTNAME=/etc/init.d/usrmgt-server
|
|
876 |
||
877 |
# Exit if the daemon does not exist
|
|
878 |
test -f $DAEMON || exit 0
|
|
879 |
||
880 |
# Load the VERBOSE setting and other rcS variables
|
|
881 |
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
|
882 |
||
883 |
# Define LSB log_* functions.
|
|
884 |
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
|
885 |
. /lib/lsb/init-functions
|
|
886 |
||
887 |
#
|
|
888 |
# Function that starts the daemon/service
|
|
889 |
#
|
|
890 |
do_start()
|
|
891 |
{
|
|
892 |
# Return
|
|
893 |
# 0 if daemon has been started
|
|
894 |
# 1 if daemon was already running
|
|
895 |
# 2 if daemon could not be started
|
|
896 |
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ |
|
897 |
|| return 1
|
|
898 |
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ |
|
899 |
$DAEMON_ARGS \ |
|
900 |
|| return 2
|
|
901 |
# Add code here, if necessary, that waits for the process to be ready
|
|
902 |
# to handle requests from services started subsequently which depend
|
|
903 |
# on this one. As a last resort, sleep for some time.
|
|
904 |
}
|
|
905 |
||
906 |
#
|
|
907 |
# Function that stops the daemon/service
|
|
908 |
#
|
|
909 |
do_stop()
|
|
910 |
{
|
|
911 |
# Return
|
|
912 |
# 0 if daemon has been stopped
|
|
913 |
# 1 if daemon was already stopped
|
|
914 |
# 2 if daemon could not be stopped
|
|
915 |
# other if a failure occurred
|
|
916 |
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
|
|
917 |
RETVAL="$?"
|
|
918 |
[ "$RETVAL" = 2 ] && return 2
|
|
919 |
# Wait for children to finish too if this is a daemon that forks
|
|
920 |
# and if the daemon is only ever run from this initscript.
|
|
921 |
# If the above conditions are not satisfied then add some other code
|
|
922 |
# that waits for the process to drop all resources that could be
|
|
923 |
# needed by services started subsequently. A last resort is to
|
|
924 |
# sleep for some time.
|
|
925 |
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
|
|
926 |
[ "$?" = 2 ] && return 2
|
|
927 |
# Many daemons don't delete their pidfiles when they exit.
|
|
928 |
rm -f $PIDFILE
|
|
929 |
return "$RETVAL"
|
|
930 |
}
|
|
931 |
||
932 |
#
|
|
933 |
# Function that sends a SIGHUP to the daemon/service
|
|
934 |
#
|
|
935 |
do_reload() {
|
|
936 |
#
|
|
937 |
# If the daemon can reload its configuration without
|
|
938 |
# restarting (for example, when it is sent a SIGHUP),
|
|
939 |
# then implement that here.
|
|
940 |
#
|
|
941 |
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
|
|
942 |
return 0
|
|
943 |
}
|
|
944 |
||
945 |
case "$1" in
|
|
946 |
start)
|
|
947 |
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
|
948 |
do_start
|
|
949 |
case "$?" in
|
|
950 |
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
|
951 |
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
|
952 |
esac
|
|
953 |
;;
|
|
954 |
stop)
|
|
955 |
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
|
956 |
do_stop
|
|
957 |
case "$?" in
|
|
958 |
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
|
959 |
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
|
960 |
esac
|
|
961 |
;;
|
|
962 |
#reload|force-reload)
|
|
963 |
#
|
|
964 |
# If do_reload() is not implemented then leave this commented out
|
|
965 |
# and leave 'force-reload' as an alias for 'restart'.
|
|
966 |
#
|
|
967 |
#log_daemon_msg "Reloading $DESC" "$NAME"
|
|
968 |
#do_reload
|
|
969 |
#log_end_msg $?
|
|
970 |
#;;
|
|
971 |
restart|force-reload)
|
|
972 |
#
|
|
973 |
# If the "reload" option is implemented then remove the
|
|
974 |
# 'force-reload' alias
|
|
975 |
#
|
|
976 |
log_daemon_msg "Restarting $DESC" "$NAME"
|
|
977 |
do_stop
|
|
978 |
case "$?" in
|
|
979 |
0|1)
|
|
980 |
do_start
|
|
981 |
case "$?" in
|
|
982 |
0) log_end_msg 0 ;;
|
|
983 |
1) log_end_msg 1 ;; # Old process is still running
|
|
984 |
*) log_end_msg 1 ;; # Failed to start
|
|
985 |
esac
|
|
986 |
;;
|
|
987 |
*)
|
|
988 |
# Failed to stop
|
|
989 |
log_end_msg 1
|
|
990 |
;;
|
|
991 |
esac
|
|
992 |
;;
|
|
993 |
*)
|
|
994 |
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
|
|
995 |
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
|
|
996 |
exit 3
|
|
997 |
;;
|
|
998 |
esac
|
|
999 |
||
1000 |
:
|
|
1001 |
''') |
|
1002 |
||
1003 |
conf.close() |
|
1004 |
except IOError, (errno, strerror): |
|
1005 |
print "IO error(%s): %s" % (errno, strerror) |
|
1006 |
sys.exit(1) |
|
1007 |
||
1008 |
# fix permissions as the file contains the database password
|
|
1009 |
try: |
|
1010 |
os.chmod('doc/setup/usrmgt-server.init', 0600) |
|
1011 |
except OSError, (errno, strerror): |
|
1012 |
print "WARNING: Couldn't chmod doc/setup/usrmgt-server.init:" |
|
1013 |
print "OS error(%s): %s" % (errno, strerror) |
|
1014 |
||
1015 |
print "Successfully wrote lib/conf/usrmgt-server.init" |
|
1016 |
||
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1017 |
print
|
1018 |
print "You may modify the configuration at any time by editing" |
|
1019 |
print conffile |
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1020 |
print jailconffile |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1021 |
print conf_hfile |
624
by dcoles
forum: Removed the subsilver2 style and phpBB installer |
1022 |
print phpBBconffile |
688
by apeel
setup.py now creates the /etc/init.d script for usrmgr-server, and install_proc.txt has instructions on installing it. |
1023 |
print usrmgtserver_initdfile |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1024 |
print
|
1025 |
return 0 |
|
1026 |
||
1027 |
def build(args): |
|
121
by mattgiuca
setup: build and install now read command line options |
1028 |
# Get "dry" variable from command line
|
1029 |
(opts, args) = getopt.gnu_getopt(args, "n", ['dry']) |
|
1030 |
opts = dict(opts) |
|
1031 |
dry = '-n' in opts or '--dry' in opts |
|
1032 |
||
1033 |
if dry: |
|
1034 |
print "Dry run (no actions will be executed\n" |
|
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1035 |
|
1036 |
# Compile the trampoline
|
|
349
by mattgiuca
setup.py: Changed so instead of directly calling gcc on the trampoline, calls |
1037 |
curdir = os.getcwd() |
1038 |
os.chdir('trampoline') |
|
1039 |
action_runprog('make', [], dry) |
|
1040 |
os.chdir(curdir) |
|
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1041 |
|
1042 |
# Create the jail and its subdirectories
|
|
122
by mattgiuca
setup.py: build action now copies all operating system files into the jail. |
1043 |
# Note: Other subdirs will be made by copying files
|
116
by mattgiuca
setup.py: mkdir now properly obeys "dry". |
1044 |
action_mkdir('jail', dry) |
1045 |
action_mkdir('jail/home', dry) |
|
1046 |
action_mkdir('jail/tmp', dry) |
|
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1047 |
|
547
by dcoles
settup.py: Added nss libaries and /etc files needed for resolving hostnames. |
1048 |
# Chmod the tmp directory to world writable
|
1049 |
action_chmod_w('jail/tmp', dry) |
|
1050 |
||
122
by mattgiuca
setup.py: build action now copies all operating system files into the jail. |
1051 |
# Copy all console and operating system files into the jail
|
418
by mattgiuca
Renamed trunk/console to trunk/scripts. We are now able to put more scripts in |
1052 |
action_copylist(install_list.list_scripts, 'jail/opt/ivle', dry) |
122
by mattgiuca
setup.py: build action now copies all operating system files into the jail. |
1053 |
copy_os_files_jail(dry) |
253
by mattgiuca
setup.py: chmods python-console when building. |
1054 |
# Chmod the python console
|
418
by mattgiuca
Renamed trunk/console to trunk/scripts. We are now able to put more scripts in |
1055 |
action_chmod_x('jail/opt/ivle/scripts/python-console', dry) |
1056 |
action_chmod_x('jail/opt/ivle/scripts/fileservice', dry) |
|
657
by drtomc
serve: use the trampoline to serve all files. |
1057 |
action_chmod_x('jail/opt/ivle/scripts/serveservice', dry) |
253
by mattgiuca
setup.py: chmods python-console when building. |
1058 |
|
422
by mattgiuca
setup.py: Needs to copy the "lib" directory into the jail. Now does this and |
1059 |
# Also copy the IVLE lib directory into the jail
|
1060 |
# This is necessary for running certain scripts
|
|
1061 |
action_copylist(install_list.list_lib, 'jail/opt/ivle', dry) |
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1062 |
# IMPORTANT: The file jail/opt/ivle/lib/conf/conf.py contains details
|
1063 |
# which could compromise security if left in the jail (such as the DB
|
|
1064 |
# password).
|
|
1065 |
# The "safe" version is in jailconf.py. Delete conf.py and replace it with
|
|
1066 |
# jailconf.py.
|
|
435
by drtomc
setup.py: Fix a couple of jail config glitches. |
1067 |
action_copyfile('lib/conf/jailconf.py', |
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1068 |
'jail/opt/ivle/lib/conf/conf.py', dry) |
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1069 |
|
116
by mattgiuca
setup.py: mkdir now properly obeys "dry". |
1070 |
# Compile .py files into .pyc or .pyo files
|
1071 |
compileall.compile_dir('www', quiet=True) |
|
422
by mattgiuca
setup.py: Needs to copy the "lib" directory into the jail. Now does this and |
1072 |
compileall.compile_dir('lib', quiet=True) |
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1073 |
compileall.compile_dir('scripts', quiet=True) |
422
by mattgiuca
setup.py: Needs to copy the "lib" directory into the jail. Now does this and |
1074 |
compileall.compile_dir('jail/opt/ivle/lib', quiet=True) |
1075 |
||
1076 |
# Set up ivle.pth inside the jail
|
|
1077 |
# Need to set /opt/ivle/lib to be on the import path
|
|
1078 |
ivle_pth = \ |
|
1079 |
"jail/usr/lib/python%s/site-packages/ivle.pth" % PYTHON_VERSION |
|
1080 |
f = open(ivle_pth, 'w') |
|
1081 |
f.write('/opt/ivle/lib\n') |
|
1082 |
f.close() |
|
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1083 |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1084 |
return 0 |
1085 |
||
122
by mattgiuca
setup.py: build action now copies all operating system files into the jail. |
1086 |
def copy_os_files_jail(dry): |
1087 |
"""Copies necessary Operating System files from their usual locations
|
|
1088 |
into the jail/ directory of the cwd."""
|
|
1089 |
# Currently source paths are configured for Ubuntu.
|
|
251
by mattgiuca
setup.py: Worked the "files to copy into jail" out into a separate list |
1090 |
for filename in JAIL_FILES: |
1091 |
copy_file_to_jail(filename, dry) |
|
1092 |
for src, dst in JAIL_LINKS.items(): |
|
1093 |
action_symlink(src, dst, dry) |
|
1094 |
for src, dst in JAIL_COPYTREES.items(): |
|
1095 |
action_copytree(src, dst, dry) |
|
122
by mattgiuca
setup.py: build action now copies all operating system files into the jail. |
1096 |
|
1097 |
def copy_file_to_jail(src, dry): |
|
1098 |
"""Copies a single file from an absolute location into the same location
|
|
1099 |
within the jail. src must begin with a '/'. The jail will be located
|
|
1100 |
in a 'jail' subdirectory of the current path."""
|
|
1101 |
action_copyfile(src, 'jail' + src, dry) |
|
1102 |
||
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1103 |
def install(args): |
121
by mattgiuca
setup: build and install now read command line options |
1104 |
# Get "dry" and "nojail" variables from command line
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
1105 |
(opts, args) = getopt.gnu_getopt(args, "n", |
1106 |
['dry', 'nojail', 'nosubjects']) |
|
121
by mattgiuca
setup: build and install now read command line options |
1107 |
opts = dict(opts) |
1108 |
dry = '-n' in opts or '--dry' in opts |
|
1109 |
nojail = '--nojail' in opts |
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
1110 |
nosubjects = '--nosubjects' in opts |
121
by mattgiuca
setup: build and install now read command line options |
1111 |
|
1112 |
if dry: |
|
1113 |
print "Dry run (no actions will be executed\n" |
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
1114 |
|
1115 |
if not dry and os.geteuid() != 0: |
|
1116 |
print >>sys.stderr, "Must be root to run install" |
|
1117 |
print >>sys.stderr, "(I need to chown some files)." |
|
1118 |
return 1 |
|
1119 |
||
1120 |
# Create the target (install) directory
|
|
1121 |
action_mkdir(ivle_install_dir, dry) |
|
1122 |
||
1123 |
# Create bin and copy the compiled files there
|
|
1124 |
action_mkdir(os.path.join(ivle_install_dir, 'bin'), dry) |
|
1125 |
tramppath = os.path.join(ivle_install_dir, 'bin/trampoline') |
|
1126 |
action_copyfile('trampoline/trampoline', tramppath, dry) |
|
1127 |
# chown trampoline to root and set setuid bit
|
|
1128 |
action_chown_setuid(tramppath, dry) |
|
1129 |
||
528
by drtomc
usrmgt-server: robustify svn url handling a bit. |
1130 |
# Create a scripts directory to put the usrmgt-server in.
|
1131 |
action_mkdir(os.path.join(ivle_install_dir, 'scripts'), dry) |
|
1132 |
usrmgtpath = os.path.join(ivle_install_dir, 'scripts/usrmgt-server') |
|
1133 |
action_copyfile('scripts/usrmgt-server', usrmgtpath, dry) |
|
1134 |
action_chmod_x(usrmgtpath, dry) |
|
1135 |
||
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
1136 |
# Copy the www and lib directories using the list
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
1137 |
action_copylist(install_list.list_www, ivle_install_dir, dry) |
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
1138 |
action_copylist(install_list.list_lib, ivle_install_dir, dry) |
524
by dcoles
forum: Changed setup to just copy the phpBB directory (probbaly can be made |
1139 |
|
1140 |
# Copy the php directory
|
|
681
by dcoles
setup.py: chown the phpBB3 directory to www-data for correct permissions |
1141 |
forum_dir = "www/php/phpBB3" |
1142 |
forum_path = os.path.join(ivle_install_dir, forum_dir) |
|
1143 |
action_copytree(forum_dir, forum_path, dry) |
|
1144 |
print "chown -R www-data:www-data %s" % forum_path |
|
1145 |
if not dry: |
|
1146 |
os.system("chown -R www-data:www-data %s" % forum_path) |
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
1147 |
|
1148 |
if not nojail: |
|
1149 |
# Copy the local jail directory built by the build action
|
|
1150 |
# to the jails template directory (it will be used as a template
|
|
1151 |
# for all the students' jails).
|
|
1152 |
action_copytree('jail', os.path.join(jail_base, 'template'), dry) |
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
1153 |
if not nosubjects: |
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
1154 |
# Copy the subjects and exercises directories across
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
1155 |
action_copylist(install_list.list_subjects, subjects_base, dry, |
1156 |
srcdir="./subjects") |
|
515
by stevenbird
Propagated "problem" -> "exercise" nomenclature change. |
1157 |
action_copylist(install_list.list_exercises, exercises_base, dry, |
1158 |
srcdir="./exercises") |
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
1159 |
|
256
by mattgiuca
Changed the way IVLE's path is loaded into Python's sys.path. Now a file |
1160 |
# Append IVLE path to ivle.pth in python site packages
|
1161 |
# (Unless it's already there)
|
|
1162 |
ivle_pth = os.path.join(sys.prefix, |
|
317
by mattgiuca
doc/dependencies: Added dependency on matplotlib. |
1163 |
"lib/python%s/site-packages/ivle.pth" % PYTHON_VERSION) |
256
by mattgiuca
Changed the way IVLE's path is loaded into Python's sys.path. Now a file |
1164 |
ivle_www = os.path.join(ivle_install_dir, "www") |
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
1165 |
ivle_lib = os.path.join(ivle_install_dir, "lib") |
256
by mattgiuca
Changed the way IVLE's path is loaded into Python's sys.path. Now a file |
1166 |
write_ivle_pth = True |
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
1167 |
write_ivle_lib_pth = True |
256
by mattgiuca
Changed the way IVLE's path is loaded into Python's sys.path. Now a file |
1168 |
try: |
1169 |
file = open(ivle_pth, 'r') |
|
1170 |
for line in file: |
|
1171 |
if line.strip() == ivle_www: |
|
1172 |
write_ivle_pth = False |
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
1173 |
elif line.strip() == ivle_lib: |
1174 |
write_ivle_lib_pth = False |
|
1175 |
file.close() |
|
256
by mattgiuca
Changed the way IVLE's path is loaded into Python's sys.path. Now a file |
1176 |
except (IOError, OSError): |
1177 |
pass
|
|
1178 |
if write_ivle_pth: |
|
1179 |
action_append(ivle_pth, ivle_www) |
|
409
by mattgiuca
Moved www/conf and www/common to a new directory lib. This separates the "web" |
1180 |
if write_ivle_lib_pth: |
1181 |
action_append(ivle_pth, ivle_lib) |
|
256
by mattgiuca
Changed the way IVLE's path is loaded into Python's sys.path. Now a file |
1182 |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1183 |
return 0 |
1184 |
||
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
1185 |
def updatejails(args): |
1186 |
# Get "dry" variable from command line
|
|
1187 |
(opts, args) = getopt.gnu_getopt(args, "n", ['dry']) |
|
1188 |
opts = dict(opts) |
|
1189 |
dry = '-n' in opts or '--dry' in opts |
|
1190 |
||
1191 |
if dry: |
|
1192 |
print "Dry run (no actions will be executed\n" |
|
1193 |
||
1194 |
if not dry and os.geteuid() != 0: |
|
1195 |
print >>sys.stderr, "Must be root to run install" |
|
1196 |
print >>sys.stderr, "(I need to chown some files)." |
|
1197 |
return 1 |
|
1198 |
||
1199 |
# Update the template jail directory in case it hasn't been installed
|
|
1200 |
# recently.
|
|
1201 |
action_copytree('jail', os.path.join(jail_base, 'template'), dry) |
|
1202 |
||
1203 |
# Re-link all the files in all students jails.
|
|
1204 |
for dir in os.listdir(jail_base): |
|
1205 |
if dir == 'template': continue |
|
1206 |
# First back up the student's home directory
|
|
1207 |
temp_home = os.tmpnam() |
|
1208 |
action_rename(os.path.join(jail_base, dir, 'home'), temp_home, dry) |
|
1209 |
# Delete the student's jail and relink the jail files
|
|
1210 |
action_linktree(os.path.join(jail_base, 'template'), |
|
1211 |
os.path.join(jail_base, dir), dry) |
|
1212 |
# Restore the student's home directory
|
|
1213 |
action_rename(temp_home, os.path.join(jail_base, dir, 'home'), dry) |
|
1214 |
# Set up the user's home directory just in case they don't have a
|
|
1215 |
# directory for this yet
|
|
1216 |
action_mkdir(os.path.join(jail_base, dir, 'home', dir), dry) |
|
1217 |
||
1218 |
return 0 |
|
1219 |
||
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1220 |
# The actions call Python os functions but print actions and handle dryness.
|
1221 |
# May still throw os exceptions if errors occur.
|
|
1222 |
||
108
by mattgiuca
setup.py: Added RunError class. action_runprog now throws a RunError if the |
1223 |
class RunError: |
1224 |
"""Represents an error when running a program (nonzero return)."""
|
|
1225 |
def __init__(self, prog, retcode): |
|
1226 |
self.prog = prog |
|
1227 |
self.retcode = retcode |
|
1228 |
def __str__(self): |
|
1229 |
return str(self.prog) + " returned " + repr(self.retcode) |
|
1230 |
||
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1231 |
def action_runprog(prog, args, dry): |
1232 |
"""Runs a unix program. Searches in $PATH. Synchronous (waits for the
|
|
1233 |
program to return). Runs in the current environment. First prints the
|
|
1234 |
action as a "bash" line.
|
|
1235 |
||
108
by mattgiuca
setup.py: Added RunError class. action_runprog now throws a RunError if the |
1236 |
Throws a RunError with a retcode of the return value of the program,
|
1237 |
if the program did not return 0.
|
|
1238 |
||
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1239 |
prog: String. Name of the program. (No path required, if in $PATH).
|
1240 |
args: [String]. Arguments to the program.
|
|
1241 |
dry: Bool. If True, prints but does not execute.
|
|
1242 |
"""
|
|
1243 |
print prog, string.join(args, ' ') |
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
1244 |
if dry: return |
1245 |
ret = os.spawnvp(os.P_WAIT, prog, args) |
|
1246 |
if ret != 0: |
|
1247 |
raise RunError(prog, ret) |
|
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1248 |
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1249 |
def action_remove(path, dry): |
1250 |
"""Calls rmtree, deleting the target file if it exists."""
|
|
434
by drtomc
setup.py: add a bunch of shared objects to be added to the jail for svn. |
1251 |
try: |
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1252 |
print "rm -r", path |
1253 |
if not dry: |
|
1254 |
shutil.rmtree(path, True) |
|
434
by drtomc
setup.py: add a bunch of shared objects to be added to the jail for svn. |
1255 |
except OSError, (err, msg): |
1256 |
if err != errno.EEXIST: |
|
1257 |
raise
|
|
1258 |
# Otherwise, didn't exist, so we don't care
|
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1259 |
|
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
1260 |
def action_rename(src, dst, dry): |
1261 |
"""Calls rename. Deletes the target if it already exists."""
|
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1262 |
action_remove(dst, dry) |
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
1263 |
print "mv ", src, dst |
1264 |
if dry: return |
|
1265 |
try: |
|
1266 |
os.rename(src, dst) |
|
1267 |
except OSError, (err, msg): |
|
1268 |
if err != errno.EEXIST: |
|
1269 |
raise
|
|
1270 |
||
116
by mattgiuca
setup.py: mkdir now properly obeys "dry". |
1271 |
def action_mkdir(path, dry): |
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
1272 |
"""Calls mkdir. Silently ignored if the directory already exists.
|
1273 |
Creates all parent directories as necessary."""
|
|
1274 |
print "mkdir -p", path |
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
1275 |
if dry: return |
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1276 |
try: |
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
1277 |
os.makedirs(path) |
107
by mattgiuca
setup.py: Added "action" functions which encapsulate calling OS functions. |
1278 |
except OSError, (err, msg): |
1279 |
if err != errno.EEXIST: |
|
1280 |
raise
|
|
1281 |
||
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1282 |
def action_copytree(src, dst, dry): |
1283 |
"""Copies an entire directory tree. Symlinks are seen as normal files and
|
|
1284 |
copies of the entire file (not the link) are made. Creates all parent
|
|
1285 |
directories as necessary.
|
|
1286 |
||
1287 |
See shutil.copytree."""
|
|
529
by mattgiuca
setup.py: Fixed copytree; now able to handle copying a directory over itself |
1288 |
# Allow copying over itself
|
1289 |
if (os.path.normpath(os.path.join(os.getcwd(),src)) == |
|
1290 |
os.path.normpath(os.path.join(os.getcwd(),dst))): |
|
1291 |
return
|
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1292 |
action_remove(dst, dry) |
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1293 |
print "cp -r", src, dst |
1294 |
if dry: return |
|
132
by mattgiuca
setup.py: File copying is more robust - preserves symlinks and permissions |
1295 |
shutil.copytree(src, dst, True) |
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1296 |
|
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
1297 |
def action_linktree(src, dst, dry): |
1298 |
"""Hard-links an entire directory tree. Same as copytree but the created
|
|
1299 |
files are hard-links not actual copies. Removes the existing destination.
|
|
1300 |
"""
|
|
433
by mattgiuca
setup.py: Conf now writes another file, lib/conf/jailconf.py. This file is a |
1301 |
action_remove(dst, dry) |
252
by mattgiuca
setup.py: Added action "updatejails" which wipes all student jails, replacing |
1302 |
print "<cp with hardlinks> -r", src, dst |
1303 |
if dry: return |
|
1304 |
common.makeuser.linktree(src, dst) |
|
1305 |
||
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
1306 |
def action_copylist(srclist, dst, dry, srcdir="."): |
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1307 |
"""Copies all files in a list to a new location. The files in the list
|
1308 |
are read relative to the current directory, and their destinations are the
|
|
1309 |
same paths relative to dst. Creates all parent directories as necessary.
|
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
1310 |
srcdir is "." by default, can be overridden.
|
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1311 |
"""
|
1312 |
for srcfile in srclist: |
|
1313 |
dstfile = os.path.join(dst, srcfile) |
|
313
by mattgiuca
test/test_framework: Updated examples, a bit of better descriptions, sample |
1314 |
srcfile = os.path.join(srcdir, srcfile) |
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1315 |
dstdir = os.path.split(dstfile)[0] |
1316 |
if not os.path.isdir(dstdir): |
|
1317 |
action_mkdir(dstdir, dry) |
|
1318 |
print "cp -f", srcfile, dstfile |
|
1319 |
if not dry: |
|
133
by mattgiuca
setup.py: Now allows IVLE to be installed over itself, in order to allow |
1320 |
try: |
1321 |
shutil.copyfile(srcfile, dstfile) |
|
1322 |
shutil.copymode(srcfile, dstfile) |
|
1323 |
except shutil.Error: |
|
1324 |
pass
|
|
118
by mattgiuca
setup.py: Added copytree and copylist actions. |
1325 |
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
1326 |
def action_copyfile(src, dst, dry): |
1327 |
"""Copies one file to a new location. Creates all parent directories
|
|
1328 |
as necessary.
|
|
318
by mattgiuca
setup.py: action_copyfile now handles errors as warnings, instead of quitting |
1329 |
Warn if file not found.
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
1330 |
"""
|
1331 |
dstdir = os.path.split(dst)[0] |
|
1332 |
if not os.path.isdir(dstdir): |
|
1333 |
action_mkdir(dstdir, dry) |
|
1334 |
print "cp -f", src, dst |
|
1335 |
if not dry: |
|
133
by mattgiuca
setup.py: Now allows IVLE to be installed over itself, in order to allow |
1336 |
try: |
1337 |
shutil.copyfile(src, dst) |
|
1338 |
shutil.copymode(src, dst) |
|
318
by mattgiuca
setup.py: action_copyfile now handles errors as warnings, instead of quitting |
1339 |
except (shutil.Error, IOError), e: |
1340 |
print "Warning: " + str(e) |
|
119
by mattgiuca
setup.py: Added install action. Completely works! |
1341 |
|
122
by mattgiuca
setup.py: build action now copies all operating system files into the jail. |
1342 |
def action_symlink(src, dst, dry): |
1343 |
"""Creates a symlink in a given location. Creates all parent directories
|
|
1344 |
as necessary.
|
|
1345 |
"""
|
|
1346 |
dstdir = os.path.split(dst)[0] |
|
1347 |
if not os.path.isdir(dstdir): |
|
1348 |
action_mkdir(dstdir, dry) |
|
131
by mattgiuca
setup.py: |
1349 |
# Delete existing file
|
1350 |
if os.path.exists(dst): |
|
1351 |
os.remove(dst) |
|
1352 |
print "ln -fs", src, dst |
|
122
by mattgiuca
setup.py: build action now copies all operating system files into the jail. |
1353 |
if not dry: |
1354 |
os.symlink(src, dst) |
|
1355 |
||
256
by mattgiuca
Changed the way IVLE's path is loaded into Python's sys.path. Now a file |
1356 |
def action_append(ivle_pth, ivle_www): |
1357 |
file = open(ivle_pth, 'a+') |
|
1358 |
file.write(ivle_www + '\n') |
|
1359 |
file.close() |
|
1360 |
||
119
by mattgiuca
setup.py: Added install action. Completely works! |
1361 |
def action_chown_setuid(file, dry): |
1362 |
"""Chowns a file to root, and sets the setuid bit on the file.
|
|
1363 |
Calling this function requires the euid to be root.
|
|
1364 |
The actual mode of path is set to: rws--s--s
|
|
1365 |
"""
|
|
1366 |
print "chown root:root", file |
|
1367 |
if not dry: |
|
1368 |
os.chown(file, 0, 0) |
|
1369 |
print "chmod a+xs", file |
|
1370 |
print "chmod u+rw", file |
|
1371 |
if not dry: |
|
1372 |
os.chmod(file, stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
|
1373 |
| stat.S_ISUID | stat.S_IRUSR | stat.S_IWUSR) |
|
1374 |
||
253
by mattgiuca
setup.py: chmods python-console when building. |
1375 |
def action_chmod_x(file, dry): |
371
by mattgiuca
setup.py: Fixed chmodding python-console. (Turns out this was a bug in setup, |
1376 |
"""Chmod 755 a file (sets permissions to rwxr-xr-x)."""
|
1377 |
print "chmod 755", file |
|
253
by mattgiuca
setup.py: chmods python-console when building. |
1378 |
if not dry: |
371
by mattgiuca
setup.py: Fixed chmodding python-console. (Turns out this was a bug in setup, |
1379 |
os.chmod(file, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR |
1380 |
| stat.S_IXGRP | stat.S_IRGRP | stat.S_IXOTH | stat.S_IROTH) |
|
253
by mattgiuca
setup.py: chmods python-console when building. |
1381 |
|
547
by dcoles
settup.py: Added nss libaries and /etc files needed for resolving hostnames. |
1382 |
|
1383 |
def action_chmod_w(file, dry): |
|
1384 |
"""Chmod 777 a file (sets permissions to rwxrwxrwx)."""
|
|
1385 |
print "chmod 777", file |
|
1386 |
if not dry: |
|
1387 |
os.chmod(file, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR |
|
1388 |
| stat.S_IXGRP | stat.S_IWGRP | stat.S_IRGRP | stat.S_IXOTH |
|
1389 |
| stat.S_IWOTH | stat.S_IROTH) |
|
1390 |
||
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
1391 |
def query_user(default, prompt): |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1392 |
"""Prompts the user for a string, which is read from a line of stdin.
|
1393 |
Exits silently if EOF is encountered. Returns the string, with spaces
|
|
1394 |
removed from the beginning and end.
|
|
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
1395 |
|
1396 |
Returns default if a 0-length line (after spaces removed) was read.
|
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1397 |
"""
|
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
1398 |
sys.stdout.write('%s\n (default: "%s")\n>' % (prompt, default)) |
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1399 |
try: |
1400 |
val = sys.stdin.readline() |
|
1401 |
except KeyboardInterrupt: |
|
1402 |
# Ctrl+C
|
|
1403 |
sys.stdout.write("\n") |
|
1404 |
sys.exit(1) |
|
1405 |
sys.stdout.write("\n") |
|
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
1406 |
# If EOF, exit
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1407 |
if val == '': sys.exit(1) |
113
by mattgiuca
setup.py: Now loads defaults, if possible, from the existing conf.py. |
1408 |
# If empty line, return default
|
1409 |
val = val.strip() |
|
1410 |
if val == '': return default |
|
1411 |
return val |
|
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1412 |
|
114
by mattgiuca
setup.py: Wrote listmake (and ancillary functions). |
1413 |
def filter_mutate(function, list): |
1414 |
"""Like built-in filter, but mutates the given list instead of returning a
|
|
1415 |
new one. Returns None."""
|
|
1416 |
i = len(list)-1 |
|
1417 |
while i >= 0: |
|
1418 |
# Delete elements which do not match
|
|
1419 |
if not function(list[i]): |
|
1420 |
del list[i] |
|
1421 |
i -= 1 |
|
1422 |
||
104
by mattgiuca
setup.py: Replaced the simple script with a full options processing script |
1423 |
if __name__ == "__main__": |
1424 |
sys.exit(main()) |