From 1dc744ac1faf61a0c8b8f2e427436316f28f660a Mon Sep 17 00:00:00 2001 Message-Id: <1dc744ac1faf61a0c8b8f2e427436316f28f660a.1715118897.git.mdw@distorted.org.uk> From: Mark Wooding Date: Wed, 6 May 2015 18:04:28 +0100 Subject: [PATCH 1/1] bin/outbound: Factor out the actual shutting down of an SSH process. Organization: Straylight/Edgeware From: Mark Wooding --- bin/outbound | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/outbound b/bin/outbound index cad1526..5ed160d 100755 --- a/bin/outbound +++ b/bin/outbound @@ -15,12 +15,7 @@ writefile () { runssh () { ssh -T -oControlPath="./$host.ctrl" "$@"; } -stopit () { - - ## Initial shutdown protocol. - writefile "$host.state" stopping - if [ -f "$host.pid" ]; then kill $(cat "$host.pid") 2>/dev/null || :; fi - rm -f "$host.pid" +clobber () { ## Shut down an existing connection if there is one. if [ -S "$host.ctrl" ]; then @@ -39,6 +34,17 @@ stopit () { ## Remove the stale socket. rm -f "$host.ctrl" fi +} + +stopit () { + + ## Initial shutdown protocol. + writefile "$host.state" stopping + if [ -f "$host.pid" ]; then kill $(cat "$host.pid") 2>/dev/null || :; fi + rm -f "$host.pid" + + ## Clobber the existing connection, if there is one. + clobber ## Update the state. rm -f "$host.state" "$host.pid" -- [mdw]