nose-pluto/app/scripts/deploy.sh
Chris Wanstrath 1f86909e37 finally
2025-09-22 15:07:26 -07:00

40 lines
993 B
Bash
Executable File

#!/usr/bin/env bash
##
# deploys from your dev machine to your NOSEputer
set -euo pipefail
source ./scripts/config.sh
SOCK="$HOME/.ssh/cm-%r@%h:%p"
# 1) Open a master connection (prompts once)
ssh -MNf -o ControlMaster=yes -o ControlPersist=120 \
-o ControlPath="$SOCK" "$HOST"
# 2) rsync (reuses the connection)
# ensure our directory exists
ssh -o ControlPath=$SOCK "$HOST" "mkdir -p $DEST/app"
# destructive sync for /app
rsync -az --delete \
-e "ssh -o ControlPath=$SOCK" \
--exclude 'node_modules/' \
--exclude '.git/' \
../app/ "$HOST:$DEST/app/"
# additive sync for root, /bin, /www
rsync -az \
-e "ssh -o ControlPath=$SOCK" \
--exclude 'node_modules/' \
--exclude '.git/' \
--exclude 'app/' \
../ "$HOST:$DEST/"
# 3) remote deploy (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"