diff --git a/mq.sh b/mq.sh index 22d6d74..350db8a 100755 --- a/mq.sh +++ b/mq.sh @@ -68,6 +68,14 @@ case "$command" in ;; esac +# At this point all of the commands we might run need to SSH. Only the "run" +# command passes files, so for the "sem" etc we can just ssh to tftp, and rerun +# the full mq.sh script. This uses only 1 SSH connection. +if [ "$(hostname -f)" != "${HOST}" ] && [ "$command" != "run" ]; then + RemoteExec mq.sh "$command" "$@" + exit $? +fi + # Check we can talk to the cannonical host if ! RemoteCommand exit; then diff --git a/scripts/remote b/scripts/remote index e244f56..8256dbc 100755 --- a/scripts/remote +++ b/scripts/remote @@ -27,3 +27,10 @@ RemoteCommand() { fi RemoteCommandOn "${HOST}" "$@" } + +# Like RemoteCommand, but doesn't run "stty" to change echo behaviour +# Needs -tt for pseudo-tty so that Ctrl+C interrupts are forwarded to +# bash on the remote end. +RemoteExec() { + ssh -tt -oLogLevel=quiet "${HOST}" "$@" +}