Update 'freenas_network_unlock.py'
This commit is contained in:
@@ -35,18 +35,18 @@ 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/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)
|
||||
|
||||
# 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/FreeNASRecoveryKeys/{}.recoveryKey /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/FreeNASRecoveryKeys; cryptsetup luksClose FreeNASRecoveryKeys; rm -rf /mnt/FreeNASRecoveryKeys'".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')
|
||||
@@ -64,4 +64,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)
|
||||
#rc = call("umount -f /mnt/ramfs; rm -fP /mnt/ramfs/*; rmdir /mnt/ramfs", shell=True)
|
||||
Reference in New Issue
Block a user