101
104
# Needed by python
102
105
'/usr/bin/python%s' % PYTHON_VERSION,
106
# Needed by fileservice
107
'/lib/libcom_err.so.2',
108
'/lib/libcrypt.so.1',
109
'/lib/libkeyutils.so.1',
110
'/lib/libresolv.so.2',
113
'/usr/lib/libapr-1.so.0',
114
'/usr/lib/libaprutil-1.so.0',
115
'/usr/lib/libapt-pkg-libc6.6-6.so.4.5',
116
'/usr/lib/libdb-4.6.so',
117
'/usr/lib/libexpat.so.1',
118
'/usr/lib/libgcrypt.so.11',
119
'/usr/lib/libgnutls.so.13',
120
'/usr/lib/libgpg-error.so.0',
121
'/usr/lib/libgssapi_krb5.so.2',
122
'/usr/lib/libk5crypto.so.3',
123
'/usr/lib/libkrb5.so.3',
124
'/usr/lib/libkrb5support.so.0',
125
'/usr/lib/liblber.so.2',
126
'/usr/lib/liblber-2.4.so.2',
127
'/usr/lib/libldap_r.so.2',
128
'/usr/lib/libldap_r-2.4.so.2',
129
'/usr/lib/libneon.so.27',
130
'/usr/lib/libpq.so.5',
131
'/usr/lib/libsasl2.so.2',
132
'/usr/lib/libsqlite3.so.0',
133
'/usr/lib/libsvn_client-1.so.1',
134
'/usr/lib/libsvn_delta-1.so.1',
135
'/usr/lib/libsvn_diff-1.so.1',
136
'/usr/lib/libsvn_fs-1.so.1',
137
'/usr/lib/libsvn_fs_base-1.so.1',
138
'/usr/lib/libsvn_fs_fs-1.so.1',
139
'/usr/lib/libsvn_ra-1.so.1',
140
'/usr/lib/libsvn_ra_dav-1.so.1',
141
'/usr/lib/libsvn_ra_local-1.so.1',
142
'/usr/lib/libsvn_ra_svn-1.so.1',
143
'/usr/lib/libsvn_repos-1.so.1',
144
'/usr/lib/libsvn_subr-1.so.1',
145
'/usr/lib/libsvn_wc-1.so.1',
146
'/usr/lib/libtasn1.so.3',
147
'/usr/lib/libxml2.so.2',
103
148
# Needed by matplotlib
104
149
'/usr/lib/i686/cmov/libssl.so.0.9.8',
105
150
'/usr/lib/i686/cmov/libcrypto.so.0.9.8',
179
247
# In the local file system, where are the per-subject file spaces located.
180
248
# The individual subject directories are expected to be located immediately
181
249
# in subdirectories of this location."""))
250
config_options.append(ConfigOption("exercises_base",
251
"/home/informatics/exercises",
252
"""Root directory where the exercise directories (containing
253
subject-independent exercise sheets) are stored (on the local file
256
# In the local file system, where are the subject-independent exercise sheet
257
# file spaces located."""))
258
config_options.append(ConfigOption("tos_path",
259
"/home/informatics/tos.html",
260
"""Location where the Terms of Service document is stored (on the local
263
# In the local file system, where is the Terms of Service document located."""))
264
config_options.append(ConfigOption("motd_path",
265
"/home/informatics/motd.html",
266
"""Location where the Message of the Day document is stored (on the local
269
# In the local file system, where is the Message of the Day document
270
# located. This is an HTML file (just the body fragment), which will
271
# be displayed on the login page. It is optional."""))
182
272
config_options.append(ConfigOption("public_host", "public.localhost",
183
273
"""Hostname which will cause the server to go into "public mode",
184
274
providing login-free access to student's published work:""",
214
304
"""Database name:""",
216
306
# Database name"""))
307
config_options.append(ConfigOption("db_forumdbname", "ivle_forum",
308
"""Forum Database name:""",
310
# Forum Database name"""))
217
311
config_options.append(ConfigOption("db_user", "postgres",
218
312
"""Username for DB server login:""",
220
314
# Database username"""))
221
315
config_options.append(ConfigOption("db_password", "",
222
316
"""Password for DB server login:
223
(Caution: This password is stored in plaintext in www/conf/conf.py)""",
317
(Caution: This password is stored in plaintext in lib/conf/conf.py)""",
225
319
# Database password"""))
320
config_options.append(ConfigOption("auth_modules", "ldap_auth",
321
"""Authentication config
322
=====================
323
Comma-separated list of authentication modules. Only "ldap" is available
326
# Comma-separated list of authentication modules.
327
# These refer to importable Python modules in the www/auth directory.
328
# Modules "ldap" and "guest" are available in the source tree, but
329
# other modules may be plugged in to auth against organisation-specific
330
# auth backends."""))
331
config_options.append(ConfigOption("ldap_url", "ldaps://www.example.com",
332
"""(LDAP options are only relevant if "ldap" is included in the list of
334
URL for LDAP authentication server:""",
336
# URL for LDAP authentication server"""))
337
config_options.append(ConfigOption("ldap_format_string",
338
"uid=%s,ou=users,o=example",
339
"""Format string for LDAP auth request:
340
(Must contain a single "%s" for the user's login name)""",
342
# Format string for LDAP auth request
343
# (Must contain a single "%s" for the user's login name)"""))
344
config_options.append(ConfigOption("svn_addr", "http://svn.localhost/",
347
The base url for accessing subversion repositories:""",
349
# The base url for accessing subversion repositories."""))
350
config_options.append(ConfigOption("svn_conf", "/opt/ivle/svn/svn.conf",
351
"""The location of the subversion configuration file used by apache
352
to host the user repositories:""",
354
# The location of the subversion configuration file used by
355
# apache to host the user repositories."""))
356
config_options.append(ConfigOption("svn_repo_path", "/home/informatics/repositories",
357
"""The root directory for the subversion repositories:""",
359
# The root directory for the subversion repositories."""))
360
config_options.append(ConfigOption("svn_auth_ivle", "/opt/ivle/svn/ivle.auth",
361
"""The location of the password file used to authenticate users
362
of the subversion repository from the ivle server:""",
364
# The location of the password file used to authenticate users
365
# of the subversion repository from the ivle server."""))
366
config_options.append(ConfigOption("svn_auth_local", "/opt/ivle/svn/local.auth",
367
"""The location of the password file used to authenticate local users
368
of the subversion repository:""",
370
# The location of the password file used to authenticate local users
371
# of the subversion repository."""))
372
config_options.append(ConfigOption("usrmgt_host", "localhost",
373
"""User Management Server config
374
============================
375
The hostname where the usrmgt-server runs:""",
377
# The hostname where the usrmgt-server runs."""))
378
config_options.append(ConfigOption("usrmgt_port", "2178",
379
"""The port where the usrmgt-server runs:""",
381
# The port where the usrmgt-server runs."""))
382
config_options.append(ConfigOption("usrmgt_magic", "",
383
"""The password for the usrmgt-server:""",
385
# The password for the usrmgt-server."""))
227
387
# Try importing existing conf, but if we can't just set up defaults
228
388
# The reason for this is that these settings are used by other phases
229
389
# of setup besides conf, so we need to know them.
230
390
# Also this allows you to hit Return to accept the existing value.
232
confmodule = __import__("www/conf/conf")
392
confmodule = __import__("lib/conf/conf")
233
393
for opt in config_options:
235
395
globals()[opt.option_name] = confmodule.__dict__[opt.option_name]
394
554
def listmake(args):
395
555
# We build two separate lists, by walking www and console
396
556
list_www = build_list_py_files('www')
397
list_console = build_list_py_files('console')
557
list_lib = build_list_py_files('lib')
398
558
list_subjects = build_list_py_files('subjects', no_top_level=True)
559
list_exercises = build_list_py_files('exercises', no_top_level=True)
561
"scripts/python-console",
562
"scripts/fileservice",
563
"scripts/serveservice",
564
"scripts/usrmgt-server",
565
"scripts/diffservice",
399
567
# Make sure that the files generated by conf are in the list
400
568
# (since listmake is typically run before conf)
401
if "www/conf/conf.py" not in list_www:
402
list_www.append("www/conf/conf.py")
403
# Make sure that console/python-console is in the list
404
if "console/python-console" not in list_console:
405
list_console.append("console/python-console")
569
if "lib/conf/conf.py" not in list_lib:
570
list_lib.append("lib/conf/conf.py")
406
571
# Write these out to a file
407
572
cwd = os.getcwd()
408
573
# the files that will be created/overwritten
551
742
conf.write('%s\n%s = %s\n' % (opt.comment, opt.option_name,
552
743
repr(globals()[opt.option_name])))
555
except IOError, (errno, strerror):
556
print "IO error(%s): %s" % (errno, strerror)
559
print "Successfully wrote www/conf/conf.py"
745
# Add the forum secret to the config file (regenerated each config)
746
conf.write('forum_secret = "%s"\n' % (forum_secret))
749
except IOError, (errno, strerror):
750
print "IO error(%s): %s" % (errno, strerror)
753
print "Successfully wrote lib/conf/conf.py"
755
# Write conf/jailconf.py
758
conf = open(jailconffile, "w")
760
# In the "in-jail" version of conf, we don't need MOST of the details
761
# (it would be a security risk to have them here).
762
# So we just write root_dir, and jail_base is "/".
763
# (jail_base being "/" means "jail-relative" paths are relative to "/"
764
# when inside the jail.)
765
conf.write("""# IVLE Configuration File
767
# Miscellaneous application settings
768
# (User jail version)
771
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
773
# eg. "/" or "/ivle".
776
# In the local file system, where are the student/user file spaces located.
777
# The user jails are expected to be located immediately in subdirectories of
781
# The hostname for serving publicly accessible pages
783
""" % (repr(root_dir),repr(public_host)))
786
except IOError, (errno, strerror):
787
print "IO error(%s): %s" % (errno, strerror)
790
print "Successfully wrote lib/conf/jailconf.py"
561
792
# Write trampoline/conf.h
591
825
print "Successfully wrote trampoline/conf.h"
827
# Write www/php/phpBB3/config.php
830
conf = open(phpBBconffile, "w")
833
if db_host == 'localhost':
834
forumdb_host = '127.0.0.1'
836
forumdb_host = db_host
839
// phpBB 3.0.x auto-generated configuration file
840
// Do not change anything in this file!
842
$dbhost = '""" + forumdb_host + """';
843
$dbport = '""" + str(db_port) + """';
844
$dbname = '""" + db_forumdbname + """';
845
$dbuser = '""" + db_user + """';
846
$dbpasswd = '""" + db_password + """';
848
$table_prefix = 'phpbb_';
850
$load_extensions = '';
851
@define('PHPBB_INSTALLED', true);
852
// @define('DEBUG', true);
853
//@define('DEBUG_EXTRA', true);
855
$forum_secret = '""" + forum_secret +"""';
859
except IOError, (errno, strerror):
860
print "IO error(%s): %s" % (errno, strerror)
863
print "Successfully wrote www/php/phpBB3/config.php"
865
# Write lib/conf/usrmgt-server.init
868
conf = open(usrmgtserver_initdfile, "w")
870
conf.write( '''#! /bin/sh
872
# Works for Ubuntu. Check before using on other distributions
875
# Provides: usrmgt-server
876
# Required-Start: $syslog $networking $urandom
877
# Required-Stop: $syslog
878
# Default-Start: 2 3 4 5
880
# Short-Description: IVLE user management server
881
# Description: Daemon connecting to the IVLE user management database.
884
PATH=/sbin:/bin:/usr/sbin:/usr/bin
885
DESC="IVLE user management server"
887
DAEMON=/opt/ivle/scripts/$NAME
888
DAEMON_ARGS="''' + str(usrmgt_port) + ''' ''' + usrmgt_magic + '''"
889
PIDFILE=/var/run/$NAME.pid
890
SCRIPTNAME=/etc/init.d/usrmgt-server
892
# Exit if the daemon does not exist
893
test -f $DAEMON || exit 0
895
# Load the VERBOSE setting and other rcS variables
896
[ -f /etc/default/rcS ] && . /etc/default/rcS
898
# Define LSB log_* functions.
899
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
900
. /lib/lsb/init-functions
903
# Function that starts the daemon/service
908
# 0 if daemon has been started
909
# 1 if daemon was already running
910
# 2 if daemon could not be started
911
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
913
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
916
# Add code here, if necessary, that waits for the process to be ready
917
# to handle requests from services started subsequently which depend
918
# on this one. As a last resort, sleep for some time.
922
# Function that stops the daemon/service
927
# 0 if daemon has been stopped
928
# 1 if daemon was already stopped
929
# 2 if daemon could not be stopped
930
# other if a failure occurred
931
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
933
[ "$RETVAL" = 2 ] && return 2
934
# Wait for children to finish too if this is a daemon that forks
935
# and if the daemon is only ever run from this initscript.
936
# If the above conditions are not satisfied then add some other code
937
# that waits for the process to drop all resources that could be
938
# needed by services started subsequently. A last resort is to
939
# sleep for some time.
940
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
941
[ "$?" = 2 ] && return 2
942
# Many daemons don't delete their pidfiles when they exit.
948
# Function that sends a SIGHUP to the daemon/service
952
# If the daemon can reload its configuration without
953
# restarting (for example, when it is sent a SIGHUP),
954
# then implement that here.
956
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
962
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
965
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
966
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
970
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
973
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
974
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
977
#reload|force-reload)
979
# If do_reload() is not implemented then leave this commented out
980
# and leave 'force-reload' as an alias for 'restart'.
982
#log_daemon_msg "Reloading $DESC" "$NAME"
986
restart|force-reload)
988
# If the "reload" option is implemented then remove the
989
# 'force-reload' alias
991
log_daemon_msg "Restarting $DESC" "$NAME"
998
1) log_end_msg 1 ;; # Old process is still running
999
*) log_end_msg 1 ;; # Failed to start
1009
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
1010
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
1019
except IOError, (errno, strerror):
1020
print "IO error(%s): %s" % (errno, strerror)
1023
# fix permissions as the file contains the database password
1025
os.chmod('doc/setup/usrmgt-server.init', 0600)
1026
except OSError, (errno, strerror):
1027
print "WARNING: Couldn't chmod doc/setup/usrmgt-server.init:"
1028
print "OS error(%s): %s" % (errno, strerror)
1030
print "Successfully wrote lib/conf/usrmgt-server.init"
594
1033
print "You may modify the configuration at any time by editing"
596
1036
print conf_hfile
1038
print usrmgtserver_initdfile
618
1068
action_mkdir('jail/home', dry)
619
1069
action_mkdir('jail/tmp', dry)
1071
# Chmod the tmp directory to world writable
1072
action_chmod_w('jail/tmp', dry)
621
1074
# Copy all console and operating system files into the jail
622
action_copylist(install_list.list_console, 'jail/opt/ivle', dry)
1075
action_copylist(install_list.list_scripts, 'jail/opt/ivle', dry)
623
1076
copy_os_files_jail(dry)
624
1077
# Chmod the python console
625
action_chmod_x('jail/opt/ivle/console/python-console', dry)
1078
action_chmod_x('jail/opt/ivle/scripts/python-console', dry)
1079
action_chmod_x('jail/opt/ivle/scripts/fileservice', dry)
1080
action_chmod_x('jail/opt/ivle/scripts/serveservice', dry)
1082
# Also copy the IVLE lib directory into the jail
1083
# This is necessary for running certain scripts
1084
action_copylist(install_list.list_lib, 'jail/opt/ivle', dry)
1085
# IMPORTANT: The file jail/opt/ivle/lib/conf/conf.py contains details
1086
# which could compromise security if left in the jail (such as the DB
1088
# The "safe" version is in jailconf.py. Delete conf.py and replace it with
1090
action_copyfile('lib/conf/jailconf.py',
1091
'jail/opt/ivle/lib/conf/conf.py', dry)
628
1093
# Compile .py files into .pyc or .pyo files
629
1094
compileall.compile_dir('www', quiet=True)
630
compileall.compile_dir('console', quiet=True)
1095
compileall.compile_dir('lib', quiet=True)
1096
compileall.compile_dir('scripts', quiet=True)
1097
compileall.compile_dir('jail/opt/ivle/lib', quiet=True)
1099
# Set up ivle.pth inside the jail
1100
# Need to set /opt/ivle/lib to be on the import path
1102
"jail/usr/lib/python%s/site-packages/ivle.pth" % PYTHON_VERSION
1103
f = open(ivle_pth, 'w')
1104
f.write('/opt/ivle/lib\n')
675
1150
# chown trampoline to root and set setuid bit
676
1151
action_chown_setuid(tramppath, dry)
678
# Copy the www directory using the list
1153
# Create a scripts directory to put the usrmgt-server in.
1154
action_mkdir(os.path.join(ivle_install_dir, 'scripts'), dry)
1155
usrmgtpath = os.path.join(ivle_install_dir, 'scripts/usrmgt-server')
1156
action_copyfile('scripts/usrmgt-server', usrmgtpath, dry)
1157
action_chmod_x(usrmgtpath, dry)
1159
# Copy the www and lib directories using the list
679
1160
action_copylist(install_list.list_www, ivle_install_dir, dry)
1161
action_copylist(install_list.list_lib, ivle_install_dir, dry)
1163
# Copy the php directory
1164
forum_dir = "www/php/phpBB3"
1165
forum_path = os.path.join(ivle_install_dir, forum_dir)
1166
action_copytree(forum_dir, forum_path, dry)
1167
print "chown -R www-data:www-data %s" % forum_path
1169
os.system("chown -R www-data:www-data %s" % forum_path)
682
1172
# Copy the local jail directory built by the build action
683
# to the jails template directory (it will be used as a template
684
# for all the students' jails).
685
action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1173
# to the jails __staging__ directory (it will be used to help build
1174
# all the students' jails).
1175
action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
686
1176
if not nosubjects:
687
# Copy the subjects directory across
1177
# Copy the subjects and exercises directories across
688
1178
action_copylist(install_list.list_subjects, subjects_base, dry,
689
1179
srcdir="./subjects")
1180
action_copylist(install_list.list_exercises, exercises_base, dry,
1181
srcdir="./exercises")
691
1183
# Append IVLE path to ivle.pth in python site packages
692
1184
# (Unless it's already there)
693
1185
ivle_pth = os.path.join(sys.prefix,
694
1186
"lib/python%s/site-packages/ivle.pth" % PYTHON_VERSION)
695
1187
ivle_www = os.path.join(ivle_install_dir, "www")
1188
ivle_lib = os.path.join(ivle_install_dir, "lib")
696
1189
write_ivle_pth = True
1190
write_ivle_lib_pth = True
698
1192
file = open(ivle_pth, 'r')
699
1193
for line in file:
700
1194
if line.strip() == ivle_www:
701
1195
write_ivle_pth = False
1196
elif line.strip() == ivle_lib:
1197
write_ivle_lib_pth = False
703
1199
except (IOError, OSError):
705
1201
if write_ivle_pth:
706
1202
action_append(ivle_pth, ivle_www)
1203
if write_ivle_lib_pth:
1204
action_append(ivle_pth, ivle_lib)
721
1219
print >>sys.stderr, "(I need to chown some files)."
724
# Update the template jail directory in case it hasn't been installed
1222
# Update the staging jail directory in case it hasn't been installed
726
action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1224
action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
728
1226
# Re-link all the files in all students jails.
729
1227
for dir in os.listdir(jail_base):
730
if dir == 'template': continue
1228
if dir == '__staging__': continue
731
1229
# First back up the student's home directory
732
1230
temp_home = os.tmpnam()
733
1231
action_rename(os.path.join(jail_base, dir, 'home'), temp_home, dry)
734
1232
# Delete the student's jail and relink the jail files
735
action_linktree(os.path.join(jail_base, 'template'),
1233
action_linktree(os.path.join(jail_base, '__staging__'),
736
1234
os.path.join(jail_base, dir), dry)
737
1235
# Restore the student's home directory
738
1236
action_rename(temp_home, os.path.join(jail_base, dir, 'home'), dry)