From 0a8a6c8d6987a4a835c8e365fc8eaedfa9a80900 Mon Sep 17 00:00:00 2001 From: David McNett Date: Tue, 26 Dec 2017 11:39:19 -0600 Subject: [PATCH] Ugly but functional solution for bash lameness It turns out my previous attempt at a bash solution didn't actually work. I just got confused during testing because my test target inadvertantly had a good copy of ./bin/netskel copied from a previous attempt and it appeared to work but didn't. Bash completely dumps the push session as soon as it fetches the Netskel client script from the server and no subsequent commands get run. This doesn't happen on true /bin/sh (BSD) or on /bin/dash (Debuntu) hosts. The cleanest workaround I found was simply to chain all the remaining commands on the single line using && links. This seems to work everywhere I've tested, albeit in a somewhat ugly way. Good enough for me to be happy. --- client/netskel | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/client/netskel b/client/netskel index 07a9eb5..7f1b929 100755 --- a/client/netskel +++ b/client/netskel @@ -344,16 +344,11 @@ case $1 in echo 'EOF' >> $NETSKEL_INSTALL_SCRIPT echo 'chmod 600 $HOME/.netskel/config' >> $NETSKEL_INSTALL_SCRIPT - echo "ssh -q -p $NETSKEL_PORT -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $NETSKEL_SERVER rawclient > ./bin/netskel" >> $NETSKEL_INSTALL_SCRIPT - echo 'chmod 700 $HOME/bin/netskel' >> $NETSKEL_INSTALL_SCRIPT - - echo '$HOME/bin/netskel init && \' >> $NETSKEL_INSTALL_SCRIPT - echo 'echo "Syncing this host for the first time:" && \' >> $NETSKEL_INSTALL_SCRIPT - echo '$HOME/bin/netskel sync' >> $NETSKEL_INSTALL_SCRIPT + echo "ssh -Atq -p $NETSKEL_PORT -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $NETSKEL_SERVER rawclient > ./bin/netskel && chmod 700 ./bin/netskel && ./bin/netskel init && ./bin/netskel sync && echo '\nNetskel INIT Successful'" >> $NETSKEL_INSTALL_SCRIPT netskel_log "Pushing Pack:" echo "-- " - ssh -ATq -o ConnectTimeout=5 $2 < $NETSKEL_INSTALL_SCRIPT || netskel_log "Unable to connect to $2" + ssh -ATq -o ConnectTimeout=5 $2 /bin/sh < $NETSKEL_INSTALL_SCRIPT || netskel_log "Unable to connect to $2" echo "-- " netskel_cleanup