Пример #1
0
def mount(directory):
    u = Unroll()

    exports_append = ExportsAppend(u, directory)
    u.run(exports_append.run, exports_append.unroll)
    u.run('sudo nfsd restart')

    u.run(
            'VBoxManage snapshot crypt restore crypt',
            'VBoxManage snapshot crypt restore crypt'
            )

    u.run(
            'VBoxManage startvm crypt',
            'VBoxManage controlvm crypt poweroff'
            )

    u.run(['nc', '-l', str(NC_PORT)])

    u.run(
            ssh('sudo mount "1.1.1.1:{:s}" /media/volume'.format(directory)),
            ssh('sudo umount /media/volume')
            )

    u.run(get_volume_password)
    u.run(
        ssh(
            "HISTFILE= echo '{:s}' | sudo cryptsetup luksOpen /media/volume/crypt crypt"
            .format(g_volume_password)),
        ssh('sudo cryptsetup luksClose crypt'))

    u.run(
            ssh('sudo mount /dev/mapper/crypt /crypt'),
            ssh('sudo umount /crypt')
            )

    u.run(
            'mkdir -p /Volumes/crypt',
            'rmdir /Volumes/crypt'
            )

    u.run(
            'sudo mount_nfs {:s}:/crypt /Volumes/crypt'.format(CRYPT_HOSTNAME),
            'umount /Volumes/crypt'
            )

    u.run('open /Volumes/crypt', critical=False)
Пример #2
0
def create(directory, size_mb, password):
    u = Unroll()

    exports_append = ExportsAppend(u, directory)
    u.run(exports_append.run, exports_append.unroll)
    u.run('sudo nfsd restart')

    u.run(
            'VBoxManage snapshot crypt restore crypt',
            'VBoxManage snapshot crypt restore crypt'
            )

    u.run(
            'VBoxManage startvm crypt',
            'VBoxManage controlvm crypt poweroff'
            )

    u.run(['nc', '-l', str(NC_PORT)])

    u.run(
            ssh('sudo mount "1.1.1.1:{:s}" /media/volume'.format(directory)),
            ssh('sudo umount /media/volume')
            )

    u.run(ssh('dd if=/dev/zero of=/media/volume/crypt bs=1M count={:d}'.format(size_mb)))
    u.run(
        ssh(
            "HISTFILE= echo '{:s}' | sudo cryptsetup luksFormat /media/volume/crypt"
            .format(password)))

    u.run(
        ssh(
            "HISTFILE= echo '{:s}' | sudo cryptsetup luksOpen /media/volume/crypt crypt"
            .format(password)),
        ssh('sudo cryptsetup luksClose crypt'))

    u.run(ssh('sudo mkfs.ext4 /dev/mapper/crypt'))

    u.run(
            ssh('sudo mount /dev/mapper/crypt /crypt'),
            ssh('sudo umount /crypt')
            )

    u.run(ssh('sudo chown -R nikita:nikita /crypt'))

    u.run(ssh())

    u.unroll()
Пример #3
0
def umount(directory):
    u = Unroll()

    u.run('sudo umount /Volumes/crypt')

    u.run(ssh("""\
sync\
&& sudo service nfs-kernel-server stop\
&& sudo umount /crypt\
&& sudo cryptsetup luksClose crypt\
&& sudo umount /media/volume"""))

    exports_append = ExportsAppend(u, directory)
    u.run(exports_append.unroll)

    u.run('VBoxManage controlvm crypt poweroff')
    u.run('VBoxManage snapshot crypt restore crypt', critical=False)