From 1e73232b190be4e20319d31789ab6c13b234a8b5 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Wed, 7 Nov 2018 09:37:10 -0600 Subject: [PATCH] Setup Script - Change tmp location and delte key if its already there --- VERSION | 2 +- so-setup-network.sh | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 6d7de6e6a..21e8796a0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.2 +1.0.3 diff --git a/so-setup-network.sh b/so-setup-network.sh index 9a0e95645..4673518a1 100644 --- a/so-setup-network.sh +++ b/so-setup-network.sh @@ -35,8 +35,27 @@ accept_salt_key_local() { accept_salt_key_remote() { - # Accept the key remotely so the device can check in - ssh -v -i /root/.ssh/so.key socore@$MSRV sudo salt-key -a $HOSTNAME -y + # See if the key is already there. If so nuke it. + GETKEYSACCEPTED=$(ssh -v -i /root/.ssh/so.key socore@$MSRV sudo salt-key -l accepted) + GETKEYSREJECTED=$(ssh -v -i /root/.ssh/so.key socore@$MSRV sudo salt-key -l rejected) + + if grep -q $HOSTNAME $GETKEYSACCEPTED; then + SKACPT=1 + else + SKACPT=0 + fi + if grep -q $HOSTNAME $GETKEYSREJECTED; then + SKRJCT=1 + else + SKRJCT=0 + fi + + if [ $SKACPT=1 ] || [ $SKRJCT=1 ]; then + ssh -v -i /root/.ssh/so.key socore@$MSRV sudo salt-key -d $HOSTNAME -y + else + # Accept the key remotely so the device can check in + ssh -v -i /root/.ssh/so.key socore@$MSRV sudo salt-key -a $HOSTNAME -y + fi } @@ -333,15 +352,15 @@ got_root() { install_cleanup() { # Clean up after ourselves - rm -rf ./installtmp + rm -rf /root/installtmp } install_prep() { # Create a tmp space that isn't in /tmp - mkdir ./installtmp - TMP=./installtmp + mkdir /root/installtmp + TMP=/root/installtmp }