#7 Add support for asymmetric encryption

This commit is contained in:
Espen Henriksen 2016-04-19 21:06:35 +02:00
parent 4948f1b137
commit 34ae748408
No known key found for this signature in database
GPG Key ID: D27FDB6528795773
1 changed files with 9 additions and 1 deletions

10
yadm
View File

@ -223,8 +223,16 @@ function encrypt() {
#; process relative to YADM_WORK #; process relative to YADM_WORK
YADM_WORK=$(git config core.worktree) YADM_WORK=$(git config core.worktree)
GPG_KEY="$(config yadm.gpg-recipient)"
cd $YADM_WORK cd $YADM_WORK
#; Build gpg options for gpg
if [ "$GPG_KEY" != "" ]; then
GPG_OPTS="-er $GPG_KEY"
else
GPG_OPTS="-c"
fi
#; build a list of globs from YADM_ENCRYPT #; build a list of globs from YADM_ENCRYPT
GLOBS=() GLOBS=()
while IFS='' read -r glob || [ -n "$glob" ]; do while IFS='' read -r glob || [ -n "$glob" ]; do
@ -234,7 +242,7 @@ function encrypt() {
done < "$YADM_ENCRYPT" done < "$YADM_ENCRYPT"
#; encrypt all files which match the globs #; encrypt all files which match the globs
tar -cv ${GLOBS[@]} | gpg --yes -c --output "$YADM_ARCHIVE" tar -cv ${GLOBS[@]} | gpg --yes "$GPG_OPTS" --output "$YADM_ARCHIVE"
if [ $? = 0 ]; then if [ $? = 0 ]; then
echo "Wrote new file: $YADM_ARCHIVE" echo "Wrote new file: $YADM_ARCHIVE"
else else