From a10069fbe13127bd5c08be54df948f4f206cbe2f Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 8 Aug 2019 17:13:50 -0300 Subject: Ask the passphrase only once and be verbose when asking --- borger | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/borger b/borger index 05d8d2b..531e32a 100755 --- a/borger +++ b/borger @@ -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 -- cgit v1.2.3