aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-08-08 17:13:50 -0300
committerSilvio Rhatto <rhatto@riseup.net>2019-08-08 17:13:50 -0300
commita10069fbe13127bd5c08be54df948f4f206cbe2f (patch)
tree509b68d8f195ab34357c77487a1cacfbd696f77b
parent1933bbd450f9acb9d7281d9e5cb34437f8b27179 (diff)
downloadborger-a10069fbe13127bd5c08be54df948f4f206cbe2f.tar.gz
borger-a10069fbe13127bd5c08be54df948f4f206cbe2f.tar.bz2
Ask the passphrase only once and be verbose when asking
-rwxr-xr-xborger13
1 files 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