238
256
# In the local file system, where are the subject-independent exercise sheet
239
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."""))
240
272
config_options.append(ConfigOption("public_host", "public.localhost",
241
273
"""Hostname which will cause the server to go into "public mode",
242
274
providing login-free access to student's published work:""",
777
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"
780
1033
print "You may modify the configuration at any time by editing"
782
1035
print jailconffile
783
1036
print conf_hfile
1038
print usrmgtserver_initdfile
897
1161
action_copylist(install_list.list_lib, ivle_install_dir, dry)
899
1163
# Copy the php directory
900
action_copytree('www/php/phpBB3',os.path.join(ivle_install_dir,'www/php/phpBB3'),
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)
904
1172
# Copy the local jail directory built by the build action
905
# to the jails template directory (it will be used as a template
906
# for all the students' jails).
907
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)
908
1176
if not nosubjects:
909
1177
# Copy the subjects and exercises directories across
910
1178
action_copylist(install_list.list_subjects, subjects_base, dry,
951
1219
print >>sys.stderr, "(I need to chown some files)."
954
# 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
956
action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1224
action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
958
1226
# Re-link all the files in all students jails.
959
1227
for dir in os.listdir(jail_base):
960
if dir == 'template': continue
1228
if dir == '__staging__': continue
961
1229
# First back up the student's home directory
962
1230
temp_home = os.tmpnam()
963
1231
action_rename(os.path.join(jail_base, dir, 'home'), temp_home, dry)
964
1232
# Delete the student's jail and relink the jail files
965
action_linktree(os.path.join(jail_base, 'template'),
1233
action_linktree(os.path.join(jail_base, '__staging__'),
966
1234
os.path.join(jail_base, dir), dry)
967
1235
# Restore the student's home directory
968
1236
action_rename(temp_home, os.path.join(jail_base, dir, 'home'), dry)