VeraCrypt: verschiebe Programmlogik aus Shell- in Python-Skript
This commit is contained in:
parent
45caf8984e
commit
7768ced57e
|
@ -141,12 +141,24 @@ def __main():
|
||||||
container_name = args[ARG_CONTAINER_NAME]
|
container_name = args[ARG_CONTAINER_NAME]
|
||||||
container = os.path.join(usbdrive, 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]:
|
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]:
|
if args[ARG_UNMOUNT_USB_DRIVE]:
|
||||||
unmount_usbdrive(usbdrive)
|
unmount_usbdrive(usbdrive)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if os.path.exists(volume):
|
||||||
|
print(":: VeraCrypt mount point \"{}\" already exists! Assuming container is already mounted.".format(volume))
|
||||||
|
return
|
||||||
|
|
||||||
vera_mount(volume, container)
|
vera_mount(volume, container)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -16,24 +16,9 @@ PYTHON_VERA_WRAPPER_BIN=~/ls1-misc/veracrypt/verausbdrive.py
|
||||||
|
|
||||||
set -e
|
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_BASEPATH="$(dirname "$PYTHON_VERA_WRAPPER_BIN")"
|
||||||
MY_BINARY="$(basename "$PYTHON_VERA_WRAPPER_BIN")"
|
MY_BINARY="$(basename "$PYTHON_VERA_WRAPPER_BIN")"
|
||||||
|
|
||||||
pushd "$MY_BASEPATH" > /dev/null
|
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
|
popd > /dev/null
|
||||||
|
|
Loading…
Reference in New Issue