Exemple #1
0
def setup_sandbox_drive():
    umask = conf.get('sandbox-drive.umask')
    mountpoint = conf.get('sandbox-drive.mountpoint')
    symlink_path = conf.get('sandbox-drive.symlink')
    group_name = conf.get('sandbox-drive.group-name')
    owner_name = conf.get('sandbox-drive.owner-name')

    os.mkdir(mountpoint)
    os.symlink(mountpoint, symlink_path)
    exectools.check_call_command(['groupadd', group_name])
    exectools.check_call_command(['usermod', '-a', '-G', 'vboxsf', owner_name])
    exectools.check_call_command(
        ['usermod', '-a', '-G', group_name, owner_name])
    patchtools.apply_patch(restools.get_resource_file('fstab.patch'),
                           '/etc/fstab')

    drive_uid = pwd.getpwnam(owner_name).pw_uid
    drive_gid = grp.getgrnam(group_name).gr_gid
    tokens = {
        'mountpoint': mountpoint,
        'umask': umask,
        'gid': str(drive_gid),
        'uid': str(drive_uid)
    }
    patchtools.replace_tokens(tokens, '/etc/fstab')
    exectools.check_call_command(['mount', '-a'])
def setup_sandbox_drive():
    umask = conf.get('sandbox-drive.umask')
    mountpoint = conf.get('sandbox-drive.mountpoint')
    symlink_path = conf.get('sandbox-drive.symlink')
    group_name = conf.get('sandbox-drive.group-name')
    owner_name = conf.get('sandbox-drive.owner-name')

    os.mkdir(mountpoint)
    os.symlink(mountpoint, symlink_path)
    exectools.check_call_command(['groupadd', group_name])
    exectools.check_call_command(['usermod', '-a', '-G', 'vboxsf', owner_name])
    exectools.check_call_command(['usermod', '-a', '-G', group_name, owner_name])
    patchtools.apply_patch(restools.get_resource_file('fstab.patch'), '/etc/fstab')
    
    drive_uid = pwd.getpwnam(owner_name).pw_uid
    drive_gid = grp.getgrnam(group_name).gr_gid
    tokens = {
             'mountpoint': mountpoint,
             'umask': umask,
             'gid': str(drive_gid),
             'uid': str(drive_uid)
             }
    patchtools.replace_tokens(tokens, '/etc/fstab')
    exectools.check_call_command(['mount', '-a'])
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json


def load_from_file(filename):
    with open(filename, mode='r') as fd:
        conf = json.load(fd)
        return conf_loader(conf)

class conf_loader(object):
    
    def __init__(self, parsed_config):
        self.__parsed_config = parsed_config
        
    def get(self, key):
        key_path = key.split('.')
        value = self.__parsed_config
        for k in key_path:
            value = value[k]
        return value
        
if __name__ == '__main__':
    from net.sandbox.install.util.restools import restools
    f = restools.get_resource_file('post-install-conf.json')
    print "vbox-version: %s" % conf_loader.load_from_file(f).get("vbox-version")
    print "sandbox-drive.owner-name: %s" % conf_loader.load_from_file(f).get("sandbox-drive.owner-name")
Exemple #4
0
def setup_swap():
    patchtools.apply_patch(restools.get_resource_file('sysctl.conf.patch'),
                           '/etc/sysctl.conf')
    exectools.check_call_command(['sysctl', '-w', 'vm.swappiness=10'])
Exemple #5
0
def setup_grub():
    patchtools.apply_patch(restools.get_resource_file('grub.patch'),
                           '/etc/default/grub')
    exectools.check_call_command(['update-grub'])
Exemple #6
0
def setup_networking():
    patchtools.apply_patch(restools.get_resource_file('interfaces.patch'),
                           '/etc/network/interfaces')
    patchtools.apply_patch(restools.get_resource_file('hosts.patch'),
                           '/etc/hosts')
    exectools.check_call_command(['service', 'networking', 'restart'])
Exemple #7
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import grp
import os
import pwd

from net.sandbox.install.util import patchtools, aptgettools, filetools, exectools,\
    conftools
from net.sandbox.install.util.consoletools import console
from net.sandbox.install.util.nettools import nettools
from net.sandbox.install.util.restools import restools

CONF_FILE = restools.get_resource_file('post-install-conf.json')
conf = conftools.load_from_file(CONF_FILE)


def install_vbox_additions():
    vbox_version = conf.get('vbox-version')
    iso_prefix = conf.get('vbox-additions.iso-prefix')
    additions_mount_point = conf.get('vbox-additions.mount-point')
    url_pattern = conf.get('vbox-additions.url-pattern')
    executable_path = conf.get('vbox-additions.executable-path')

    uname = os.uname()[2]
    aptgettools.install(
        ['build-essential',
         'linux-headers-%s' % uname, 'dkms'])
    additions_iso_file = filetools.temp_file(iso_prefix, '.iso')
    nettools.download(url_pattern % (vbox_version, vbox_version),
                      additions_iso_file)
    os.mkdir(additions_mount_point)
def setup_swap():
    patchtools.apply_patch(restools.get_resource_file('sysctl.conf.patch'), '/etc/sysctl.conf')
    exectools.check_call_command(['sysctl', '-w', 'vm.swappiness=10'])
def setup_grub():
    patchtools.apply_patch(restools.get_resource_file('grub.patch'), '/etc/default/grub')
    exectools.check_call_command(['update-grub'])
def setup_networking():
    patchtools.apply_patch(restools.get_resource_file('interfaces.patch'), '/etc/network/interfaces')
    patchtools.apply_patch(restools.get_resource_file('hosts.patch'), '/etc/hosts')
    exectools.check_call_command(['service', 'networking', 'restart'])