diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2019-08-08 17:13:50 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2019-08-08 17:13:50 -0300 |
commit | a10069fbe13127bd5c08be54df948f4f206cbe2f (patch) | |
tree | 509b68d8f195ab34357c77487a1cacfbd696f77b | |
parent | 1933bbd450f9acb9d7281d9e5cb34437f8b27179 (diff) | |
download | borger-a10069fbe13127bd5c08be54df948f4f206cbe2f.tar.gz borger-a10069fbe13127bd5c08be54df948f4f206cbe2f.tar.bz2 |
Ask the passphrase only once and be verbose when asking
-rwxr-xr-x | borger | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -254,7 +254,8 @@ function borger_single { # Convert the pass command to passphrase otherwise # the user would be interrupted by a passphrase prompt # at every iteration - if [ ! -z "$BORG_PASSCOMMAND" ]; then + if [ ! -z "$BORG_PASSCOMMAND" ] && [ -z "$BORG_PASSPHRASE" ]; then + info "Asking passphrase for borg key used at $DESTINATION" export BORG_PASSPHRASE="`$BORG_PASSCOMMAND`" export BORG_PASSCOMMAND="" fi @@ -281,9 +282,13 @@ function borger_multiple { for config in `ls $CONFIG`; do # Include BORG_PASSPHRASE config for each destination in an array if grep -q "BORG_PASSCOMMAND" $CONFIG/$config; then - COMMAND="`grep BORG_PASSCOMMAND $CONFIG/$config | cut -d = -f 2 | sed -e "s/^'//" -e "s/'$//" -e 's/^"//' -e 's/"$//'`" - #BORG_PASSPHRASES[$config]="BORG_PASSPHRASE=`$COMMAND`" - BORG_PASSPHRASES[$config]="`$COMMAND`" + # Ask the passphrase only once + if [ -z "${BORG_PASSPHRASES[$config]}" ]; then + info "Asking passphrase for borg key used at $config" + COMMAND="`grep BORG_PASSCOMMAND $CONFIG/$config | cut -d = -f 2 | sed -e "s/^'//" -e "s/'$//" -e 's/^"//' -e 's/"$//'`" + #BORG_PASSPHRASES[$config]="BORG_PASSPHRASE=`$COMMAND`" + BORG_PASSPHRASES[$config]="`$COMMAND`" + fi else BORG_PASSPHRASES[$config]="" fi |