diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2009-02-08 01:14:36 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2009-02-08 01:14:36 +0100 |
commit | cb33e74054d702eda5c6b1d6770751e06bc3083c (patch) | |
tree | 78541a23bfb2ba969a6228276b1e50f271bac923 /bashrc/common | |
parent | 52bb282c86617d22ea7eeca1101d54edf72fcdfd (diff) | |
download | dotfiles-cb33e74054d702eda5c6b1d6770751e06bc3083c.tar.gz dotfiles-cb33e74054d702eda5c6b1d6770751e06bc3083c.tar.xz dotfiles-cb33e74054d702eda5c6b1d6770751e06bc3083c.zip |
remove old symlink before creating new one
Diffstat (limited to '')
-rw-r--r-- | bashrc/common/ssh-agent-forwarding.sh | 14 |
1 files changed, 12 insertions, 2 deletions
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" |