From 48f81d9ac6640e77dddecd2d116953ad7da1957b Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Wed, 6 Jan 2021 08:58:33 -0500 Subject: [PATCH] reduce setting ssh commands down to 1 function and 1 function call --- setup/so-functions | 45 ++++++++++++++------------------------------- setup/so-setup | 4 +--- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 8d12156ae..52c8b19c9 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1080,37 +1080,6 @@ get_minion_type() { echo "$minion_type" } -get_scp_cmd() { - local automated=$1 - - if [ $automated == yes ]; then - scpcmd='sshpass -p "automation" scp -o StrictHostKeyChecking=no' - else - scpcmd='scp' - fi -} - -get_ssh_cmd() { - local automated=$1 - - if [ $automated == yes ]; then - sshcmd='sshpass -p "automation" ssh -o StrictHostKeyChecking=no' - else - sshcmd='ssh' - fi - -} - -get_ssh_copy_id_cmd() { - local automated=$1 - - if [ $automated == yes ]; then - sshcopyidcmd='sshpass -p "automation" ssh-copy-id -o StrictHostKeyChecking=no' - else - sshcopyidcmd='ssh-copy-id' - fi -} - host_pillar() { local pillar_file="$temp_install_dir"/pillar/minions/"$MINION_ID".sls @@ -2005,6 +1974,20 @@ set_progress_str() { "----" >> "$setup_log" 2>&1 } +set_ssh_cmds() { + local automated=$1 + + if [ $automated == yes ]; then + sshcmd='sshpass -p "automation" ssh -o StrictHostKeyChecking=no' + sshcopyidcmd='sshpass -p "automation" ssh-copy-id -o StrictHostKeyChecking=no' + scpcmd='sshpass -p "automation" scp -o StrictHostKeyChecking=no' + else + sshcmd='ssh' + sshcopyidcmd='ssh-copy-id' + scpcmd='scp' + fi +} + sensor_pillar() { local pillar_file=$temp_install_dir/pillar/minions/$MINION_ID.sls diff --git a/setup/so-setup b/setup/so-setup index 7ab87a23a..991273b65 100755 --- a/setup/so-setup +++ b/setup/so-setup @@ -146,9 +146,7 @@ case "$setup_type" in esac #set ssh commands that will be used based on if this is an automated test install or not -get_scp_cmd $automated -get_ssh_cmd $automated -get_ssh_copy_id_cmd $automated +set_ssh_cmds $automated # Allow execution of SO tools during setup local_sbin="$(pwd)/../salt/common/tools/sbin"