Commit 9c5bbeb0 authored by nimrod's avatar nimrod
Browse files

Fix issue with ControlMaster sockets pruning.

The prune_ssh_sockets shell function would always delete the
ControlMaster sockets (the open file handlers would have a random suffix
and the check would always show that the socket wasn't open by any
process). Instead add a prefix to the ControlMaster sockets and ignore
them when pruning. Those sockets are always deleted when the process
exists. Also, mark the vim filetype for the ssh config fragments as
sshconfig.
parent 6c992b1a
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -293,11 +293,14 @@ flatpak_kill () {
    fi
}

__prune_docker_remote () {
    for i in ~/.ssh/docker_*
    do
        [ ! -e "$i" ] || lsof -t "$i" >/dev/null || rm "$i"
    done
# shellcheck disable=SC2120
prune_ssh_sockets () {
    ( [ "${1:-}" != '-f' ] && [ "${1:-}" != '--force' ] ) || killall -v ssh || true
    find ~/.ssh/ \
        -maxdepth 1 \
        -type s \
        \! -name 'cm_*.sock' \
        -execdir sh -c 'lsof -t "$1" >/dev/null || rm "$1"' _ {} \;
}

__prompt () {
@@ -383,4 +386,5 @@ then
    ! command -v direnv > /dev/null || eval "$(direnv hook bash)"
fi

__prune_docker_remote
# shellcheck disable=SC2119
prune_ssh_sockets
+1 −0
Original line number Diff line number Diff line

# vim:ft=sshconfig
#Endless

Host appupdates.endlessm.com irc.endlessm.com status.endlessm.com
+2 −0
Original line number Diff line number Diff line

# vim:ft=sshconfig
# github.com

Host github.com
+1 −0
Original line number Diff line number Diff line

# vim:ft=sshconfig
# shore.co.il infrastructure

Host cgit.shore.co.il host01.shore.co.il wdr4300.shore.co.il xbmc.shore.co.il
+1 −0
Original line number Diff line number Diff line

# vim:ft=sshconfig
# localhost

Host localhost
Loading