From d06f9f62dff9b013dccec35325b0f544d002b4cc Mon Sep 17 00:00:00 2001 From: Chris Wanstrath <2+defunkt@users.noreply.github.com> Date: Tue, 16 Sep 2025 20:41:17 -0700 Subject: [PATCH] fun --- scripts/deploy.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 976c370..b2b705f 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -7,12 +7,21 @@ set -euo pipefail HOST="chris@nose-pluto.local" DEST="~/pluto" +SOCK="$HOME/.ssh/cm-%r@%h:%p" -# sync (skip node_modules and .git) +# 1) Open a master connection (prompts once) +ssh -MNf -o ControlMaster=yes -o ControlPersist=120 \ + -o ControlPath="$SOCK" "$HOST" + +# 2) rsync (reuses the connection) rsync -az --delete \ + -e "ssh -o ControlPath=$SOCK" \ --exclude 'node_modules/' \ --exclude '.git/' \ ./ "$HOST:$DEST/" -# install deps + restart service -ssh "$HOST" 'cd ~/pluto && bun install --frozen-lockfile && sudo systemctl restart nose-pluto.service' +# 3) remote install (reuses the connection) +ssh -o ControlPath="$SOCK" "$HOST" "cd $DEST && bun install --frozen-lockfile && sudo systemctl restart nose-pluto.service" + +# 4) close the master connection +ssh -O exit -o ControlPath="$SOCK" "$HOST"