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

« back to all changes in this revision

Viewing changes to bin/ivle-mountallusers

  • Committer: Matt Giuca
  • Date: 2009-01-19 17:28:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: matt.giuca@gmail.com-20090119172859-htjq3rfpp0fhtpc9
ivle.worksheet: Added calculate_score. This is a nice clean Storm port of
    ivle.db.calculate_worksheet_score.
tutorial: Replaced use of ivle.db.calculate_worksheet_score with
    ivle.worksheet.calculate_score.
    Guess What!! Removed this module's dependency on ivle.db! Hooray!
    (Note: tutorialservice still depends on it).
bin/ivle-marks: Updated this script to use ivle.worksheet_calculate_score.
    Note that this DOES NOT execute properly -- it seems it didn't even
    before my changes (tries to call db.get_users). Not my fault; I'm
    committing and going to bed!
ivle.db: Removed calculate_worksheet_score.
    As this removes the dependency on get_problem_status, removed that too!
    Almost all the worksheet stuff is gone now!

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# Author:  William Grant
21
21
# Date:    4/7/2008
22
22
 
23
 
# Script to bind-mount jails for all users on the system.
 
23
# Script to UnionFS-mount jails for all users on the system.
24
24
# Requires root to run.
25
25
 
26
26
import sys
29
29
import optparse
30
30
import logging
31
31
 
32
 
import ivle.config
33
32
import ivle.database
 
33
import ivle.conf
34
34
 
35
35
p = optparse.OptionParser()
36
36
p.add_option('--verbose', '-v', action='store_true')
49
49
                          os.path.basename(sys.argv[0])
50
50
    sys.exit(1)
51
51
 
52
 
config = ivle.config.Config()
53
 
store = ivle.database.get_store(config)
 
52
store = ivle.database.get_store()
54
53
users = store.find(ivle.database.User).order_by(ivle.database.User.login)
55
54
 
56
 
logging.info("mass bind mount started")
 
55
logging.info("mass aufs mount started")
57
56
 
58
57
for user in users:
59
58
    login = user.login
60
59
    # This is where we'll mount to...
61
 
    destdir = os.path.join(config['paths']['jails']['mounts'], login)
 
60
    destdir = os.path.join(ivle.conf.jail_base, login)
62
61
    # ... and this is where we'll get the user bits.
63
 
    srcdir = os.path.join(config['paths']['jails']['src'], login)
 
62
    srcdir = os.path.join(ivle.conf.jail_src_base, login)
64
63
 
65
64
    try:
66
65
        if not options.unmount:
70
69
            if not os.path.exists(destdir):
71
70
                logging.debug("user %s had no mountpoint - creating" % login)
72
71
                os.mkdir(destdir)
73
 
            if os.path.exists(os.path.join(destdir, 'lib')):
74
 
                logging.info("%s's jail appears mounted. skipping." % login)
75
 
                continue
76
 
            # Mount read only root template
77
 
            if os.system('/bin/mount --bind -o ro %s %s'
78
 
                    % (config['paths']['jails']['template'], destdir)) == 0:
79
 
                logging.debug("mounted user %s's root template" % login)
80
 
            else:
81
 
                logging.debug("failed to mount %s's root template!" % login)
82
 
                continue
83
 
            # Mount homedir
84
 
            if os.system('/bin/mount --bind %s %s'
85
 
                    % (os.path.join(srcdir,'home'), os.path.join(destdir,'home'))) == 0:
86
 
                logging.debug("mounted user %s's home." % login)
87
 
            else:
88
 
                logging.error("failed to mount user %s's home!" % login)
89
 
                os.system("/bin/umount %s" % destdir)
90
 
                continue
91
 
            # Mount tmp
92
 
            if os.system('/bin/mount --bind %s %s'
93
 
                    % (os.path.join(srcdir,'tmp'), os.path.join(destdir,'tmp'))) == 0:
94
 
                logging.debug("mounted user %s's tmp." % login)
95
 
            else:
96
 
                logging.error("failed to mount user %s's tmp!" % login)
97
 
                os.system("/bin/umount %s" % os.path.join(destdir,'home'))
98
 
                os.system("/bin/umount %s" % destdir)
99
 
                continue
100
 
            logging.info("mounted user %s's jail" % login)
 
72
        
 
73
            if os.system('/bin/mount -t aufs -o dirs=%s:%s=ro none %s'
 
74
                             % (srcdir,ivle.conf.jail_system,destdir)) == 0:
 
75
                logging.info("mounted user %s's jail." % login)
 
76
            else:
 
77
                logging.error("failed to mount user %s's jail!" % login)
101
78
        else:
102
 
            os.system("/bin/umount %s" % os.path.join(destdir,'tmp'))
103
 
            os.system("/bin/umount %s" % os.path.join(destdir,'home'))
104
 
            os.system("/bin/umount %s" % destdir)
 
79
            os.system('/bin/umount ' + destdir)
105
80
            logging.info("unmounted user %s's jail." % login)
106
81
    except Exception, message:
107
82
        logging.warning(str(message))