Last active
September 27, 2016 15:28
-
-
Save notpeelz/c4d4afcdb33f2d992b0a to your computer and use it in GitHub Desktop.
VeraCrypt volume (secure) mounting via GUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEVICE=/dev/sda1 | |
IMAGE_PATH='/media/$1/Storage/.veracrypt/volume' | |
MOUNT_PATH='/mnt/volume' | |
if [[ "$USER" != "root" ]]; then | |
gvfs-mount -d $DEVICE | |
gksu -D $(basename $0) $0 $USER | |
exit $? | |
fi | |
test -z "$1" && exit 1 | |
IMAGE_PATH=$(eval echo $IMAGE_PATH) | |
MOUNT_PATH=$(eval echo $MOUNT_PATH) | |
veracrypt -t -l "${IMAGE_PATH}" 1> /dev/null 2>&1 | |
if [ "$?" -eq 1 ]; then | |
PWD=$(zenity --password --title="Unlock Volume") | |
test -z "$PWD" && exit 0 | |
veracrypt -t ${IMAGE_PATH} ${MOUNT_PATH} --mount --non-interactive --stdin <<< "$PWD" | |
# Old (insecure) method | |
#veracrypt -t ${IMAGE_PATH} ${MOUNT_PATH} --mount --non-interactive -p "$PWD" | |
test "$?" -eq 0 \ | |
&& zenity --info --title "Mount Volume" --text "Successfully mounted the encrypted volume." \ | |
|| zenity --error --title "Mount Volume" --text "Failed to mount the encrypted volume." | |
else | |
zenity --warning --title "Mount Volume" --text "The volume is already mounted." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment