261
246
file system):""",
263
248
# 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."""))
272
249
config_options.append(ConfigOption("public_host", "public.localhost",
273
250
"""Hostname which will cause the server to go into "public mode",
274
251
providing login-free access to student's published work:""",
863
838
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"
1033
841
print "You may modify the configuration at any time by editing"
1035
843
print jailconffile
1036
844
print conf_hfile
1037
845
print phpBBconffile
1038
print usrmgtserver_initdfile
1172
971
# Copy the local jail directory built by the build action
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)
972
# to the jails template directory (it will be used as a template
973
# for all the students' jails).
974
action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1176
975
if not nosubjects:
1177
976
# Copy the subjects and exercises directories across
1178
977
action_copylist(install_list.list_subjects, subjects_base, dry,
1219
1018
print >>sys.stderr, "(I need to chown some files)."
1222
# Update the staging jail directory in case it hasn't been installed
1021
# Update the template jail directory in case it hasn't been installed
1224
action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
1023
action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1226
1025
# Re-link all the files in all students jails.
1227
1026
for dir in os.listdir(jail_base):
1228
if dir == '__staging__': continue
1027
if dir == 'template': continue
1229
1028
# First back up the student's home directory
1230
1029
temp_home = os.tmpnam()
1231
1030
action_rename(os.path.join(jail_base, dir, 'home'), temp_home, dry)
1232
1031
# Delete the student's jail and relink the jail files
1233
action_linktree(os.path.join(jail_base, '__staging__'),
1032
action_linktree(os.path.join(jail_base, 'template'),
1234
1033
os.path.join(jail_base, dir), dry)
1235
1034
# Restore the student's home directory
1236
1035
action_rename(temp_home, os.path.join(jail_base, dir, 'home'), dry)