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

« back to all changes in this revision

Viewing changes to bin/ivle-buildjail

  • Committer: David Coles
  • Date: 2009-12-09 01:19:01 UTC
  • Revision ID: coles.david@gmail.com-20091209011901-98pqe54aygb02759
Remove ivle-buildjail's dependancy on the old ivle.conf module

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import sys
23
23
import shutil
24
24
 
25
 
import ivle.conf
26
25
import ivle.config
27
26
import ivle.jailbuilder.debian
28
27
 
33
32
(requires root)
34
33
Builds or updates the base IVLE jail."""
35
34
 
 
35
# Requires root
 
36
if os.getuid() != 0:
 
37
    print >> sys.stderr, "This script requires root privlages to run"
 
38
    sys.exit(1)
 
39
 
36
40
conf = ivle.config.Config()
37
 
build_path = ivle.conf.jail_system_build
 
41
build_path = conf['paths']['jails']['template_build']
38
42
 
39
43
# Parse arguments
40
44
parser = optparse.OptionParser(usage)
115
119
 
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)
168
172
                ):
169
173
                continue
170
174
            raise UnsafeJail(f)
171
 
    
172
 
 
 
175
 
 
176
 
 
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."
176
182
    sys.exit(1)
177
183
 
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
180
186
 
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')
183
189
          )
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'))
185
191
 
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"))