summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2017-02-20 09:58:31 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2017-02-20 10:08:49 +0000
commit525fdbc39c17a2271f3600d0c0eba288402cbcfc (patch)
tree757de28812f1d28129f16570e8d254a7fd673d49
parenta037c0b8f2271f1a4addb9e2384f74336fcb4dc3 (diff)
start-container-docker.sh: Fix ssh-agent cleanup.
Make sure to kill the just-started ssh-agent in case something goes wrong. Change-Id: Ibb6d659298da97754926d1fca5ff8255f00d5955
-rwxr-xr-xstart-container-docker.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/start-container-docker.sh b/start-container-docker.sh
index 4d8d4571..5f63d54f 100755
--- a/start-container-docker.sh
+++ b/start-container-docker.sh
@@ -136,7 +136,8 @@ fi
# Remove the docker instance we have just created in case something
# goes wrong.
-trap "$DOCKER rm -fv $session_id ; exec 1>&3 2>&4" EXIT
+CONTAINER_CLEANUP="$DOCKER rm -fv ${session_id}"
+trap "exec 1>&3 2>&4 ; ${CONTAINER_CLEANUP}" EXIT
session_port=$($DOCKER port $session_id 22 | cut -d: -f 2)
@@ -162,6 +163,7 @@ if [ "x`whoami`" = "xtcwg-buildslave" ]; then
eval `ssh-agent -s 3>&- 4>&-`
ssh-add $HOME/.ssh/id_rsa
SSH_AGENT_CLEANUP="ssh-agent -k"
+ trap "exec 1>&3 2>&4 ; ${CONTAINER_CLEANUP} ; eval \`$SSH_AGENT_CLEANUP\`" EXIT
fi
fi
@@ -203,7 +205,7 @@ fi
cat <<EOF
CONTAINER="ssh -p ${session_port} -A ${session_host}"
-CONTAINER_CLEANUP="$DOCKER rm -fv ${session_id}"
+CONTAINER_CLEANUP="${CONTAINER_CLEANUP}"
session_host=${session_host}
session_port=${session_port}
EOF