2017-06-21 00:07:18 +02:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2017-09-15 18:14:10 +02:00
|
|
|
# wip
|
2017-06-21 00:07:18 +02:00
|
|
|
function gpg-encrypt-dir() {
|
|
|
|
dirname=$1
|
2017-06-21 20:18:44 +02:00
|
|
|
echo "Encrypting..."
|
2017-06-21 00:07:18 +02:00
|
|
|
tar -cz "$dirname" | gpg --symmetric --output "$dirname.tar.gz.gpg"
|
2017-06-21 20:18:44 +02:00
|
|
|
echo "Done."
|
2017-06-21 00:07:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-15 18:14:10 +02:00
|
|
|
# wip
|
2017-06-21 00:07:18 +02:00
|
|
|
function gpg-decrypt-dir() {
|
|
|
|
dirname=$1
|
|
|
|
outdir=${dirname%.tar.gz.gpg}
|
|
|
|
|
|
|
|
if [ -d "$outdir" ]; then
|
|
|
|
echo "Output directory, $outdir, already exists and will be overwritten by this command. Aborting..."
|
|
|
|
exit 1
|
|
|
|
else
|
2017-06-21 20:18:44 +02:00
|
|
|
echo "Decrypting..."
|
2017-06-21 00:07:18 +02:00
|
|
|
gpg --decrypt $dirname | tar -xv
|
2017-06-21 20:18:44 +02:00
|
|
|
echo "Done."
|
2017-06-21 00:07:18 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
2017-06-21 20:18:44 +02:00
|
|
|
|
|
|
|
|
2017-09-15 18:14:10 +02:00
|
|
|
# encrypts a file, appending a .gpg extension
|
|
|
|
# deletes the non-encrypted source
|
2017-06-21 20:18:44 +02:00
|
|
|
function gpg-encrypt-file() {
|
|
|
|
filename=$1
|
2017-09-15 18:14:10 +02:00
|
|
|
echo "Encrypting..." && \
|
|
|
|
gpg --symmetric ${filename} && \
|
|
|
|
rm ${filename} && \
|
2017-06-21 20:18:44 +02:00
|
|
|
echo "Done."
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-15 18:14:10 +02:00
|
|
|
# decrypts a file
|
|
|
|
# deletes the original encrypted file with the .gpg extension
|
2017-06-21 20:18:44 +02:00
|
|
|
function gpg-decrypt-file() {
|
|
|
|
filename=$1
|
2017-09-15 18:14:10 +02:00
|
|
|
echo "Decrypting..." && \
|
|
|
|
gpg --decrypt ${filename} >"${filename%.gpg}" && \
|
|
|
|
rm ${filename} && \
|
2017-06-21 20:18:44 +02:00
|
|
|
echo "Done."
|
|
|
|
}
|