From 3a1fd2c139448bab97a96cc1b655893cc7ad6415 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Tue, 3 Apr 2018 13:48:58 -0400 Subject: [PATCH] tests/libvm: Support SSH_CONFIG env var When juggling multiple test VMs for different purposes, it's useful to be able to easily e.g. `make vmcheck` a specific one by overriding the ssh-config file to use, rather than editing the latter each time. Closes: #1324 Approved by: cgwalters --- tests/common/libvm.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/common/libvm.sh b/tests/common/libvm.sh index 7b3965ac..19d7dad7 100644 --- a/tests/common/libvm.sh +++ b/tests/common/libvm.sh @@ -21,14 +21,15 @@ vm_setup() { export VM=${VM:-vmcheck} + export SSH_CONFIG=${SSH_CONFIG:-${topsrcdir}/ssh-config} SSHOPTS="-o User=root -o ControlMaster=auto \ -o ControlPath=/var/tmp/ssh-$VM-$(date +%s%N).sock \ -o ControlPersist=yes" # If we're provided with an ssh-config, make sure we tell # ssh to pick it up. - if [ -f "${topsrcdir}/ssh-config" ]; then - SSHOPTS="${SSHOPTS} -F ${topsrcdir}/ssh-config" + if [ -f "${SSH_CONFIG}" ]; then + SSHOPTS="${SSHOPTS} -F ${SSH_CONFIG}" fi export SSHOPTS @@ -60,8 +61,8 @@ EOF # rsync wrapper that sets up authentication vm_raw_rsync() { local rsyncopts="ssh -o User=root" - if [ -f ${topsrcdir}/ssh-config ]; then - rsyncopts="$rsyncopts -F '${topsrcdir}/ssh-config'" + if [ -f "${SSH_CONFIG}" ]; then + rsyncopts="$rsyncopts -F '${SSH_CONFIG}'" fi rsync -az --no-owner --no-group -e "$rsyncopts" "$@" } @@ -81,8 +82,8 @@ vm_cmd_as() { local user=$1; shift # don't reuse root's ControlPath local sshopts="-o User=$user" - if [ -f "${topsrcdir}/ssh-config" ]; then - sshopts="$sshopts -F ${topsrcdir}/ssh-config" + if [ -f "${SSH_CONFIG}" ]; then + sshopts="$sshopts -F ${SSH_CONFIG}" fi ssh $sshopts $VM "$@" }