From e3b670b8b8ee7d9b95a366002ea6d6bd082d0b09 Mon Sep 17 00:00:00 2001 From: Julia Vassiliki Date: Fri, 23 Oct 2026 11:06:13 +1100 Subject: [PATCH] Run mq.sh command over SSH to reduce connections Previously every remote command e.g. `mq.sh sem dumpall` would SSH to tftp.keg.cse.unsw.edu.au multiple times. Even with ControlMastering, this still needs to open lots of login shells, which for us tends to be very slow. Instead, if we re-run the entire mq.sh command on the remote host, then we only need to SSH once. We don't do this for run, however, because it needs to copy files back and forth. It could definitely be done, however, it is more effort to do so. Hopefully, this would reduce the load on our servers and make 'run' less intensive. Signed-off-by: Julia Vassiliki --- mq.sh | 8 ++++++++ scripts/remote | 7 +++++++ 2 files changed, 15 insertions(+) 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}" "$@" +}