diff --git a/freenas_network_unlock.py b/freenas_network_unlock.py index 29c6435..8dcef57 100644 --- a/freenas_network_unlock.py +++ b/freenas_network_unlock.py @@ -35,18 +35,19 @@ def request(resource, method='GET', data=None): raise ValueError(r) # Create a small ramdrive to store our recovery keys temporarily -#rc = call("mkdir /mnt/ramfs", shell=True) -#rc = call("mdmfs -s 1m md /mnt/ramfs", shell=True) +rc = call("mkdir /mnt/ramfs", shell=True) +rc = call("mdmfs -s 1m md /mnt/ramfs", shell=True) # Send our unlock/mount script to the pi and execute it on the pi using ssh -#rc = call("ssh {}@{} 'mkdir /mnt/FreeNASRecoveryKeys; echo -n {} | cryptsetup luksOpen {} FreeNASRecoveryKeys -d - && mount /dev/mapper/FreeNASRecoveryKeys /mnt/FreeNASRecoveryKeys'".format(config.KEY_HOST_USER, config.KEY_HOST, config.LUKS_PASSWORD, config.LUKS_VOLUME), shell=True) +rc = call("ssh {}@{} 'mkdir /mnt/FreeNASPoolKeys; echo -n {} | cryptsetup luksOpen {} FreeNASPoolKeys -d - && mount /dev/mapper/FreeNASPoolKeys /mnt/FreeNASPoolKeys'".format(config.KEY_HOST_USER, config.KEY_HOST, config.LUKS_PASSWORD, config.LUKS_VOLUME), shell=True) # Now we can copy the keys to the ramfs -#for poolName in config.POOL_NAMES: -# rc= call("scp {}@{}:/mnt/FreeNASRecoveryKeys/{}.recoveryKey /mnt/ramfs".format(config.KEY_HOST_USER, config.KEY_HOST, poolName), shell=True) +for poolName in config.POOL_NAMES: + #rc= call("scp {}@{}:/mnt/FreeNASPoolKeys/{}.recoveryKey /mnt/ramfs".format(config.KEY_HOST_USER, config.KEY_HOST, poolName), shell=True) + rc= call("scp {}@{}:/mnt/FreeNASPoolKeys/{}.passphrase /mnt/ramfs".format(config.KEY_HOST_USER, config.KEY_HOST, poolName), shell=True) # We can close the luks volume now -#rc = call("ssh {}@{} 'umount /mnt/FreeNASRecoveryKeys; cryptsetup luksClose FreeNASRecoveryKeys; rm -rf /mnt/FreeNASRecoveryKeys'".format(config.KEY_HOST_USER, config.KEY_HOST), shell=True) +rc = call("ssh {}@{} 'umount /mnt/FreeNASPoolKeys; cryptsetup luksClose FreeNASPoolKeys; rm -rf /mnt/FreeNASPoolKeys'".format(config.KEY_HOST_USER, config.KEY_HOST), shell=True) # Loop through the pools and only unlock the locked ones POOLS = request('storage/volume/', 'GET') @@ -66,4 +67,4 @@ for pool in POOLS['response']: logging.debug('Pool {} is already unlocked'.format(pool['name'])) # wipe the files, unmount the ramfs, and remove the folder -#rc = call("umount -f /mnt/ramfs; rm -fP /mnt/ramfs/*; rmdir /mnt/ramfs", shell=True) \ No newline at end of file +rc = call("umount -f /mnt/ramfs; rm -fP /mnt/ramfs/*; rmdir /mnt/ramfs", shell=True) \ No newline at end of file