Encrypted DVDs - mount / umount toggle script

Keywords: truecrypt
Versions:

This script is designed to handle .tc files (I use this extension for truecrypt volumes) from konqueror. One double click mounts, the next unmounts. It only supports volumes that only use a key file and no additional password.

On encrypted DVDs the mount point must already exist. Also the dvd.key needs to reside on a encrypted volume itself for obvious reasons.

#!/bin/bash

vaultfile=$(readlink -f $1)
vaultdir=$(echo $vaultfile | rev | cut --complement -d. -f1 | rev)

if [ $vaultfile == $vaultdir ]; then
        echo "Mount point and file identical. Aborting."
        exit
fi

mappingname=$(mount | grep $vaultdir | cut -d\  -f1)

if [ -z $mappingname ]; then

        if [ ! -e $vaultdir ]; then
                echo "Creating mount point $vaultdir..."
                mkdir $vaultdir
        fi

        echo "Mounting $vaultfile..."
        truecrypt -k ~/.truecrypt/dvd.key -u $vaultfile $vaultdir

else

        echo "Unmounting $vaultfile..."
        truecrypt -d $mappingname

fi

Related notes for 'truecrypt':
Encrypted DVDs

Comments
Enter new comment:

The comment will only be accepted when the following question is answered correctly:
How many dwarfs are there in snow white and the seven dwarfs?

Solution:
Name:
URL:
(Dear handmade spam sender: The URL will only be linked to after my approval, which you will not get.)
Comment: