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"