DEV_USB=$1 MOUNT_NAME=priv MOUNT_DIR=/media/michael/priv error(){ echo "!\t$1" exit 1 } issue(){ echo "!\t$1" } clear echo "Unlocking db..." cryptsetup luksOpen $DEV_USB $MOUNT_NAME ||\ error "Issue unlocking db... quitting..." echo "Mounting db..." rm -rf $MOUNT_DIR mkdir $MOUNT_DIR &&\ mount /dev/mapper/$MOUNT_NAME $MOUNT_DIR ||\ error "Issue mounting db... quitting..." echo "Making link..." rm -rf ./data.link ln -s "$MOUNT_DIR/notes" ./data.link ||\ error "Issue mounting db... quitting..." echo "Starting container..." docker run --name priv --rm -it -v `pwd`/data.link/:/notes `docker build -q .` echo "Unmounting db..." umount -f "$MOUNT_DIR" ||\ issue "Issue unmounting $DEV_USB..." rm -rf $MOUNT_DIR ||\ issue "Issue deleting mountpoint..." echo "Removing link..." rm -rf ./data.link issue "Issue deleting link..." echo "Locking db..." cryptsetup luksClose /dev/mapper/$MOUNT_NAME ||\ error "Issue locking db... quitting..." echo "Exiting gracefully..." exit 0