Files
wizwar6e/deploy/deploy.sh
T
Eric WagonerandClaude Fable 5.1 636d97d5c1 The nightly rollup and backup say by their exit status whether they managed, and the deploy leaves the cron file off a host the hall schedules
On the shared host the hall's hall-nightly.sh (game-kit, gamehall/ops) runs
both scripts for every game and checks in with Sentry Crons once for all,
so this game's own check-in files are absent there and its exit status is
the word. A box of its own keeps its cron and check-ins as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-12 10:07:06 -04:00

39 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build locally, push to the droplet, restart. Usage: deploy/deploy.sh <droplet-ip>
set -euo pipefail
HOST="${1:?usage: deploy.sh <droplet-ip-or-host>}"
# The family list is the kit's; the site deploys with the kit's latest copy when the kit is beside this checkout.
KIT_FAMILY="$(dirname "$0")/../../game-kit/family.json"
[ -f "$KIT_FAMILY" ] && cp "$KIT_FAMILY" packages/web/public/family.json
npm run build --workspace=@wizwar/web
# /data/ is the local game ledgers, anchored so the engine's own data/ (the
# cards and boards the server reads) always ships.
# Old hashed chunks stay a week: a page loaded before this deploy can still
# fetch the module it was built against instead of failing mid-game.
rsync -az --delete --filter='P packages/web/dist/assets/*' \
--exclude node_modules --exclude /data/ --exclude .git --exclude research \
./ "root@$HOST:/opt/wizwar/"
ssh "root@$HOST" '
cd /opt/wizwar && npm install --no-audit --no-fund
find /opt/wizwar/packages/web/dist/assets -type f -mtime +7 -delete
chown -R wizwar:wizwar /opt/wizwar
cp /opt/wizwar/deploy/wizwar.service /etc/systemd/system/wizwar.service
# Cron runs the backup and the rollup from /usr/local/bin: install
# them on every deploy so the live copies are always the repo copies.
install -m 755 /opt/wizwar/deploy/wizwar-backup.sh /usr/local/bin/wizwar-backup.sh
install -m 755 /opt/wizwar/deploy/wizwar-rollup.sh /usr/local/bin/wizwar-rollup.sh
install -m 755 /opt/wizwar/deploy/wizwar-visitors.sh /usr/local/bin/wizwar-visitors.sh
# On a host the hall shares, its hall-nightly.sh runs the rollup and backup
# of every game and checks in with Sentry once for all; a game on a box of
# its own schedules its own.
if [ -f /etc/cron.d/gamehall ]; then rm -f /etc/cron.d/wizwar-rollup
else install -m 644 /opt/wizwar/deploy/wizwar-rollup.cron /etc/cron.d/wizwar-rollup; fi
systemctl daemon-reload
systemctl enable --now wizwar
systemctl restart wizwar
systemctl --no-pager -l status wizwar | head -5
'
echo "deployed."