source $agenteval >/dev/null
fi
rm -f $agenteval.lock
- # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
- ssh-add ~/.ssh/id_dsa 2>/dev/null
fi
+for key in $HOME/.ssh/id_dsa;do
+ # Prevent gdm(8) lockups on non-interactive consoles.
+ tty -s || continue
+ (ssh-add -l|grep -qw "$key") && continue
+ if lockfile -! -1 -r 0 $agenteval.input.lock 2>/dev/null;then
+ echo >&2 -n "Locking: $agenteval.input.lock ... "
+ lockfile -1 -r -1 $agenteval.input.lock
+ echo >&2 "locked"
+ fi
+ # Recheck identity existence after the lock acquire
+ if ssh-add -l|grep -qw "$key";then
+ echo >&2 "Identity $key already appended in the meantime."
+ else
+ # "2>/dev/null" to prevent: Identity added: .ssh/id_dsa (.ssh/id_dsa)
+ ssh-add "$key" 2>/dev/null
+ fi
+ rm -f $agenteval.input.lock
+ echo >&2 "$agenteval.input.lock unlocked."
+done
unset agenteval