From 52f2d20dbc2c47d05b4ca815b908b38a382eb5ec Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 16 Oct 2021 15:36:12 +0000 Subject: [PATCH] rbucmd: start ssh-agent only if there isn't one running already --- bin/rbucmd.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/rbucmd.sh b/bin/rbucmd.sh index 2ee1e5f..e94297c 100644 --- a/bin/rbucmd.sh +++ b/bin/rbucmd.sh @@ -32,7 +32,7 @@ while getopts cl: flag; do *) usage esac done -shift $((OPTIND - 1)) +shift $(($OPTIND - 1)) if [ $# -ne 2 ] || [ -z "$1" ] || [ -z "$2" ]; then usage fi @@ -41,8 +41,10 @@ backup_name=$2 [ -f "$host/bulist" ] || err "no bulist present in \"$h/\"" -eval $(ssh-agent -s) -trap 'eval $(ssh-agent -ks)' EXIT INT QUIT TERM +if [ -z "$SSH_AUTH_SOCK" ] || [ ! -S "$SSH_AUTH_SOCK" ]; then + eval $(ssh-agent -s) + trap 'eval $(ssh-agent -ks)' EXIT INT QUIT TERM +fi set -e