VAULT – A small script to create and mount encfs encrypted directories on the fly

Linux

This small script will allow you to create, mount and unmount encfs directories on the fly.
As the need for encryption seems to rise all the time, usable solutions always come in handy.

You can create a safe storage for sensible data quickly and easily with this script.

All you need to do to is to install encfs with your distrubutions package manager and adjust the tiny CONFIG section to your needs.
The script will take care of the rest (hopefully).

Comments welcome.

#!/bin/bash
#
# VAULT
# DR 20140624
# https://www.daniel-ritter.de/blog/vault-create-and-mount-encfs-encrypted-directories-on-the-fly
# 
# 
# CREATE AND MOUNT ENCFS ENCRYPTED DIRECTORIES ON THE FLY
#
# ENCFS NEEDS TO BE INSTALLED (apt-get install encfs for Debian/Ubuntu)
# ADJUST CONFIG SECTION TO YOUR NEEDS
#
# NO GUARANTEES, KNOW WHAT YOU ARE DOING
# THIS IS LICENSED WITH GPL
# http://www.gnu.org/licenses/gpl.txt



# CONFIG

VAULTBASEDIR=/home/myusername
FILEMANAGER=nautilus

# END OF CONFIG


clear
echo "VAULT"
echo


# INITIAL SETUP creates directories and sets up encryption
if [ ! -d "$VAULTBASEDIR/.vault_dec" ];then
echo "NO VAULT FOUND. CREATING..."
echo
echo
encfs $VAULTBASEDIR/.vault $VAULTBASEDIR/.vault_dec
touch $VAULTBASEDIR/.vault_dec/mounted
fusermount -u $VAULTBASEDIR/.vault_dec
echo
echo
echo "VAULT CREATED. RUN vault TO LOCK AND UNLOCK IT."
exit
fi



# VAULT is unlocked, lock it
if [[ -e $VAULTBASEDIR/.vault_dec/mounted ]];then
echo "Locking VAULT"
echo
fusermount -u $VAULTBASEDIR/.vault_dec
ls -la $VAULTBASEDIR/.vault_dec
echo
echo
echo "LOCKED"


# VAULT IS LOCKED, unlock it and open filemanager
else
echo "UNLOCKING VAULT"
encfs $VAULTBASEDIR/.vault $VAULTBASEDIR/.vault_dec
$FILEMANAGER $VAULTBASEDIR/.vault_dec
fi

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Nach oben