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

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: dcoles
  • Date: 2008-02-29 02:11:58 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:624
forum: Removed the subsilver2 style and phpBB installer
Modified prosilver theme to be more IVLE integrated
Added db dumps for setup

setup.py: Added config.php generator code

doc/setup/install_proc.txt: New setup/install details

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
    '/usr/lib/libXdmcp.so.6',
160
160
    '/lib/libgcc_s.so.1',
161
161
    '/etc/matplotlibrc',
 
162
    # Needed for resolv
 
163
    '/lib/libnss_dns.so.2',
 
164
    #'/lib/libnss_mdns4.so',
 
165
    '/etc/hosts',
 
166
    '/etc/resolv.conf',
 
167
    #'/etc/hosts.conf',
 
168
    #'/etc/hostname',
 
169
    '/etc/nsswitch.conf',
 
170
    '/lib/libnss_files.so.2',
162
171
]
163
172
# Symlinks to make within the jail. Src mapped to dst.
164
173
JAIL_LINKS = {
204
213
# In the local file system, where IVLE is actually installed.
205
214
# This directory should contain the "www" and "bin" directories."""))
206
215
config_options.append(ConfigOption("jail_base", "/home/informatics/jails",
207
 
    """Root directory where the jails (containing user files) are stored
 
216
    """Location of Directories
 
217
=======================
 
218
Root directory where the jails (containing user files) are stored
208
219
(on the local file system):""",
209
220
    """
210
221
# In the local file system, where are the student/user file spaces located.
218
229
# In the local file system, where are the per-subject file spaces located.
219
230
# The individual subject directories are expected to be located immediately
220
231
# in subdirectories of this location."""))
221
 
config_options.append(ConfigOption("problems_base",
222
 
    "/home/informatics/problems",
223
 
    """Root directory where the problem directories (containing
224
 
subject-independent problem sheets) are stored (on the local file
 
232
config_options.append(ConfigOption("exercises_base",
 
233
    "/home/informatics/exercises",
 
234
    """Root directory where the exercise directories (containing
 
235
subject-independent exercise sheets) are stored (on the local file
225
236
system):""",
226
237
    """
227
 
# In the local file system, where are the subject-independent problem sheet
 
238
# In the local file system, where are the subject-independent exercise sheet
228
239
# file spaces located."""))
229
240
config_options.append(ConfigOption("public_host", "public.localhost",
230
241
    """Hostname which will cause the server to go into "public mode",
261
272
    """Database name:""",
262
273
    """
263
274
# Database name"""))
 
275
config_options.append(ConfigOption("db_forumdbname", "ivle_forum",
 
276
    """Forum Database name:""",
 
277
    """
 
278
# Forum Database name"""))
264
279
config_options.append(ConfigOption("db_user", "postgres",
265
280
    """Username for DB server login:""",
266
281
    """
270
285
    (Caution: This password is stored in plaintext in lib/conf/conf.py)""",
271
286
    """
272
287
# Database password"""))
 
288
config_options.append(ConfigOption("auth_modules", "ldap_auth",
 
289
    """Authentication config
 
290
=====================
 
291
Comma-separated list of authentication modules. Only "ldap" is available
 
292
by default.""",
 
293
    """
 
294
# Comma-separated list of authentication modules.
 
295
# These refer to importable Python modules in the www/auth directory.
 
296
# Modules "ldap" and "guest" are available in the source tree, but
 
297
# other modules may be plugged in to auth against organisation-specific
 
298
# auth backends."""))
 
299
config_options.append(ConfigOption("ldap_url", "ldaps://www.example.com",
 
300
    """(LDAP options are only relevant if "ldap" is included in the list of
 
301
auth modules).
 
302
URL for LDAP authentication server:""",
 
303
    """
 
304
# URL for LDAP authentication server"""))
 
305
config_options.append(ConfigOption("ldap_format_string",
 
306
    "uid=%s,ou=users,o=example",
 
307
    """Format string for LDAP auth request:
 
308
    (Must contain a single "%s" for the user's login name)""",
 
309
    """
 
310
# Format string for LDAP auth request
 
311
# (Must contain a single "%s" for the user's login name)"""))
 
312
config_options.append(ConfigOption("svn_addr", "http://svn.localhost/",
 
313
    """Subversion config
 
314
=================
 
315
The base url for accessing subversion repositories:""",
 
316
    """
 
317
# The base url for accessing subversion repositories."""))
273
318
config_options.append(ConfigOption("svn_conf", "/opt/ivle/svn/svn.conf",
274
319
    """The location of the subversion configuration file used by apache
275
320
to host the user repositories:""",
293
338
# The location of the password file used to authenticate local users
294
339
# of the subversion repository."""))
295
340
config_options.append(ConfigOption("usrmgt_host", "localhost",
296
 
    """The hostname where the usrmgt-server runs:""",
 
341
    """User Management Server config
 
342
============================
 
343
The hostname where the usrmgt-server runs:""",
297
344
    """
298
345
# The hostname where the usrmgt-server runs."""))
299
346
config_options.append(ConfigOption("usrmgt_port", "2178",
334
381
# as necessary, and include it in the distribution.
335
382
listmake_mimetypes = ['text/x-python', 'text/html',
336
383
    'application/x-javascript', 'application/javascript',
337
 
    'text/css', 'image/png', 'application/xml']
 
384
    'text/css', 'image/png', 'image/gif', 'application/xml']
338
385
 
339
386
# Main function skeleton from Guido van Rossum
340
387
# http://www.artima.com/weblogs/viewpost.jsp?thread=4829
458
505
Copy subjects/ to subjects directory (unless --nosubjects specified).
459
506
 
460
507
--nojail        Do not copy the jail.
461
 
--nosubjects    Do not copy the subjects and problems directories.
 
508
--nosubjects    Do not copy the subjects and exercises directories.
462
509
--dry | -n  Print out the actions but don't do anything."""
463
510
    elif operation == 'updatejails':
464
511
        print """sudo python setup.py updatejails [--dry|-n]
477
524
    list_www = build_list_py_files('www')
478
525
    list_lib = build_list_py_files('lib')
479
526
    list_subjects = build_list_py_files('subjects', no_top_level=True)
480
 
    list_problems = build_list_py_files('problems', no_top_level=True)
 
527
    list_exercises = build_list_py_files('exercises', no_top_level=True)
481
528
    list_scripts = [
482
529
        "scripts/python-console",
483
530
        "scripts/fileservice",
484
531
        "scripts/usrmgt-server",
 
532
        "scripts/diffservice",
485
533
    ]
486
534
    # Make sure that the files generated by conf are in the list
487
535
    # (since listmake is typically run before conf)
519
567
list_subjects = """)
520
568
        writelist_pretty(file, list_subjects)
521
569
        file.write("""
522
 
# List of all installable files in problems directory.
 
570
# List of all installable files in exercises directory.
523
571
# This is to install sample exercise material.
524
 
list_problems = """)
525
 
        writelist_pretty(file, list_problems)
 
572
list_exercises = """)
 
573
        writelist_pretty(file, list_exercises)
526
574
 
527
575
        file.close()
528
576
    except IOError, (errno, strerror):
576
624
    conffile = os.path.join(cwd, "lib/conf/conf.py")
577
625
    jailconffile = os.path.join(cwd, "lib/conf/jailconf.py")
578
626
    conf_hfile = os.path.join(cwd, "trampoline/conf.h")
 
627
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
579
628
 
580
629
    # Get command-line arguments to avoid asking questions.
581
630
 
733
782
 
734
783
    print "Successfully wrote trampoline/conf.h"
735
784
 
 
785
    # Write www/php/phpBB3/config.php
 
786
 
 
787
    try:
 
788
        conf = open(phpBBconffile, "w")
 
789
        
 
790
        # php-pg work around
 
791
        if db_host == 'localhost':
 
792
            forumdb_host = '127.0.0.1'
 
793
        else:
 
794
            forumdb_host = db_host
 
795
 
 
796
        conf.write( """<?php
 
797
// phpBB 3.0.x auto-generated configuration file
 
798
// Do not change anything in this file!
 
799
$dbms = 'postgres';
 
800
$dbhost = '""" + forumdb_host + """';
 
801
$dbport = '""" + str(db_port) + """';
 
802
$dbname = '""" + db_forumdbname + """';
 
803
$dbuser = '""" + db_user + """';
 
804
$dbpasswd = '""" + db_password + """';
 
805
 
 
806
$table_prefix = 'phpbb_';
 
807
$acm_type = 'file';
 
808
$load_extensions = '';
 
809
@define('PHPBB_INSTALLED', true);
 
810
// @define('DEBUG', true);
 
811
//@define('DEBUG_EXTRA', true);
 
812
?>"""   )
 
813
    
 
814
        conf.close()
 
815
    except IOError, (errno, strerror):
 
816
        print "IO error(%s): %s" % (errno, strerror)
 
817
        sys.exit(1)
 
818
 
 
819
    print "Successfully wrote www/php/phpBB3/config.php"
 
820
 
736
821
    print
737
822
    print "You may modify the configuration at any time by editing"
738
823
    print conffile
739
824
    print jailconffile
740
825
    print conf_hfile
 
826
    print phpBBconffile
741
827
    print
742
828
    return 0
743
829
 
762
848
    action_mkdir('jail/home', dry)
763
849
    action_mkdir('jail/tmp', dry)
764
850
 
 
851
    # Chmod the tmp directory to world writable
 
852
    action_chmod_w('jail/tmp', dry)
 
853
 
765
854
    # Copy all console and operating system files into the jail
766
855
    action_copylist(install_list.list_scripts, 'jail/opt/ivle', dry)
767
856
    copy_os_files_jail(dry)
840
929
    # chown trampoline to root and set setuid bit
841
930
    action_chown_setuid(tramppath, dry)
842
931
 
 
932
    # Create a scripts directory to put the usrmgt-server in.
 
933
    action_mkdir(os.path.join(ivle_install_dir, 'scripts'), dry)
 
934
    usrmgtpath = os.path.join(ivle_install_dir, 'scripts/usrmgt-server')
 
935
    action_copyfile('scripts/usrmgt-server', usrmgtpath, dry)
 
936
    action_chmod_x(usrmgtpath, dry)
 
937
 
843
938
    # Copy the www and lib directories using the list
844
939
    action_copylist(install_list.list_www, ivle_install_dir, dry)
845
940
    action_copylist(install_list.list_lib, ivle_install_dir, dry)
 
941
    
 
942
    # Copy the php directory
 
943
    action_copytree('www/php/phpBB3',os.path.join(ivle_install_dir,'www/php/phpBB3'), 
 
944
    dry)
846
945
 
847
946
    if not nojail:
848
947
        # Copy the local jail directory built by the build action
850
949
        # for all the students' jails).
851
950
        action_copytree('jail', os.path.join(jail_base, 'template'), dry)
852
951
    if not nosubjects:
853
 
        # Copy the subjects and problems directories across
 
952
        # Copy the subjects and exercises directories across
854
953
        action_copylist(install_list.list_subjects, subjects_base, dry,
855
954
            srcdir="./subjects")
856
 
        action_copylist(install_list.list_problems, problems_base, dry,
857
 
            srcdir="./problems")
 
955
        action_copylist(install_list.list_exercises, exercises_base, dry,
 
956
            srcdir="./exercises")
858
957
 
859
958
    # Append IVLE path to ivle.pth in python site packages
860
959
    # (Unless it's already there)
984
1083
    directories as necessary.
985
1084
 
986
1085
    See shutil.copytree."""
 
1086
    # Allow copying over itself
 
1087
    if (os.path.normpath(os.path.join(os.getcwd(),src)) ==
 
1088
        os.path.normpath(os.path.join(os.getcwd(),dst))):
 
1089
        return
987
1090
    action_remove(dst, dry)
988
1091
    print "cp -r", src, dst
989
1092
    if dry: return
1074
1177
        os.chmod(file, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
1075
1178
            | stat.S_IXGRP | stat.S_IRGRP | stat.S_IXOTH | stat.S_IROTH)
1076
1179
 
 
1180
 
 
1181
def action_chmod_w(file, dry):
 
1182
    """Chmod 777 a file (sets permissions to rwxrwxrwx)."""
 
1183
    print "chmod 777", file
 
1184
    if not dry:
 
1185
        os.chmod(file, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
 
1186
            | stat.S_IXGRP | stat.S_IWGRP | stat.S_IRGRP | stat.S_IXOTH
 
1187
            | stat.S_IWOTH | stat.S_IROTH)
 
1188
 
1077
1189
def query_user(default, prompt):
1078
1190
    """Prompts the user for a string, which is read from a line of stdin.
1079
1191
    Exits silently if EOF is encountered. Returns the string, with spaces