VeraCrypt: verschiebe Programmlogik aus Shell- in Python-Skript

This commit is contained in:
Christopher Spinrath 2018-07-17 17:09:52 +02:00
parent 45caf8984e
commit 7768ced57e
2 changed files with 14 additions and 17 deletions

View File

@ -141,12 +141,24 @@ def __main():
container_name = args[ARG_CONTAINER_NAME]
container = os.path.join(usbdrive, container_name)
if not os.path.exists(usbdrive):
print(":: USB partition mount point \"{}\" doesn't exist. Ignoring request.".format(usbdrive))
return
if args[ARG_VERA_DISMOUNT]:
vera_unmount(volume)
if os.path.exists(volume):
vera_unmount(volume)
else:
print(":: VeraCrypt mount point \"{}\" doesn't exist. Skipping unmount!".format(volume))
if args[ARG_UNMOUNT_USB_DRIVE]:
unmount_usbdrive(usbdrive)
return
if os.path.exists(volume):
print(":: VeraCrypt mount point \"{}\" already exists! Assuming container is already mounted.".format(volume))
return
vera_mount(volume, container)
if __name__ == '__main__':

View File

@ -16,24 +16,9 @@ PYTHON_VERA_WRAPPER_BIN=~/ls1-misc/veracrypt/verausbdrive.py
set -e
USB_DRIVE_MOUNT_PATH="$MOUNT_PATH/$USB_DRIVE_PART_NAME"
VERA_MOUNT_PATH="$MOUNT_PATH/$VERA_DRIVE_NAME"
if [ ! -d "$USB_DRIVE_MOUNT_PATH" ]
then
echo "USB drive partition not mounted; ignoring request."
exit 0
fi
if [ -d "$VERA_MOUNT_PATH" ]
then
echo "Verascript drive name already in use; assuming the container is already mounted."
exit 0
fi
MY_BASEPATH="$(dirname "$PYTHON_VERA_WRAPPER_BIN")"
MY_BINARY="$(basename "$PYTHON_VERA_WRAPPER_BIN")"
pushd "$MY_BASEPATH" > /dev/null
pipenv run ./"$MY_BINARY" -m "$MOUNT_PATH" -v "$VERA_DRIVE_NAME" -n "$USB_DRIVE_PART_NAME" "$VERA_CONTAINER_PATH_REL"
pipenv run ./"$MY_BINARY" -m "$MOUNT_PATH" -v "$VERA_DRIVE_NAME" -n "$USB_DRIVE_PART_NAME" "$VERA_CONTAINER_PATH_REL" $@
popd > /dev/null