From 33076e344748b6bf46b54166cbceba4b21683e22 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 11 May 2018 11:30:38 +1000 Subject: [PATCH 1/3] Cleanup all mux sockets that exist --- bin/ghe-backup | 2 +- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-ssh | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index e76a7c69a..09bf80174 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -101,7 +101,7 @@ cleanup () { fi # Cleanup SSH multiplexing - ghe-ssh --clean "$GHE_HOSTNAME" + ghe-ssh --clean } # Setup exit traps diff --git a/bin/ghe-restore b/bin/ghe-restore index 4357d5809..a4cd3a0ad 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -73,7 +73,7 @@ cleanup () { fi # Cleanup SSH multiplexing - ghe-ssh --clean "$GHE_HOSTNAME" + ghe-ssh --clean } # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 0183f2f58..feb7c785b 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -23,7 +23,7 @@ while true; do ;; -c|--clean) cleanup_mux=1 - shift + break ;; --) echo "Error: illegal '--' in ssh invocation" @@ -37,6 +37,13 @@ while true; do esac done +if [ -n "$cleanup_mux" ]; then + while find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1; do + find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 + done + exit +fi + # Show usage with no host [ -z "$host" ] && print_usage @@ -77,12 +84,5 @@ fi $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. -if [ -z "$cleanup_mux" ]; then - # Exec ssh command with modified host / port args and add nice to command. - # shellcheck disable=SC2090 # We don't need the quote/backslashes respected - exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" -elif [ -z "$GHE_DISABLE_SSH_MUX" ]; then - while ssh -O check -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1; do - ssh -O stop -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1 - done -fi +# shellcheck disable=SC2090 # We don't need the quote/backslashes respected +exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" From 3f12ef5746e3bd9c9e5107feea5e6a5fc5fb18ca Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 11 May 2018 11:33:36 +1000 Subject: [PATCH 2/3] Only try once --- share/github-backup-utils/ghe-ssh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index feb7c785b..c557791fe 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -38,9 +38,7 @@ while true; do done if [ -n "$cleanup_mux" ]; then - while find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1; do - find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 - done + find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 exit fi From 5c22ef8c3fe5df686c4c822491be0aeeccb9de9e Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 11 May 2018 11:35:00 +1000 Subject: [PATCH 3/3] Always true --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index c557791fe..a705c9109 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -38,7 +38,7 @@ while true; do done if [ -n "$cleanup_mux" ]; then - find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 + find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 || true exit fi