Created
June 1, 2016 07:51
-
-
Save tmlbl/f6731b750a8cae5bdd255c7d24c4fc90 to your computer and use it in GitHub Desktop.
A quick bash script to encrypt a directory with a passkey.
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 | |
BANK_DIR=$HOME/.bank | |
mkdir -p $BANK_DIR; | |
if [ "$1" = "lock" ]; then | |
if [ -e $BANK_DIR.tar.gz.gpg ]; then | |
echo "$BANK_DIR already locked."; | |
exit 1; | |
fi | |
echo "Locking $BANK_DIR..."; | |
(tar zcvf - -C $HOME .bank | gpg -c > $BANK_DIR.tar.gz.gpg) && | |
rm -r $BANK_DIR; | |
elif [ "$1" = "unlock" ]; then | |
echo "Unlocking $BANK_DIR..."; | |
(gpg --decrypt $BANK_DIR.tar.gz.gpg | tar -xzf - -C $HOME) && | |
rm $BANK_DIR.tar.gz.gpg; | |
else | |
echo "Commands: lock, unlock"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment