Skip to content

Commit

Permalink
Ugly but functional solution for bash lameness
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nugget committed Dec 26, 2017
1 parent 8c596c5 commit 0a8a6c8
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions client/netskel
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a8a6c8

Please sign in to comment.