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) try: exectools.check_call_command([ 'mount', '-o', 'loop', '-t', 'iso9660', additions_iso_file, additions_mount_point ]) try: exectools.call_command( [os.path.join(additions_mount_point, executable_path)]) finally: exectools.check_call_command(['umount', additions_mount_point]) finally: os.rmdir(additions_mount_point)
def install(packages, force=False): pkg_names = packages if type(pkg_names).__name__ == 'str': pkg_names = [pkg_names] command = ['apt-get', 'install', '-y'] if force: command += '-f' command += pkg_names exectools.check_call_command(command)
def install(packages, force = False): pkg_names = packages if type(pkg_names).__name__ == 'str': pkg_names = [pkg_names] command = ['apt-get', 'install', '-y'] if force: command += '-f' command += pkg_names exectools.check_call_command(command)
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 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) try: exectools.check_call_command(['mount', '-o', 'loop', '-t', 'iso9660', additions_iso_file, additions_mount_point]) try: exectools.call_command([os.path.join(additions_mount_point, executable_path)]) finally: exectools.check_call_command(['umount', additions_mount_point]) finally: os.rmdir(additions_mount_point)
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_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'])
def update(): exectools.check_call_command(['apt-get', 'update'])