49
49
os.path.basename(sys.argv[0])
52
config = ivle.config.Config()
53
store = ivle.database.get_store(config)
54
users = store.find(ivle.database.User).order_by(ivle.database.User.login)
56
logging.info("mass bind mount started")
55
res = db.get_all('login', ['login', 'unixid'])
57
return (flds['login'], flds['unixid'])
58
uids = dict(map(repack,res))
59
except Exception, message:
60
logging.error(str(message))
63
logging.info("mass aufs mount started")
65
list.sort(key=lambda user: user.login)
60
68
# This is where we'll mount to...
61
destdir = os.path.join(config['paths']['jails']['mounts'], login)
69
destdir = os.path.join(ivle.conf.jail_base, login)
62
70
# ... and this is where we'll get the user bits.
63
srcdir = os.path.join(config['paths']['jails']['src'], login)
71
srcdir = os.path.join(ivle.conf.jail_src_base, login)
66
74
if not options.unmount:
70
78
if not os.path.exists(destdir):
71
79
logging.debug("user %s had no mountpoint - creating" % login)
73
if os.path.exists(os.path.join(destdir, 'lib')):
74
logging.info("%s's jail appears mounted. skipping." % login)
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)
81
logging.debug("failed to mount %s's root template!" % login)
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)
88
logging.error("failed to mount user %s's home!" % login)
89
os.system("/bin/umount %s" % destdir)
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)
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)
100
logging.info("mounted user %s's jail" % login)
82
if os.system('/bin/mount -t aufs -o dirs=%s:%s=ro none %s'
83
% (srcdir,ivle.conf.jail_system,destdir)) == 0:
84
logging.info("mounted user %s's jail." % login)
86
logging.error("failed to mount user %s's jail!" % login)
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)
88
os.system('/bin/umount ' + destdir)
105
89
logging.info("unmounted user %s's jail." % login)
106
90
except Exception, message:
107
91
logging.warning(str(message))