mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-12 22:21:28 +01:00
Make run_remote_test's use of ssh-agent more predictable.
Review URL: http://codereview.chromium.org/560005
This commit is contained in:
parent
797abfd825
commit
9969ce9238
@ -25,6 +25,9 @@ function remote_sh_allow_changed_host_key() {
|
|||||||
function set_up_remote_access() {
|
function set_up_remote_access() {
|
||||||
if [ -z "$SSH_AGENT_PID" ]; then
|
if [ -z "$SSH_AGENT_PID" ]; then
|
||||||
eval $(ssh-agent)
|
eval $(ssh-agent)
|
||||||
|
OWN_SSH_AGENT=1
|
||||||
|
else
|
||||||
|
OWN_SSH_AGENT=0
|
||||||
fi
|
fi
|
||||||
cp $FLAGS_private_key $TMP_PRIVATE_KEY
|
cp $FLAGS_private_key $TMP_PRIVATE_KEY
|
||||||
chmod 0400 $TMP_PRIVATE_KEY
|
chmod 0400 $TMP_PRIVATE_KEY
|
||||||
@ -36,6 +39,17 @@ function set_up_remote_access() {
|
|||||||
echo "Connection OK"
|
echo "Connection OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanup_remote_access() {
|
||||||
|
# Call this function from the exit trap of the main script.
|
||||||
|
# Iff we started ssh-agent, be nice and clean it up.
|
||||||
|
# Note, only works if called from the main script - no subshells.
|
||||||
|
if [[ 1 -eq ${OWN_SSH_AGENT} ]]
|
||||||
|
then
|
||||||
|
kill ${SSH_AGENT_PID} 2>/dev/null
|
||||||
|
unset SSH_AGENT_PID SSH_AUTH_SOCK
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function remote_access_init() {
|
function remote_access_init() {
|
||||||
TMP_PRIVATE_KEY=$TMP/private_key
|
TMP_PRIVATE_KEY=$TMP/private_key
|
||||||
TMP_KNOWN_HOSTS=$TMP/known_hosts
|
TMP_KNOWN_HOSTS=$TMP/known_hosts
|
||||||
|
|||||||
@ -29,11 +29,7 @@ function cleanup() {
|
|||||||
else
|
else
|
||||||
echo "Left temporary files at ${TMP}"
|
echo "Left temporary files at ${TMP}"
|
||||||
fi
|
fi
|
||||||
if [[ -n "${SSH_AGENT_PID}" ]]
|
cleanup_remote_access
|
||||||
then
|
|
||||||
kill ${SSH_AGENT_PID} 2>/dev/null
|
|
||||||
unset SSH_AGENT_PID SSH_AUTH_SOCK
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns an error if the test_result_file has text which indicates
|
# Returns an error if the test_result_file has text which indicates
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user