Created
March 23, 2015 19:26
-
-
Save Karunamon/0e49f8a53c34ad977058 to your computer and use it in GitHub Desktop.
Simple encrypted volume mounter
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 | |
volumeName='encrypted-volume' | |
volumePath="/var/Private/$volumeName" | |
mountPath='/mmt/private/' | |
#Default ext* file system stuff makes for good test fodder | |
stat $mountPath/lost+found >> /dev/null 2>&1 | |
if [ $? == 0 ]; then | |
#It's mounted, unmount it | |
cd .. | |
umount $mountPath | |
cryptsetup luksClose $volumeName | |
echo "Volume $volumeName has been closed and unmounted." | |
else | |
#It's not mounted, mount it | |
cryptsetup luksOpen $volumePath $volumeName | |
if [ $? == 0 ]; then | |
#cryptsetup was successful | |
mount /dev/mapper/$volumeName $mountPath | |
mount | grep $volumeName | |
cd $mountPath | |
else | |
echo "Mount failed. Bad password or something else?" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment