From cb33e74054d702eda5c6b1d6770751e06bc3083c Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sun, 8 Feb 2009 01:14:36 +0100 Subject: remove old symlink before creating new one --- bashrc/common/ssh-agent-forwarding.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bashrc') diff --git a/bashrc/common/ssh-agent-forwarding.sh b/bashrc/common/ssh-agent-forwarding.sh index b18ef75..e4435ee 100644 --- a/bashrc/common/ssh-agent-forwarding.sh +++ b/bashrc/common/ssh-agent-forwarding.sh @@ -15,8 +15,18 @@ if [ -n "$SSH_AUTH_SOCK" -a -n "$SSH_CLIENT" ]; then # add current socket echo "$(date +%s) $SSH_AUTH_SOCK $SSH_CLIENT" >> "${HOME}/.ssh-agent-forwarding" - ln -sf "$SSH_AUTH_SOCK" "${HOME}/.ssh-agent-forwarded-sock" - + + # remove old symlink + if [[ -L "${HOME}/.ssh-agent-forwarded-sock" ]]; then + rm -f "${HOME}/.ssh-agent-forwarded-sock" + fi + + # create static symlink to socket + if [[ ! -e "${HOME}/.ssh-agent-forwarded-sock" ]]; then + ln -sf "$SSH_AUTH_SOCK" "${HOME}/.ssh-agent-forwarded-sock" + else + echo "Warning: ${HOME}/.ssh-agent-forwarded-sock exists and is not a symlink!" + fi fi SSH_AUTH_SOCK="${HOME}/.ssh-agent-forwarded-sock" -- cgit v1.2.3