Support alternate gpg program (#19)

pull/26/head
Tim Byrne 8 years ago
parent e4d1b3a165
commit ce0acf1505
No known key found for this signature in database
GPG Key ID: 6CBE24C2FD8CF76E

20
yadm

@ -29,6 +29,8 @@ YADM_CONFIG="config"
YADM_ENCRYPT="encrypt" YADM_ENCRYPT="encrypt"
YADM_ARCHIVE="files.gpg" YADM_ARCHIVE="files.gpg"
GPG_PROGRAM="gpg"
#; flag when something may have changes (which prompts auto actions to be performed) #; flag when something may have changes (which prompts auto actions to be performed)
CHANGES_POSSIBLE=0 CHANGES_POSSIBLE=0
@ -214,7 +216,7 @@ function decrypt() {
fi fi
#; decrypt the archive #; decrypt the archive
(gpg -d "$YADM_ARCHIVE" || echo 1) | tar v${tar_option}f - -C "$YADM_WORK" ($GPG_PROGRAM -d "$YADM_ARCHIVE" || echo 1) | tar v${tar_option}f - -C "$YADM_WORK"
if [ $? = 0 ] ; then if [ $? = 0 ] ; then
[ ! "$DO_LIST" = "YES" ] && echo "All files decrypted." [ ! "$DO_LIST" = "YES" ] && echo "All files decrypted."
else else
@ -261,7 +263,7 @@ function encrypt() {
echo echo
#; encrypt all files which match the globs #; encrypt all files which match the globs
tar -f - -c "${GLOBS[@]}" | gpg --yes "${GPG_OPTS[@]}" --output "$YADM_ARCHIVE" tar -f - -c "${GLOBS[@]}" | $GPG_PROGRAM --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
@ -574,8 +576,18 @@ function require_git() {
error_out "This functionality requires Git to be installed, but the command git cannot be located." error_out "This functionality requires Git to be installed, but the command git cannot be located."
} }
function require_gpg() { function require_gpg() {
command -v gpg >/dev/null 2>&1 || \ local alt_gpg
error_out "This functionality requires GPG to be installed, but the command gpg cannot be located." alt_gpg="$(config yadm.gpg-program)"
local more_info
more_info=""
if [ "$alt_gpg" != "" ] ; then
GPG_PROGRAM="$alt_gpg"
more_info="\nThis command has been set via the yadm.gpg-program configuration."
fi
command -v "$GPG_PROGRAM" >/dev/null 2>&1 || \
error_out "This functionality requires GPG to be installed, but the command '$GPG_PROGRAM' cannot be located.$more_info"
} }
function require_repo() { function require_repo() {
[ -d "$YADM_REPO" ] || error_out "Git repo does not exist. did you forget to run 'init' or 'clone'?" [ -d "$YADM_REPO" ] || error_out "Git repo does not exist. did you forget to run 'init' or 'clone'?"

@ -301,6 +301,10 @@ If left blank or not provided, symmetric encryption is used instead.
If set to "ASK", gpg will interactively ask for recipients. If set to "ASK", gpg will interactively ask for recipients.
See the ENCRYPTION section for more details. See the ENCRYPTION section for more details.
This feature is disabled by default. This feature is disabled by default.
.TP
.B yadm.gpg-program
Specify an alternate program to use instead of "gpg".
By default, the first "gpg" found in $PATH is used.
.SH ALTERNATES .SH ALTERNATES
When managing a set of files across different systems, it can be useful to have When managing a set of files across different systems, it can be useful to have
an automated way of choosing an alternate version of a file for a different an automated way of choosing an alternate version of a file for a different

Loading…
Cancel
Save