34
33
Builds or updates the base IVLE jail."""
37
print >> sys.stderr, "This script requires root privlages to run"
36
40
conf = ivle.config.Config()
37
build_path = ivle.conf.jail_system_build
41
build_path = conf['paths']['jails']['template_build']
40
44
parser = optparse.OptionParser(usage)
116
120
if conf['jail']['devmode']:
117
121
# Copy all console and operating system files into the jail
118
services_path = os.path.join(ivle.conf.share_path, 'services')
122
services_path = os.path.join(conf['paths']['share'], 'services')
119
123
jail_services_path = os.path.join(build_path, services_path[1:])
120
124
if os.path.exists(jail_services_path):
121
125
shutil.rmtree(jail_services_path)
170
174
raise UnsafeJail(f)
177
# Copy jail template build to actual jail template
178
template_path = conf['paths']['jails']['template']
173
179
if os.spawnvp(os.P_WAIT, 'rsync', ['rsync', '-a', '--delete',
174
build_path + '/', ivle.conf.jail_system]) != 0:
180
build_path + '/', template_path]) != 0:
175
181
print >> sys.stderr, "Jail copying failed."
178
184
# Now mangle things a bit, so we can bind-mount the user bits in.
179
185
# /etc/passwd and /etc/ivle/ivle.conf need to be symlinks to somewhere in /home
181
os.rename(os.path.join(ivle.conf.jail_system, 'etc/passwd'),
182
os.path.join(ivle.conf.jail_system, 'home/.passwd')
187
os.rename(os.path.join(template_path, 'etc/passwd'),
188
os.path.join(template_path, 'home/.passwd')
184
os.symlink('../home/.passwd', os.path.join(ivle.conf.jail_system, 'etc/passwd'))
190
os.symlink('../home/.passwd', os.path.join(template_path, 'etc/passwd'))
186
os.makedirs(os.path.join(ivle.conf.jail_system, "etc/ivle"))
192
os.makedirs(os.path.join(template_path, "etc/ivle"))
187
193
os.symlink('../../home/.ivle.conf',
188
os.path.join(ivle.conf.jail_system, "etc/ivle/ivle.conf"))
194
os.path.join(template_path, "etc/ivle/ivle.conf"))