rbucmd: start ssh-agent only if there isn't one running already

This commit is contained in:
Lucas 2021-10-16 15:36:12 +00:00
parent 50cd17d821
commit 52f2d20dbc
1 changed files with 5 additions and 3 deletions

View File

@ -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